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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
/ d6 W8 n4 T6 s  A8 g6 b# e* K3 y#include <linux/init.h>0 Q( `* d5 U  y7 E" i
#include <linux/module.h>
. P5 w4 b/ v5 }) j8 e, v  t0 p#include <linux/kernel.h>" V! |+ u6 [, H) n9 f
#include <linux/types.h>
/ k6 ~; y$ m* W: d#include <linux/gpio.h>  l3 n3 j! C( f3 b0 u& j
#include <linux/leds.h>, b. \2 L1 g( H
#include <linux/platform_device.h>
! G+ w$ ?: [7 c
6 h. S/ V4 `# i4 Z. j#include <asm/mach-types.h>
+ L; h  v( L& k! l; o#include <asm/mach/arch.h>
& U  I8 `& A0 q4 o& }7 X: g#include <mach/da8xx.h>
# F6 w+ e1 i: i$ u+ R#include <mach/mux.h>
' p* h2 Q* d( Y, m+ e/ n
4 Z& c  h) K7 P* n. V#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)( n5 a: n* ?6 n% w
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)# P5 b& {9 o; E. B5 d8 F% r
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
8 ?4 i. `/ e$ N% p#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& r: w9 {: J: U; j7 ]$ @
; x+ U% G* ^2 k9 m6 }6 {
/* assign the tl som board LED-GPIOs*/* ~2 @' v# h7 A3 N0 G% k* O; P0 k
static const short da850_evm_tl_user_led_pins[] = {
, J; I& C( j- U; R3 G# m* c9 g) ]        /* These pins are definition at <mach/mux.h> file */! |* J$ E1 H. m; l  w
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 o+ V1 J7 f4 @- t
        -1
$ i# |2 W% w" E9 l};
! n- m& [* p6 ?" g! X/ c8 d% c( L; u' u( R! v) E4 J% b; ]! L
static struct gpio_led da850_evm_tl_leds[] = {
/ h; }0 u1 l* d. J        {9 u9 D* ~2 Y' U6 l5 c+ {
                .active_low = 0,
! b9 U: G4 H' M                .gpio = DA850_USER_LED0,
! V( Q9 u% f4 D! W" f7 L                .name = "user_led0",
5 s( ^/ }- Z; ~                .default_trigger = "default-on",& A- @% m( \$ [: k
        },
. N4 q9 T; c' S9 K. [        {! U. q8 X4 V# A+ V, t+ c
                .active_low = 0,
- D$ w" T/ p' I! T: c! x* O+ A                .gpio = DA850_USER_LED1," K" Y+ i: M1 v4 E
                .name = "user_led1",) F9 N* K4 z5 T$ P
                .default_trigger = "default-on",% f7 h7 I. N& p
        },
1 O+ Z/ Q9 g- a' O4 ?        {  d/ I/ F3 K. L$ E
                .active_low = 0,2 h9 G! u4 i# ?# f/ N
                .gpio = DA850_USER_LED2,
/ O* c9 V3 S" m. X( ~9 n% W                .name = "user_led2",6 Z% O! b' Q# c( I% z; i
                .default_trigger = "default-on",
& Z" q# y, _- E2 u3 E, ^        },# _' J8 i9 }  Z# Z5 @/ g$ v
        {
- ]" }7 o; X5 b2 a9 ]                .active_low = 0,
8 [( _: F  K# ^1 t7 b                .gpio = DA850_USER_LED3,
0 f5 N  @2 s( r7 j1 c                .name = "user_led3",# W* i$ H. p& }$ W* ?
                .default_trigger = "default-on",
2 o/ H+ M% d$ d9 d* s4 \        },
! [% Z1 w+ _5 T; |* ?};
4 O5 Z7 u4 r7 z, o" c: ]+ e: y% ]8 \" n& s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {  y, j& a) Z* C0 ~
        .leds = da850_evm_tl_leds,
5 ~: a+ M6 ?- w/ h$ a2 ^' C        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) J# z$ n+ L; i, O};
1 j' ^% K! d% f: c! K9 _3 S
/ C7 f- ~( Q, A6 K6 s2 {3 l5 A+ Nstatic void led_dev_release(struct device *dev)8 F& g$ g0 h( z* \
{6 j! v! M3 `& r" z( ?2 K7 ?
};9 w+ P! ~3 U* q; O: s
0 t( s6 @6 ^/ {8 o
static struct platform_device da850_evm_tl_leds_device = {" p; r2 K1 I1 n0 S" f5 `
        .name                = "leds-gpio",
5 [$ q) q3 i, n        .id                = 1,
: M/ k& A3 N4 E  |: @, m( ], T        .dev = {
& E- x8 U) o6 q( q( h* k" t                .platform_data = &da850_evm_tl_leds_pdata,/ G6 J& l# R7 [2 z  f1 r
                .release = led_dev_release,1 m6 F) s3 p3 i) f( m! j: m
        }
& [' T: O  S- u; R};; E3 ^' ^8 f" b: L

1 G3 d0 v, {% X0 @% j) b4 y( ]+ Rstatic int __init led_platform_init(void)
# P# V3 S, }$ c, L0 Q% _{4 o: a! q# ^3 E  d) _
        int ret;
2 e8 O# U# P2 L5 ^5 g( v! e  }; e#if 0' }( T2 p; B$ K1 s/ t- N) G
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, P( R1 G! u7 ]& [9 B        if (ret)" R0 F* X/ L7 j0 ~, B; g" I
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' C- \' ]  o6 N7 U! ]                                "%d\n", ret);/ B9 [7 w  ]4 Z' K* x
#endif0 F/ d# w7 ]% X$ r* g6 A2 L6 O
        ret = platform_device_register(&da850_evm_tl_leds_device);2 b* b0 ~' I; n
        if (ret)
3 M! R! O: m( w9 w' V* j                pr_warning("Could not register som GPIO expander LEDS");" b. g) f  L- ~* p
        else& _' {3 ]% Z  }' g% F
                printk(KERN_INFO "LED register sucessful!\n");" V) O* Q: I: F

1 }* Y! F/ A* E3 c' T8 x        return ret;2 I7 h% R# D& m4 ]
}
+ h8 R# R8 R  Y/ i
- z. E8 b# G6 k" |. u* D" lstatic void __exit led_platform_exit(void)$ z0 _$ Q4 t+ V1 N/ ?8 t. j1 @" n
{
$ Q& O& z7 `3 B7 D% s7 X2 p        platform_device_unregister(&da850_evm_tl_leds_device);
0 S/ r' i$ s. H, `& y5 d
2 V' Q. U; y2 Y6 |; p        printk(KERN_INFO "LED unregister!\n");- @+ G/ }$ s7 u; _. U
}, I9 ~% \  y9 n5 |  J
+ c2 r/ r; u* V: C+ m2 n9 s  `
module_init(led_platform_init);
( z. g- J4 H$ N; v1 U* J2 hmodule_exit(led_platform_exit);
$ Y- H2 t1 B  J7 I2 K8 x8 m9 M# p' a+ m
MODULE_DESCRIPTION("Led platform driver");2 v; q1 I4 O8 {5 c1 ^
MODULE_AUTHOR("Tronlong");) p" F% J" A& M8 N" `3 \# A) X5 L7 j
MODULE_LICENSE("GPL");
; v( \) d" J( S  b1 \
' C6 i" u, p; y! D8 a1 L
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-13 01:25 , Processed in 0.037307 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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