程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 5940|回复: 0
打印 上一主题 下一主题

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
) Q( r" ^4 h- d; }* z4 F$ N#include <linux/init.h>
6 \7 T( v7 }' N#include <linux/module.h>+ w) S$ a" {# T; C) n
#include <linux/kernel.h>
% k3 n( M- i& l/ r#include <linux/types.h>
6 O% `" T) U2 L  Q+ l#include <linux/gpio.h>" ]# \, e1 D3 N; c: X- i" e
#include <linux/leds.h>
+ v4 c- O5 ^5 A( U' n: }#include <linux/platform_device.h>8 u, v3 t* O* L5 v& n
* c" [: U# q8 |; r# W
#include <asm/mach-types.h>$ s! |  t* Z6 C  [
#include <asm/mach/arch.h>
) l$ j3 W7 e/ W  D4 t9 O#include <mach/da8xx.h>
: P( f! F8 N2 H7 |2 I1 F. Z#include <mach/mux.h>
# h% D$ d$ a; t" i) A
2 S# L/ v4 V( D. J#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)/ }3 y8 y0 I- _1 |& i# b/ `) N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5): S) b, T) r) U5 [6 I
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
2 x0 U) |' K+ p% Q3 p9 t# y#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
" f4 M  |6 Y! }8 y3 ]8 Q, Z+ i) N
/* assign the tl som board LED-GPIOs*/2 }: z( |  O) d' Q1 j* H- c( u
static const short da850_evm_tl_user_led_pins[] = {$ f& K( O6 k/ U/ K
        /* These pins are definition at <mach/mux.h> file */- U- e; K7 S+ L: h" g6 A
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 a9 Z- }" [/ j/ K0 @* n3 v4 }
        -1
- z1 p5 f  t2 i3 u+ r};
4 K/ T- B! x2 [8 G& a" ]! c# _7 W- n7 B1 G
static struct gpio_led da850_evm_tl_leds[] = {9 K% r# W! E; p% K
        {! C: S8 Y: x. w- A
                .active_low = 0,
2 u, h; C- `! `8 V) E/ u                .gpio = DA850_USER_LED0,
* P  _4 v4 \* y' s8 {/ T                .name = "user_led0",
, ]6 F8 j5 G4 P" `( t$ e1 a                .default_trigger = "default-on",
1 }) H1 j3 c% ]/ o5 P  ~  q  z        },7 U% N- Z% I. A5 J) w. Z, C
        {
2 Z# i* W$ h" ]2 A, X- ~9 ^) B                .active_low = 0,! Y2 g! L' Z. {  a) u
                .gpio = DA850_USER_LED1,
$ U7 V- a9 e7 c( }. x) D9 C                .name = "user_led1",6 M! W. f7 f9 f- H2 @4 I) N4 C) K
                .default_trigger = "default-on",
% P. p- {; c5 @" ]        },
* X" G6 e7 n% J) B        {2 r8 X: d$ a5 f( ?
                .active_low = 0,, N" s8 r9 w0 T
                .gpio = DA850_USER_LED2,
. ^, t2 u9 i& S: ?, f. ~7 h                .name = "user_led2",, ^& f2 t  B; m% L3 \4 Q! \3 q
                .default_trigger = "default-on",
+ J: W- e" T5 Z8 r7 _2 z$ d! ?        },1 J4 p6 Y0 b& @: c
        {5 a5 J. Q4 l- V
                .active_low = 0,
  K0 r7 v& x8 u  _6 G2 ]                .gpio = DA850_USER_LED3,+ q, g- k) m6 e) }% U: Z
                .name = "user_led3",
2 v5 E2 ^. V$ [! O2 l                .default_trigger = "default-on",* l. l4 `+ V# p( z5 w# ?( f$ `
        },9 t* f' I9 i# ^* o# v! i
};, z6 |4 Q3 z% x0 l0 l$ K5 b. W; v1 h
" |" j9 ^- g( p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( ~6 _- R) C0 ~0 u        .leds = da850_evm_tl_leds,
2 U/ T! a, [0 c* l        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ N2 H1 A- ]3 y9 U: K5 Z};% M0 h) a& {9 m: Y; Y

- g2 O5 l. d. m( p$ u3 Wstatic void led_dev_release(struct device *dev)* K9 ^4 C9 }4 D  e/ F! l+ A
{
% o7 Q0 N$ b: K9 L8 Y$ ]1 M4 o) ~};
: k: ~' }% b& E; C# s# M
, w7 [: D; s0 q$ t+ x6 _: ^static struct platform_device da850_evm_tl_leds_device = {
' D  X3 z6 a& G0 B  Y        .name                = "leds-gpio",
4 y$ Y; m* E  W: C        .id                = 1,; S+ Q7 R- A5 r
        .dev = {5 O' k* b# C4 _4 C8 K4 j) q+ G
                .platform_data = &da850_evm_tl_leds_pdata,
* o0 l( a% a! m, h  Y- g+ [                .release = led_dev_release,: [4 H2 M1 T: A2 s3 s3 J+ m! K
        }; g0 B5 m1 c) O0 l; l' U- h# }
};
& B0 d* I4 t; y9 H$ M
$ w9 o) G$ C* n& N* A* @! T" U* kstatic int __init led_platform_init(void)% a  z, W% G9 p7 G7 O# C
{
1 ^- ], }+ r' ]) ?; e        int ret;
: X( n; a" Y8 u' ?0 ^7 _#if 0  t' r& R/ j' G: g
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" C4 k9 O+ u- }2 N
        if (ret)
0 l$ X0 C/ r" X" v3 Y0 v# M1 C, E                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 |0 t; X( X1 U1 i3 [: B  p6 [                                "%d\n", ret);
, i9 Q, d6 M0 a: T0 @$ ?) v#endif
: {1 ~8 r, `) `' t4 V        ret = platform_device_register(&da850_evm_tl_leds_device);
7 x% w& D. X0 b- o$ f5 L7 `2 o% c        if (ret)  L5 y! J1 l  ~* f6 Q% I
                pr_warning("Could not register som GPIO expander LEDS");+ d: A  {% p, Q1 G8 W3 u0 `" {
        else2 ?8 Z" Y: h9 `3 J+ k1 q: L
                printk(KERN_INFO "LED register sucessful!\n");
8 ~+ r+ D- }7 j4 }. t1 e7 D/ y4 Z# ^' |& H: x% V) g7 p
        return ret;/ m' A! d  }8 H" o' U/ h$ {& i
}0 D6 r# N  |# y5 }* ~
/ s0 @! k  I; b" V# N
static void __exit led_platform_exit(void)
2 A* @. H5 R& a+ ~# C; @3 c{# r' m; X9 D  q' K" [
        platform_device_unregister(&da850_evm_tl_leds_device);
# w1 E; L+ e) K0 U+ d
$ b8 }+ L7 ~0 b5 {; x0 l: }* h        printk(KERN_INFO "LED unregister!\n");
8 {8 V: }  S2 L$ n4 a3 H+ |}
0 F7 `0 D* c1 B* m, y2 g6 `' L0 O7 I5 z) z/ Q4 g
module_init(led_platform_init);' b/ c/ F& T  D2 _7 S5 ~
module_exit(led_platform_exit);
2 ^( J1 J; Q% q5 ]
9 T4 M* W2 Q4 f+ tMODULE_DESCRIPTION("Led platform driver");
' \0 J: k- T8 q- F2 Z% Y7 nMODULE_AUTHOR("Tronlong");
) a5 f# `3 v% YMODULE_LICENSE("GPL");
9 P/ Y+ ~- t/ S0 k- X8 [# g. _
+ b0 _$ g6 [# @* J% S, b. ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|嵌入式开发者社区 ( 粤ICP备15055271号

GMT+8, 2025-10-10 18:48 , Processed in 0.035996 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

快速回复 返回顶部 返回列表