嵌入式开发者社区
标题:
程序注解
[打印本页]
作者:
rgf
时间:
2018-1-19 19:02
标题:
程序注解
求大神给下面的程序做注解,请稍详细些,谢谢。
4 T' D- J n+ L
#include <linux/init.h>
: e( s; ^/ g. N: C, t
#include <linux/module.h>
. X* `8 |/ R! d7 ^. Z/ l
#include <linux/kernel.h>
& m% U7 l2 V: T( w
#include <linux/types.h>
! K# z. J+ Z, {8 z: G
#include <linux/gpio.h>
* c+ ~' R- O4 a* _4 K4 q
#include <linux/leds.h>
8 l$ `; |, o# _
#include <linux/platform_device.h>
; _1 f- T* j! @# }% p7 A! @
, f: n6 `$ Q/ h4 F6 W+ w
#include <asm/mach-types.h>
6 F% ?8 z: v" X' M' e: B) @" B6 V: p
#include <asm/mach/arch.h>
8 _; K! W% }( _2 f
#include <mach/da8xx.h>
% P( ^/ ]3 l* J, S$ d3 ?& g
#include <mach/mux.h>
. m% A) y! Y' ]- V1 e8 ?
# K7 n/ o' H- c4 U$ X* @; `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* |$ I( N' m/ B1 m( b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 j6 K/ y$ A! F+ o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 O8 g" {: S+ V+ O5 y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! ~: ^4 f% U% x5 F, ?4 w
' C; a5 c G2 ~$ t! ^+ ?+ }$ ?
/* assign the tl som board LED-GPIOs*/
, i; ]* A8 a# U5 r2 I, @
static const short da850_evm_tl_user_led_pins[] = {
4 ^3 R- s* o/ L. i
/* These pins are definition at <mach/mux.h> file */
" e, |( Z/ l u' V# F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- a& x5 C ~ X+ `9 |
-1
5 F ~. }+ A' x4 W* r
};
! y& \* I& e; O0 n
6 U W6 n* Y% L% y; t; p
static struct gpio_led da850_evm_tl_leds[] = {
9 |' R$ O7 p& C5 Z- q7 C; }& }
{
% R! H6 ~ @9 L* N( J) o
.active_low = 0,
& ~) V, K3 l4 S; C. L# v
.gpio = DA850_USER_LED0,
?, l- N# V9 {' {- B* @- b0 ]
.name = "user_led0",
# v# F$ F" K6 Y E+ W. Q+ i6 o
.default_trigger = "default-on",
$ `, ?* W2 o+ ]6 F) `* G% f
},
, Z d4 w% E4 M0 n) O5 @
{
- [; |8 o7 ~0 T9 w9 p4 x% m
.active_low = 0,
$ _2 Q' J6 \0 G4 t7 _' G+ `
.gpio = DA850_USER_LED1,
5 p) c; S7 q: v% Z) Y% d; {
.name = "user_led1",
$ N& _. {/ B, X" f# y
.default_trigger = "default-on",
1 ^" L; f' f; {
},
: o1 P Z2 u7 z+ A9 D" {
{
y+ |8 ?) K. ?1 ?+ e& N9 J
.active_low = 0,
. e, j0 D& d2 }/ D/ E9 C4 }& g
.gpio = DA850_USER_LED2,
" c' ~$ r0 ~, B! h) @6 ~1 b
.name = "user_led2",
, F3 K5 }9 t/ G4 n. q' Z8 ^$ e
.default_trigger = "default-on",
& [9 R; W% Y2 v5 l @
},
$ q( U7 x( u/ ~% \0 d7 X9 u
{
( q3 P: E/ u0 B0 c$ ?! [: i- Y
.active_low = 0,
! @6 U& k1 X4 y0 _/ A
.gpio = DA850_USER_LED3,
, K4 l5 Z+ S/ A
.name = "user_led3",
3 @- f) Q. G/ v+ I1 W
.default_trigger = "default-on",
+ M9 B3 Y. z$ _! z* j, I
},
2 l7 |$ V% f" w& n% i0 E9 S
};
" ~* x& ~3 {$ o0 L
( O+ O) g7 B) K. R* p: r( J& |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% T0 y, g. W( k. D m4 v8 J
.leds = da850_evm_tl_leds,
i) n8 n- A, G/ U; Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 i, S1 ?# n, ^) R* f9 o
};
- i; s; m' [ v! C P
! m! n' m2 y& P. n8 m
static void led_dev_release(struct device *dev)
( ]5 q) j6 {( \# [ y8 }/ q& y
{
( I5 I: V6 K/ C( Z7 R; F9 @
};
. A; s- m O; _. N6 S( I
" W9 `; P" o e7 r
static struct platform_device da850_evm_tl_leds_device = {
8 X- W& m; {( B/ ]
.name = "leds-gpio",
! u# p8 s! N+ E2 N
.id = 1,
5 b& U# X, l+ c5 C" }1 L. q; b
.dev = {
9 r2 j4 o; G0 ^; t6 }2 V6 F) w
.platform_data = &da850_evm_tl_leds_pdata,
& Y# F+ w9 |* a% M G: n
.release = led_dev_release,
1 W% a( d& G0 @1 H
}
: D3 z. @: a# U+ r
};
7 P2 S( l1 C2 W& a
& f' K# d$ v3 e6 m; j. h5 d% R2 p# v1 Z
static int __init led_platform_init(void)
! g& B# E2 l0 S% p) \ p
{
* `* x4 u& P& Z
int ret;
! S- q5 J. g" ]( P& O; T* H
#if 0
g9 `( L/ C/ f! a( W7 h' b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) v2 S, h* g C+ d" ?0 Q
if (ret)
* P% z! P* F5 g5 X, S$ F. E. D( P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* y/ M4 T& z! ~3 J
"%d\n", ret);
) n! l% w) `7 b7 M" C2 w, q
#endif
( s( M% ~7 |1 ?9 A3 ~# L
ret = platform_device_register(&da850_evm_tl_leds_device);
- p+ h4 L! e+ F) l3 D( ^5 w8 m2 g
if (ret)
# x2 z: F; Q. m1 T, a7 R
pr_warning("Could not register som GPIO expander LEDS");
3 T' x1 f- y w+ G2 [0 d
else
9 x( C) C8 c4 |2 t& u$ A
printk(KERN_INFO "LED register sucessful!\n");
. ?3 q& |2 x' i
: _4 E; [1 h. S8 D9 |! G
return ret;
/ F# J9 Y# B8 W/ u, ^$ F5 p
}
+ p6 r& K. }, t$ R* t; ]; _
6 ~3 l Q9 q6 E4 ~. w0 z+ y l& M- p
static void __exit led_platform_exit(void)
# H* o* g$ M4 S/ w7 \
{
; W8 l0 f6 p, R8 S, u
platform_device_unregister(&da850_evm_tl_leds_device);
9 P% P) u" J. Y3 b
5 b" w2 y& M1 p7 v* X& x$ C" |
printk(KERN_INFO "LED unregister!\n");
; `% \% t$ \" k
}
: q. a4 P) I9 M9 {' d* w
- C: y6 a7 D4 l$ g
module_init(led_platform_init);
) D: J2 x2 v0 O- }: i& ~) T
module_exit(led_platform_exit);
* x/ X9 o% C1 q9 s
2 \4 u" {+ Q$ d4 J
MODULE_DESCRIPTION("Led platform driver");
- b8 e. J" @& q! a
MODULE_AUTHOR("Tronlong");
5 X! a% ^. H! u7 I( F* z' w
MODULE_LICENSE("GPL");
4 F* r. H# p: z6 r
) [& ~( I7 J% o+ T
欢迎光临 嵌入式开发者社区 (https://www.51ele.net/)
Powered by Discuz! X3.4