嵌入式开发者社区

标题: 程序注解 [打印本页]

作者: rgf    时间: 2018-1-19 19:02
标题: 程序注解
求大神给下面的程序做注解,请稍详细些,谢谢。# p+ Z1 I5 W+ D% y* e2 o% \- c' }- y
#include <linux/init.h>
7 M+ u8 I5 o8 {3 z7 S2 @, x#include <linux/module.h>& d  u, k. @7 s) U
#include <linux/kernel.h>
+ [8 b* G+ k3 p6 K* g#include <linux/types.h>
2 f; |4 b) f' T2 D#include <linux/gpio.h>
& W- I. e4 r/ N: b9 u#include <linux/leds.h>
' ~/ E9 A; F8 i# Z#include <linux/platform_device.h>  X& t9 H; z% V+ i3 [
" Z+ K+ m1 U! Y& N0 b6 p0 k' R1 I
#include <asm/mach-types.h>
' `$ h. R. \8 t+ \: H3 x8 l! q#include <asm/mach/arch.h># K" ~( \# K, P
#include <mach/da8xx.h>/ h3 t5 R& t. q& D5 K
#include <mach/mux.h>
; }7 e6 u/ y) @6 \! \
# K6 j2 l2 Z% m. {#define DA850_USER_LED0        GPIO_TO_PIN(0, 0), A3 U( q4 ~) m- D
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)/ J1 I$ W& J$ V! c- P
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
% s% I2 L/ K9 F#define DA850_USER_LED3        GPIO_TO_PIN(0, 2); s2 N$ D9 {2 L$ E8 V& B
, M9 r( a. i. s
/* assign the tl som board LED-GPIOs*/2 Z% ~7 D5 i! y, k; M+ ~
static const short da850_evm_tl_user_led_pins[] = {
3 H, w/ H  \% t8 [0 K        /* These pins are definition at <mach/mux.h> file */# _( i- ^2 \. _) v! B! ~8 d
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 ]& x& J# }: B  F; Q% E        -1, G/ w. Y& \% }# c9 P  s4 u
};/ Q0 Q( F  x5 S! }" t; B
8 c5 n# W% i0 J4 {: [
static struct gpio_led da850_evm_tl_leds[] = {/ h# O1 y* e% a# i0 r: U
        {) o) O# l1 b, J' H: l; p0 {
                .active_low = 0,
3 l1 X; E/ R* ^+ ?7 W6 O                .gpio = DA850_USER_LED0,
9 ^- d/ A2 _% L2 E% _8 h8 u, |                .name = "user_led0",
9 M' m, `) }! o                .default_trigger = "default-on",$ v; [0 z8 O& X+ W. `
        },  j: L$ e' `, D/ k+ Q, A8 K
        {2 t# |0 J9 @. i" x2 Y
                .active_low = 0,
; C+ d0 @; k0 |7 c9 b& I1 d                .gpio = DA850_USER_LED1,
0 B, G  h9 l  e                .name = "user_led1",
8 o% ~7 v6 }; M                .default_trigger = "default-on",; r; Z' `5 Q) U9 b7 |& [) B) N$ Y6 e; {
        },
( S2 @* [# {/ I, ?6 O' {" Z3 R* m) L        {
0 x6 y$ B. B" w1 g, A( v9 K  i+ ]4 `                .active_low = 0,
2 J5 R# ^1 H* S9 T                .gpio = DA850_USER_LED2,: T, A9 }7 o: I  r$ V
                .name = "user_led2"," B+ L: T+ X/ `- _7 e" \
                .default_trigger = "default-on",/ X, Y* \8 O# L
        },. W$ E$ ~; ^8 X* G) T7 A, }
        {
, ^2 e: U$ V6 U1 G9 e* W3 T4 B1 j                .active_low = 0,
' E/ p# E- E4 \6 e4 |* b3 m                .gpio = DA850_USER_LED3,
7 a2 Z5 G. g' r  L                .name = "user_led3",4 f! x, l" D/ L! I
                .default_trigger = "default-on",/ v  _  A3 M2 @' {% Y
        },1 B- t% u8 B1 g& u1 n7 `
};" d" v  A$ u, D' a
7 {  E5 d  a8 P) L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, F& _4 E7 B# |( p        .leds = da850_evm_tl_leds,8 _4 J, t$ `/ N/ E
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- ^9 p5 S0 p( c5 Q+ ~" O};  Q! w* Q( e' ?$ s. v1 J

, @  ]4 ?5 S; C$ E/ Mstatic void led_dev_release(struct device *dev)
3 E- a( F' `. M$ @{
) x/ e7 A; u* ?& S};
9 ]( \$ N: `0 b! J$ _5 y3 e
% C6 h' r9 U3 b9 N/ \6 Fstatic struct platform_device da850_evm_tl_leds_device = {4 @" `( ^! q+ W% F. t
        .name                = "leds-gpio",& P/ }; A9 G' n7 X8 x
        .id                = 1,1 `7 J0 W" H! u7 F  ?) [; D' B
        .dev = {
  v4 b( ~0 I1 V$ w" G1 V0 m7 P( G8 I                .platform_data = &da850_evm_tl_leds_pdata,
& [3 p8 I) t. w                .release = led_dev_release," ^) s& b9 I. J: [* f
        }
% b2 I" X# p, o3 g};1 g, ]: n! r% j+ L" i

0 P" o1 I8 p) y+ p& estatic int __init led_platform_init(void)
1 w: B( C4 J0 d% l{+ ]) {$ @0 W# r2 B8 p( C
        int ret;
& B5 ~2 Q6 Q9 M; l7 v#if 0
9 a2 I2 x; {! |0 r) c        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" S" n+ ~9 k7 O. ?) {
        if (ret)
( \2 t8 k0 x6 r6 ^3 c# i                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 a8 V) ]# D7 {8 n                                "%d\n", ret);
" I" r/ s3 R' J#endif
' k- Y( Z( C" Q* N2 z0 h        ret = platform_device_register(&da850_evm_tl_leds_device);
; X. X6 ~. e7 t5 E8 `        if (ret)0 r9 p( e0 ]% W7 f4 ?. W0 @
                pr_warning("Could not register som GPIO expander LEDS");0 @1 o# J5 L1 c! w. [& p$ @
        else
; a1 n- h7 {, p" Q$ ?7 x7 N) F                printk(KERN_INFO "LED register sucessful!\n");
! s+ y% K7 w: D$ M) i" D2 n$ k8 y8 f/ F: W- ~& c8 b2 v
        return ret;
2 Q0 K/ w, [  h}7 E2 p0 i" i# _* m  R- @, Z0 p( d
" v& D! f  S: O( T" ~
static void __exit led_platform_exit(void)9 ^% o4 D5 y; Y+ C' ~
{$ Z) [3 F3 |5 m5 P; o& A5 r
        platform_device_unregister(&da850_evm_tl_leds_device);2 M/ ?  ]( s* H: }& v

* L' P) }( l; ?9 Y( v6 E: w) r: D        printk(KERN_INFO "LED unregister!\n");
0 r8 I& D8 m3 i/ v  P}/ |) b' w( I6 F: J
. v7 r, m6 {0 a6 v1 l6 G6 O' f
module_init(led_platform_init);8 o; ?, d1 Y' a5 A+ e# ^
module_exit(led_platform_exit);6 I, O, q* L) }" e
7 u# V  F# ^- h2 {" q( ]( a
MODULE_DESCRIPTION("Led platform driver");# D& ?- h6 ^% {, f. d& d' m
MODULE_AUTHOR("Tronlong");
, x, u% a  I2 b9 y) y8 XMODULE_LICENSE("GPL");5 ^  q: D: D) K, Z) B

* s. Y5 m' D' d! j




欢迎光临 嵌入式开发者社区 (https://www.51ele.net/) Powered by Discuz! X3.4