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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
3 Y  E- w0 Y, w! m7 _0 E) l#include <linux/init.h>9 j) d, P! ?9 E' w6 @2 O; b0 D
#include <linux/module.h>
) f8 M6 \% q1 F/ T5 @0 f#include <linux/kernel.h>4 ^0 v& T; z* D+ C8 ^. S. b/ @- h
#include <linux/types.h>
( l4 j! R6 \' Q+ j9 G3 K* Q& z0 p#include <linux/gpio.h>7 F/ L$ ?. \) ?) r% D
#include <linux/leds.h>
/ Y" l: G2 b5 P8 H( w9 ]; f0 R#include <linux/platform_device.h>
8 m5 z, b# r4 I% ]7 f. E3 _9 e% _
/ g5 H% s, I! x) [7 l: p#include <asm/mach-types.h>
9 W9 k, |, x: G3 A, f0 T#include <asm/mach/arch.h>. y& b! |9 V4 P% `$ O  r( ]7 m
#include <mach/da8xx.h>% _2 P4 @+ `) d4 H; b
#include <mach/mux.h>
5 X" |1 {" n" m  a6 r$ [
/ Z) p1 _. Q; F" I  z/ i7 Z( x#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 k9 |3 }! }8 u8 {9 O2 F4 w- f
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
1 a  d! C. ~' ]- r. ]3 l9 [: X#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)5 H9 N/ f8 V4 C) Z; x
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 i. Y' W1 n; ~% u& {: m( w% W

4 |' E8 ~' m! P/* assign the tl som board LED-GPIOs*/
' c- I! E7 `% ]* d7 Y  astatic const short da850_evm_tl_user_led_pins[] = {% e3 ~- C1 G* c
        /* These pins are definition at <mach/mux.h> file */3 \, a) H3 l$ I/ i5 {9 K  f- O, f
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! B0 Y0 T  N# M; z$ ?; A
        -1% |0 A% E5 T% Q8 C5 W- _
};
- v$ b, C+ U( a* S, `$ |5 R! w5 n& W, y
static struct gpio_led da850_evm_tl_leds[] = {% ^" f; v! X4 P$ z
        {
! s1 @0 ?! m' j) h1 }1 M                .active_low = 0,' r. I8 @' N1 k( Q0 Q
                .gpio = DA850_USER_LED0,% E  W: v" V7 B/ h$ ~, g: b% ~
                .name = "user_led0",
% p& K4 q( t0 z  A                .default_trigger = "default-on",
& E% K0 L, s9 v3 ]- u6 f, Y$ |        },
  }# r0 P# [/ S. h' r        {
- [5 o' C1 q* H! k                .active_low = 0,
( {* m$ C! G9 v8 }& Q                .gpio = DA850_USER_LED1,
. L0 j  e2 z! v& C6 I. d                .name = "user_led1",
, \2 o6 v& V" B( j7 j! M                .default_trigger = "default-on",
4 R3 Z7 L9 a: S! f, g# W        },2 G; s" Z' U4 C2 ]& ?
        {" F; t! p% h# k! G9 w* O3 U
                .active_low = 0,' y( A5 E% R: P
                .gpio = DA850_USER_LED2,
; t4 p; U9 v& p: A* Y8 G                .name = "user_led2",3 f; `! n9 T+ X/ \- m* Q) u7 x3 f
                .default_trigger = "default-on",
5 U9 I) F' ?' F* c. c        },5 I/ G- ]8 _  T- `4 Y
        {7 q5 C, l3 Z9 \
                .active_low = 0,. z  Y* v5 L% Z) N
                .gpio = DA850_USER_LED3,
1 z6 z4 Q' P% j+ h+ q                .name = "user_led3",
) L- f9 W* s* b/ a7 U+ |                .default_trigger = "default-on",
: T4 b% I  W' f6 x( u        },4 ^" j% {4 _: _  J" v4 F
};
  V5 Q8 z% u3 J: O9 q7 p4 F0 Z& V' x) I) d1 A6 @( l6 d. y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 S- R2 [' _" ~3 U% [        .leds = da850_evm_tl_leds,
! A: }0 Q/ e3 e7 W  ~        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 s% J4 L' G6 O
};
, b; `1 a. B7 R. ~% |5 D6 n# G3 j# Y. G& ?! V/ D' f* q7 _
static void led_dev_release(struct device *dev)
7 _+ v. o* I+ d, G{- l6 j# u+ r( _1 [
};- W0 Q; |" i* R- ^; q( j: q
* ?- Q4 c  Q( t' L  }
static struct platform_device da850_evm_tl_leds_device = {5 o/ K/ w- l. w
        .name                = "leds-gpio",3 ~5 {) U: r1 `) F3 Z% Z0 S
        .id                = 1,
1 L: W. K% @7 z3 t$ g% j' U0 T! q- |9 z        .dev = {
' y' z6 G/ v  J. ~) V                .platform_data = &da850_evm_tl_leds_pdata,
" T* E- {6 s) Z                .release = led_dev_release,& T4 o3 P4 J0 v# b5 y
        }6 p6 ^+ f) I4 a& x( q5 h. M+ ^: o
};
# p1 z0 c4 E; N% C
; b; }& [" t' ]' s9 E* _static int __init led_platform_init(void)
0 R4 u1 ?' t4 l! U  G7 _{
  E  t- \4 O9 D, Y  r        int ret;
6 ]- X+ K4 n) {9 F#if 09 j$ u7 K; C+ B: [5 H/ r5 r7 @
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 ^5 ~2 X, e0 Z% z1 }( E" G( U% L        if (ret)
6 T/ g5 J* E' J# d  s                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 v2 ~- I$ G+ S/ y5 o                                "%d\n", ret);
3 W$ S3 a4 D8 d#endif% ?9 a. E  s6 K( L
        ret = platform_device_register(&da850_evm_tl_leds_device);4 N) z! K6 o3 A3 t
        if (ret)
( m6 @" V0 S8 G9 b& s9 g                pr_warning("Could not register som GPIO expander LEDS");4 P! O" R5 h& u7 U1 V8 y! U: ]
        else
! q$ }4 }* X1 x# |                printk(KERN_INFO "LED register sucessful!\n");
9 F' B3 [3 G, A, u6 E) G, _
/ ]6 z7 p# E$ B0 j. A" S3 ]        return ret;4 X4 j- ]# v. Z# ^1 U! f& z6 j
}
- G; W2 p3 W! G& [$ c2 `. `: l
. {4 p$ l3 U; |  A* Q' |static void __exit led_platform_exit(void)
" `/ g, _" W9 e5 x5 F; ]{
5 G. u0 g# l  n+ ]        platform_device_unregister(&da850_evm_tl_leds_device);+ o) S  g0 V3 b4 ]

7 m+ t: Y/ _* i8 D9 r1 Q7 A6 N        printk(KERN_INFO "LED unregister!\n");
! F# B# h% r% }* `7 ~8 F}0 l) Q- O% W; e9 I+ a

$ G# Y' d& p+ i5 Z" N  t9 f; f( jmodule_init(led_platform_init);
! T8 g- a; T7 h2 k7 `module_exit(led_platform_exit);+ E) |  Q' A# q# ?) f

; e: l- q" X! f! U, KMODULE_DESCRIPTION("Led platform driver");+ q: r: F- r. F& [! b) D- Z# f
MODULE_AUTHOR("Tronlong");4 `; V0 u; @! P' H$ _( t% L" H% q
MODULE_LICENSE("GPL");
* g) S; P5 e8 R: A7 P2 N3 b: j6 W/ y9 {; o, F  W, ~$ [* k
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-11-23 09:35 , Processed in 0.037895 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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