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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
  {; X8 ^& j5 C#include <linux/init.h>5 a) ]6 Q7 U1 ]! f: S" p# L6 }* o, T
#include <linux/module.h>
7 E8 ^; h4 I& i" T+ e- ^#include <linux/kernel.h>/ k+ z" Q* P) G% G7 M, x  N
#include <linux/types.h>
& L5 i0 q. q: U- P8 n( A& g6 @* X#include <linux/gpio.h>0 i6 ^5 l9 z* s, J+ k. @) K' T
#include <linux/leds.h>
/ I3 v( U3 Q! u0 L) P#include <linux/platform_device.h>
( j$ N5 n3 e8 F5 i) m' }6 O2 [* @8 q7 R
#include <asm/mach-types.h>
# I9 j' ^9 T; Z1 `#include <asm/mach/arch.h>; d0 E: r& p8 R* H& N0 G
#include <mach/da8xx.h>7 W  W" x$ y& L+ T
#include <mach/mux.h>6 C' s: ?, B2 l" D7 J
1 K+ U' f: L. z+ g
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0): j8 T5 n! O) g  Y
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
& b  B$ B& F* m6 t  d( M8 I' C#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
7 u  Z) ?, T" @# v2 P2 `- h# S# F6 W#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
) w0 d8 l, ]$ ]. O: Q2 q
: s* W+ G" [& R8 Y/* assign the tl som board LED-GPIOs*/
6 b. a! f0 p- w8 F9 t! `; lstatic const short da850_evm_tl_user_led_pins[] = {
7 T, Z$ I0 a9 {4 h. h  x; v        /* These pins are definition at <mach/mux.h> file */
5 m7 a% S( C  }6 y7 d5 @        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- P) _1 a. F) |7 h  v* u* s
        -1& K* z4 x' Y, A! d) R
};
( D/ A) t! I- E7 ]  z  ^, T0 I1 K9 y3 M) j1 `5 H( L
static struct gpio_led da850_evm_tl_leds[] = {
  w8 t6 B5 r8 S! x+ t) m) l        {' w1 N8 Y3 X0 I$ S
                .active_low = 0,. u) j# t7 }) V( t6 p; B) D/ ]3 }
                .gpio = DA850_USER_LED0,
/ f) {) X& G$ g% i7 X' E                .name = "user_led0",3 x& m' P) f" t. g; `! Z# i  m
                .default_trigger = "default-on",
( x( O2 s- k# V        },
$ C' D- ]$ k; X! k4 H3 o        {5 e) y5 Q. P+ _6 g$ B, Y
                .active_low = 0,: U; k2 ~5 b  Y# I$ Y; l2 X) M6 P3 m
                .gpio = DA850_USER_LED1,
8 v$ U& j1 o3 J: i+ s  \                .name = "user_led1",
) n$ ]4 a5 e* ?' k- ?% K- e                .default_trigger = "default-on",4 h4 x; t' d0 ]  Z2 Y
        },
. c( L& }- o. G( O        {0 }( V. \/ R0 J6 [) Q/ r8 L  Y
                .active_low = 0,9 r4 y4 C* X2 I1 L  k+ z2 Q
                .gpio = DA850_USER_LED2,
. R/ X: T" Z  M5 Q: V3 u                .name = "user_led2",
1 Q* c, d5 E! D: B4 V" g6 E                .default_trigger = "default-on",
$ P6 ^: ^/ G7 f2 o        },
7 E. a7 I2 ?2 O- }. k+ a* Y% b        {
: s" e. ^' V% I& V! u                .active_low = 0,( b8 U' c$ m  {, V
                .gpio = DA850_USER_LED3," O3 y3 T7 a5 o. Z/ O9 W
                .name = "user_led3",9 T; P7 Z) X8 S! x/ H% \3 }
                .default_trigger = "default-on",
8 {% y/ _9 o' j$ v* u. S# N/ x: Q5 @        },7 ^) b2 z% w- f0 x0 O0 {' u; P  T
};
" v& j# ]$ K  y. M/ z  j7 |4 n! O, ^( r" [: w- |3 a9 d# [. W9 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 W6 u: t; |% g. G" s
        .leds = da850_evm_tl_leds,
5 k' @, r  q# [! [2 q        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- X6 I6 |4 @% d# N
};
% e1 m' ?3 n6 |1 V. N( _
4 p$ |1 p0 c; a" Ostatic void led_dev_release(struct device *dev)5 A$ y; t7 A9 o
{
" ^1 B- M0 g7 c8 X5 s# T$ |; M};
! R3 `" B3 ?" ]' C- r1 l( x/ `
2 L' L& Z& c. n8 D# O( s" n/ Ystatic struct platform_device da850_evm_tl_leds_device = {
* V' m- n( b! r, t        .name                = "leds-gpio",
9 w! I* V) R5 Q1 ^# w        .id                = 1,
. W  K! B) ]2 @# {/ [. L$ s. Q        .dev = {" G9 w9 T* E7 h+ W: {5 m9 r
                .platform_data = &da850_evm_tl_leds_pdata,
0 K& E; l8 V. ?6 E+ [2 X5 r  y                .release = led_dev_release,' |. Q# |! t  C( L7 |: r/ G
        }( y, M" l/ m0 D6 ?4 I7 M
};
7 u  `7 \3 K3 ]' ]8 b! B
5 g) @0 b% x7 K# h; o" i! |( tstatic int __init led_platform_init(void)
/ M2 W/ E7 b: j  z{
6 G) ], Y$ P5 i2 c1 Y        int ret;3 m& F: G7 F1 @$ ]& d/ ^+ N
#if 0
* F& j& I/ I0 _$ J5 R5 d        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 b' X& M7 |  |% z7 ~
        if (ret)$ c1 h0 T  {( v7 ?* d" V
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 e% Y' ~; ]8 x* t  n3 s; W
                                "%d\n", ret);
" }5 K$ o- Y9 Z3 N, |( E#endif) g4 }+ K2 x' i
        ret = platform_device_register(&da850_evm_tl_leds_device);7 X( e" e$ i$ }' [# S6 y4 ?: g
        if (ret), y! p3 [/ h) i, x: A9 Y
                pr_warning("Could not register som GPIO expander LEDS");3 R0 n: |# z6 E. i% x0 K
        else
# X/ @+ k  w4 |; b                printk(KERN_INFO "LED register sucessful!\n");# d3 i8 C8 J2 K/ I' Z
" t+ }  X1 V+ ?+ n+ S) N/ |
        return ret;: j. \  N3 P+ S; h, Q" l
}
# i0 J$ F! u1 A; J/ B
- G$ W% r$ M7 U% g$ Fstatic void __exit led_platform_exit(void)
% |6 Z$ ~) u5 |# [8 B{
" N' v# r7 D/ o' u- o        platform_device_unregister(&da850_evm_tl_leds_device);3 U8 g( I9 _" M) `# \4 g9 y
+ V) }) [/ q$ `" F5 c, i! U
        printk(KERN_INFO "LED unregister!\n");
! u3 Y& h& C6 h( G: y5 m}" ~% d* E; f& J2 M
/ c0 ]# \1 _$ J# T+ d, B8 y/ m
module_init(led_platform_init);+ W) V/ D6 j8 @$ n0 c* j; a
module_exit(led_platform_exit);
* n0 K5 Q9 s8 r4 [5 o. V
9 }* j$ M& H- X* A2 ?/ U. z* r: OMODULE_DESCRIPTION("Led platform driver");( N  G) V, W# w* h
MODULE_AUTHOR("Tronlong");
9 U* S# \; A, Z* O( U0 C7 @MODULE_LICENSE("GPL");! k3 G; O) T9 A: X& l- E* l
6 @3 u+ I# o& i$ W2 M* I
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2026-4-1 06:13 , Processed in 0.040338 second(s), 26 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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