程序注解 - OMAP-L138 - 嵌入式开发者社区 - 51ele.net
设为首页收藏本站
点击跳转“创龙科技服务通”

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
4 c1 b9 b1 e9 B' x#include <linux/init.h>
/ t% h' Z; L* W7 p#include <linux/module.h>
3 I# B' ^. d$ e* N. r$ k9 h' u/ `& x#include <linux/kernel.h>
6 L! |+ o' G* U#include <linux/types.h>& }$ p+ b! v) N7 Y, s. \# C, T
#include <linux/gpio.h>
8 T( J% d9 c- w: n#include <linux/leds.h>
3 p# n! t, D  U( Q. s#include <linux/platform_device.h>
) {8 T/ g( R- U' h5 m0 _7 P4 w9 t! E9 {: c$ b
#include <asm/mach-types.h>& {5 {" @; B- k0 }  m
#include <asm/mach/arch.h>
  _9 t$ g! ]3 ~5 L  P" J#include <mach/da8xx.h>
- X( l8 r+ w( E+ i( C#include <mach/mux.h>" D, }8 ^2 s1 \# r3 K, L4 O7 `

( ]! `4 t3 \3 q' V- p: y" a#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
5 Y* _' U2 H) F  B% v: i- \#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)" g0 F/ ^1 g4 z& W5 k$ A
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)8 K% }4 _6 h2 E$ H
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)7 n2 B4 L  {) d& I6 ^$ i! u1 y

" [* b( O: |$ V8 g0 Z" E& H' ?( q* [5 t% |/* assign the tl som board LED-GPIOs*/
: w* W# B! V8 }' y$ g% qstatic const short da850_evm_tl_user_led_pins[] = {1 |* \* J* T. i, r; i; W% h3 _
        /* These pins are definition at <mach/mux.h> file */, ~7 J# O4 @3 J5 b) @0 W* [1 J# d. `
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* z' R: t) X: z( V  V6 e        -1
8 w7 @0 y: s0 ^& ~/ F};
! d! }$ J' ?: |' z. t& ]! y7 y& H& a; F% @
static struct gpio_led da850_evm_tl_leds[] = {
2 z& L1 }: C5 @3 u5 D; T        {
+ T1 }/ x+ ]8 V                .active_low = 0,; F$ ~, \) O) s# s, b
                .gpio = DA850_USER_LED0,
& a1 K4 U; T: O: D                .name = "user_led0",
0 [( w" Q4 I' L# m5 G0 U                .default_trigger = "default-on",7 Y( x3 a- e8 K& `: b, s6 W
        },
# j! `) C% C+ g7 A        {8 R8 K  i) m( a# X' S. s* U) l8 P1 ^
                .active_low = 0,
1 }6 b! j+ f$ ?" Q                .gpio = DA850_USER_LED1,- s4 D: B% N* f" ~
                .name = "user_led1",, [) O# g, a0 C. _+ H& I2 ]& s
                .default_trigger = "default-on",
; Z$ [% @% E7 S        },* g, y  _- z6 n+ w1 {( ~- u
        {. W' d0 |8 [5 U7 q! W* a" V
                .active_low = 0,  E' d! s7 ^( ^$ y. S) r
                .gpio = DA850_USER_LED2,
+ b  H$ g0 m& n2 n                .name = "user_led2",5 |/ ^4 L, }1 o, p; v" h
                .default_trigger = "default-on",9 @5 r8 _8 Q2 G8 z  T: A: `  \
        },
8 B2 \9 ^( N& J4 f        {
. w8 s" k! ?  D1 x                .active_low = 0,
* b% P1 }9 s5 T3 k+ ^                .gpio = DA850_USER_LED3,- y7 T  ]. A! Z. V
                .name = "user_led3",
! B& h2 d; H) _4 ~( U                .default_trigger = "default-on",+ H" j7 ]  G( L; e/ q3 j. Z
        },
+ T7 B) T; s1 y7 `1 f};' g  D, I1 N' F' s
5 @+ W9 M4 o- Q9 l+ @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 ^* L- d0 E" Q# ~8 j: ^        .leds = da850_evm_tl_leds,( [. W1 G) E2 U  J5 {- u8 d
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! N8 c( ^9 F, y) }. ~9 n
};2 S; N" |+ ^- g5 }3 Q5 K9 W" Y

) \0 d' Q7 u6 Z5 ustatic void led_dev_release(struct device *dev)
: B: t( X: \' @; e- J{
9 x& {- Y- {0 V6 k" ^# N& M+ C};
: P' |/ y4 O4 m( D$ f! A& Z- V
* C/ f& z& k9 [+ K+ E$ _. t& zstatic struct platform_device da850_evm_tl_leds_device = {- |" ^8 J# n; ]2 P
        .name                = "leds-gpio",4 ~9 R0 s) U5 W7 s  w& v& x
        .id                = 1,& Z2 j! A; V" f' C6 \7 q
        .dev = {: m$ d% O- H* l# {, q9 `* Q
                .platform_data = &da850_evm_tl_leds_pdata,
* g* Q7 n2 l! K0 Y% S3 `; H                .release = led_dev_release,! K8 Z6 g  }) z6 k
        }3 v  P; o( D1 n+ n; q
};
6 _3 E6 ~+ A2 y5 u, e) u3 N: T6 t1 s1 x% D: U$ N
static int __init led_platform_init(void)! W8 l8 v! V- y
{
9 T( Y" E6 r4 l) B" F        int ret;5 {: D- F2 F6 |# c
#if 0
" [+ d% a2 w3 l        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 D2 d+ D4 ?: ]* t  P5 I  S        if (ret)9 O: O  m. i& [2 H
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
  @2 t1 R1 m  p! t                                "%d\n", ret);' A# [" Q- ~. s/ b5 `
#endif9 n, D! c  f0 C) O0 Y& h; G
        ret = platform_device_register(&da850_evm_tl_leds_device);
; }2 @. K# O/ M* `        if (ret)
/ m* t( R  P8 ~* v' f0 D  I9 }9 j                pr_warning("Could not register som GPIO expander LEDS");
. B8 s- |% ^- F        else/ s! O$ M( p2 h& P' L7 D5 u4 v
                printk(KERN_INFO "LED register sucessful!\n");
) w" t; _( A9 [" `3 U1 O& A4 X, N9 F3 V5 @
        return ret;5 L; y9 [: \4 U: J/ u' {
}5 C+ P! J. p$ ~- b( m
+ h: |8 ^* t: A7 s% U" p
static void __exit led_platform_exit(void)
* t# i5 Z  V  X- o2 j+ K{! o! J* I, P5 W4 w: K& q0 r
        platform_device_unregister(&da850_evm_tl_leds_device);! M  U# {3 f' S9 H5 l# }3 e( Q0 p

; @5 `- p6 g5 A" _, E2 J        printk(KERN_INFO "LED unregister!\n");2 G, a. }& r/ F& e% q4 Z/ m; }
}% Q9 a; a3 C% f8 N

0 x" f* o: ]) D- a  Umodule_init(led_platform_init);5 E  h0 S# d( f, u) c
module_exit(led_platform_exit);
2 X' K5 T; ]) U  ]* b, \7 O3 k/ d6 i5 x- L. K; r1 d
MODULE_DESCRIPTION("Led platform driver");
- N/ Y* a* U6 Q, x6 [( uMODULE_AUTHOR("Tronlong");4 J# i: M$ C9 l
MODULE_LICENSE("GPL");
0 D$ g; a8 T  L& j& n
, p. F8 |6 x0 J6 c+ e% o
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

点击跳转“创龙科技服务通”

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

GMT+8, 2026-1-18 06:42 , Processed in 0.039453 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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