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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
1 r/ H0 T) k) S/ h6 }#include <linux/init.h>
- Q* U5 m7 k* f# H4 h* S#include <linux/module.h>7 n8 i$ }- d( Y4 g$ X. O# J' \
#include <linux/kernel.h>
* z) {2 _* \* B) ?. w! i" @#include <linux/types.h>
( y; j( ^3 Q! A4 |& R#include <linux/gpio.h>
) i2 h; {' s7 N" q#include <linux/leds.h>
' x/ E/ m+ y$ q5 N#include <linux/platform_device.h>% H* ?5 p' p6 ^! Y2 J

5 P* ^3 }) Y0 p7 s. `  I+ t#include <asm/mach-types.h>0 }- k5 Z' [% u( O" P1 k; d
#include <asm/mach/arch.h>
" r3 ]0 q) `% O0 Q% N  N9 O#include <mach/da8xx.h>
3 W& q' T- O2 \: r3 s# N#include <mach/mux.h>
+ r) u+ \. N* Q; h2 i0 ~7 l, L+ O( M' n: @9 _
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
' ^1 d' E: E4 b, C#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) P  Z4 h5 P: {- O# h: \1 b! p#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)* d( w& r1 `: O1 F/ f3 \
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# }7 d7 c% g: S0 R3 C
8 Q1 }9 X9 T5 B* P" f4 z# }2 _) A/* assign the tl som board LED-GPIOs*/3 }. D" G- ~8 B0 P
static const short da850_evm_tl_user_led_pins[] = {
0 u5 [$ r$ t  n7 z7 V        /* These pins are definition at <mach/mux.h> file */
4 a  V9 S" V" _! r2 ?9 }5 V        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: p$ [- S( d! f        -1
1 {# D# T- l0 ?2 d};
' K1 ]! z* `" m
4 _8 _: f" U! ^5 \9 p; Vstatic struct gpio_led da850_evm_tl_leds[] = {
9 w' _$ J2 _3 o* @        {9 o, e/ Y( b* ?0 w* _& G
                .active_low = 0,5 W, Q$ C9 F, s5 ~+ q, z/ g
                .gpio = DA850_USER_LED0,
8 y( m  E1 r- G! l7 d/ ]; D( ~' ~7 O2 K                .name = "user_led0",
/ i4 y- Q& i" g& G4 h: f- i9 s                .default_trigger = "default-on",
* Z# {/ c, m* T; q& W. @        },
; o  s7 q; ?0 B7 f; c        {/ [# C0 D6 M% E  r3 e7 R
                .active_low = 0,
( k1 M8 T3 c' q0 I0 ?- D                .gpio = DA850_USER_LED1,# J3 T- u% n$ o% Z3 V$ G1 c
                .name = "user_led1",9 R, X$ w+ \7 a0 g! u, f
                .default_trigger = "default-on",9 N% [5 z0 t. l9 \5 Y1 o: Z4 {/ u
        },
  `  {; F  @. k7 ^( w        {6 }6 Z# k/ j7 o& q( L
                .active_low = 0,/ }) b5 O+ x$ J  k" F  d6 v: y
                .gpio = DA850_USER_LED2,- E+ e- L- F* j8 p, V
                .name = "user_led2",
% y( \' v( B2 M) m0 [" P+ H6 t; L                .default_trigger = "default-on",- R/ G. F* {. B, c  l% G1 g
        },8 B2 E1 C. E/ h; g3 r5 f  ]
        {. I" l  [7 f4 `& W, r
                .active_low = 0,. }$ Z/ |7 i7 c, X0 j6 J: J& i
                .gpio = DA850_USER_LED3,8 J* R" x! L: r
                .name = "user_led3",
0 F/ H- W% q. ^. |1 ?  F# q                .default_trigger = "default-on",
0 R- \( W$ Y& }" f) I        },
/ i7 t& ~! q  R5 z( g9 |};
* e; U& d- A0 h( R- r  ~2 L- \6 t
, E; J! G8 R' r$ t0 i  Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 _# i& g/ e! I- s" k4 m( l& J        .leds = da850_evm_tl_leds,- U. L7 X9 i6 L" a, H: I/ A
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ [& [6 k( t2 d. |
};
0 v$ Q; i( Y/ e/ u* a8 |( h$ C9 ]+ b" c& o* @. W$ R
static void led_dev_release(struct device *dev)
7 n. ]. a3 w0 n# H. [  I{' ?4 u7 ]7 z* ~" ^/ g6 W( y
};# A, e8 T7 Y. i0 n

5 o$ v$ N9 i% `7 s; f) J7 Estatic struct platform_device da850_evm_tl_leds_device = {- |& f% e' e1 E8 U  J
        .name                = "leds-gpio",3 i( x! `1 Z" q; z  s1 e
        .id                = 1,
3 Z, C: c' s0 j        .dev = {
3 |& [0 c9 m& i4 x' ^" \( m9 b                .platform_data = &da850_evm_tl_leds_pdata,
; u. D4 @" X8 \6 l* T                .release = led_dev_release,5 ~& G3 A: s7 @
        }1 T8 C( ]6 i7 T6 U9 f
};
& n5 c8 o) e$ p" m- |+ U5 R# }3 d$ U
static int __init led_platform_init(void)
. u# T( ^; V! _/ b* x0 ~' q) |1 A{7 T3 B4 J: u7 Y7 t6 a. _
        int ret;
" @/ m$ X! y, }: F9 S#if 0
1 |" w' ~2 k) }2 X, ~+ d1 ~  k1 I; j        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& [1 m4 \  u2 d6 ~' {        if (ret)3 r: l, P1 d7 m: ~
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :", K/ p; H3 x* V, q# K
                                "%d\n", ret);. P1 J6 g( `  E/ o) I% s
#endif
  L5 [8 i( H$ G7 u% N% [        ret = platform_device_register(&da850_evm_tl_leds_device);
2 ?  E+ R: |. _& |        if (ret)& x# X% k  R( v% d
                pr_warning("Could not register som GPIO expander LEDS");  h8 m  ?# k& h) z2 d
        else
2 A; T; r) v- s5 B! |/ t                printk(KERN_INFO "LED register sucessful!\n");2 q* Q8 x7 |* H; p6 L* ]
! N5 [+ j( ]* I9 G- Z3 i# m
        return ret;
1 b' u" C0 c9 E' y* l: p+ t}. H& g, T+ T6 u5 @$ |; Z+ o

# S* Y  Y% I2 d+ @7 b. K# W, \static void __exit led_platform_exit(void)+ x2 t+ @( y) `6 D  C' L  g
{
- H! G9 x% n. L        platform_device_unregister(&da850_evm_tl_leds_device);8 D- u( m1 l! g, {

# V3 k4 M+ _* I0 I( K% `8 A9 M" w        printk(KERN_INFO "LED unregister!\n");6 H! e+ R. X1 Q& l! L$ N
}
  d* {1 c* z$ T6 E$ o) z" D/ @
4 I& k( p  P4 A+ X% Wmodule_init(led_platform_init);
7 X! C; B1 s8 w+ N4 s- fmodule_exit(led_platform_exit);- ^' `$ Q, Y; \

# d! H( F! j& r* `9 y( ^" T" [MODULE_DESCRIPTION("Led platform driver");
) `# k# ~' b' L+ ~$ oMODULE_AUTHOR("Tronlong");  C) S0 J5 p$ g2 O
MODULE_LICENSE("GPL");% \5 ^, |0 s/ X- `
8 B5 k1 ]  [! I' }! e1 l
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则


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

GMT+8, 2026-1-12 11:33 , Processed in 0.053964 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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