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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
2 U: v6 s% E4 n8 r; y+ c6 _#include <linux/init.h>! @) L: a: H+ M, }$ _0 p$ c
#include <linux/module.h>
- |4 r% o& n! f0 {1 A#include <linux/kernel.h>
- G; ]0 [4 ?  p#include <linux/types.h>
  W$ D# {* L, D9 e7 H#include <linux/gpio.h># G! T8 A$ T  O9 D- X$ \
#include <linux/leds.h>" X; ?7 G* K6 n
#include <linux/platform_device.h>
6 U9 H* B4 e) S  s% S4 T
  C: p9 T& S: ^; d, H#include <asm/mach-types.h>% N0 K1 f5 V/ c  a
#include <asm/mach/arch.h>
( v+ l% G! S# @; L$ p5 T#include <mach/da8xx.h>+ M! o1 C1 U% N& W  \
#include <mach/mux.h>) j" K# D* A8 y
9 `" S3 P! D% N  {0 X# P) b; w1 W
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
) a1 t. b% w. A#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
$ O, a2 u7 K0 o: L. A3 n+ M3 s; q#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)3 b4 N  Q1 P* _: Z2 E* r6 G. y
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)4 s9 t6 G% D/ j. H, ?; r. ~' U! O
& c* i) \( Y3 z/ {7 F! S8 p0 z( W
/* assign the tl som board LED-GPIOs*/  b. g3 o( O- ^; S
static const short da850_evm_tl_user_led_pins[] = {
5 D% X; x+ h4 {) |        /* These pins are definition at <mach/mux.h> file */5 [& b. p- x& I- ?$ h3 L
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) K6 t+ i1 z* P7 L" c
        -1
( K! `! U* W$ e1 A5 }};
, V( A+ A4 O" C! v3 W
$ g+ v( s0 W: ~/ ~static struct gpio_led da850_evm_tl_leds[] = {! u  n2 Q9 w6 R* }. Q* x
        {
- U1 Y, S; b7 u# ?/ ~                .active_low = 0,
$ G' L- w/ a* V, @: `) X                .gpio = DA850_USER_LED0,
* y" o% [' @4 o1 i. B. s                .name = "user_led0",% @% h' q, U: X
                .default_trigger = "default-on",
9 e) p) B' t+ ^1 h" v        },2 Q% [6 {/ {- ?, J2 j& ?
        {
. C$ `- t* T' G! O) V                .active_low = 0,# U- Q! j4 Q$ b& G4 o
                .gpio = DA850_USER_LED1,
8 z) u# [8 g, O8 R; z6 A  p  ?                .name = "user_led1",. d' v. m  M; H8 w0 H/ S
                .default_trigger = "default-on",) b( m% V7 \( C0 W& u
        },* P- \/ t0 E/ \; J
        {* E& C9 l# n% U7 u7 ]
                .active_low = 0,9 c- ~7 J( P8 a( q# w& a
                .gpio = DA850_USER_LED2,
5 K/ {5 m- _4 V                .name = "user_led2",
7 E, I- r/ e8 W0 @) n3 A! f                .default_trigger = "default-on",; t) \- p  F% l* `
        },
  N* M3 J8 j, Z& |: `' U8 H        {+ D" S4 u" w: l/ w3 k8 S2 ^
                .active_low = 0,
3 m) _6 H( t8 {' k* }9 |7 ]                .gpio = DA850_USER_LED3,
! ~4 ]) l3 {" q/ D+ h7 {                .name = "user_led3",) Q1 N: H0 {. }7 h2 h2 I
                .default_trigger = "default-on",0 p+ y. E3 s' V$ B' E% C
        },- W3 }. }8 f0 Z, L
};
2 v# l4 C0 X4 R3 k' {+ i' o9 e
& o9 Q3 j( W) V- M" L( n8 `8 H7 d5 R6 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( V& P* u8 ?! ]2 q- R1 J/ z
        .leds = da850_evm_tl_leds,9 h4 x# Q0 R+ a' U8 h
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% c* P, H. }8 c5 E- m
};( T9 m9 d  E. }5 k' M
8 T+ `( D9 a$ p: v: y3 r/ n: w6 _
static void led_dev_release(struct device *dev)
1 u$ a* v' `: f9 _{
2 K% _1 C: W: ~' B) _4 S8 L  w' H};
: R- r+ w" e0 b) L# J& q) E+ o, y( x* ]
static struct platform_device da850_evm_tl_leds_device = {# q0 R9 Q" ]' I) @' ?9 T5 I
        .name                = "leds-gpio",; I# q% |* G- [1 |% k7 q
        .id                = 1,1 g+ P) ^3 k% n- o  X6 r9 W
        .dev = {: q6 O, K3 R5 b
                .platform_data = &da850_evm_tl_leds_pdata,7 `2 d, u$ p. B+ N$ B1 N
                .release = led_dev_release,
! G* ~3 \2 B* {, w; x  R7 I        }0 f- D5 J+ y2 v
};
9 H. `5 S, \4 y
0 l; g8 [9 d' Lstatic int __init led_platform_init(void)
  _/ Y! l) s. E& D8 x{. a+ F( Y; C+ l% r  {2 h& P4 u; p
        int ret;/ n  b2 W/ ^7 @, j! U7 `5 Q$ d, x
#if 0- m6 `9 Z5 Y2 e; ?/ v, G4 U4 ]
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- O& V& u/ g: J0 ]8 q+ a        if (ret). @5 l& J8 t# [0 E4 i3 V
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' @' Q5 p4 ?- s; n% a* }0 E
                                "%d\n", ret);
$ a* o' O- [  u7 V4 D( |#endif8 Y3 K% s' d. j% G/ c( q
        ret = platform_device_register(&da850_evm_tl_leds_device);1 n9 V. j% }. m
        if (ret)( y" D6 X# c1 I+ u0 _& {
                pr_warning("Could not register som GPIO expander LEDS");
3 R0 f6 t3 n) Y* I! P. N, b/ l        else
1 S+ G3 [; }$ u( H  e$ \9 M                printk(KERN_INFO "LED register sucessful!\n");
3 i0 j0 H# y2 s
  |, W3 _! @" n( a8 O        return ret;, y( \. l3 {6 k" T, G% O2 [
}" s; r) L, o( s/ I# e6 S. Z! D, c
4 j0 i2 {5 ?; f, L
static void __exit led_platform_exit(void)8 N: i0 b0 W6 k, u
{
; M4 l! i- P+ B& g& r1 _        platform_device_unregister(&da850_evm_tl_leds_device);4 m, W# c8 Y; G7 C! u1 R4 W

! d6 R& W6 _& R/ a) I        printk(KERN_INFO "LED unregister!\n");9 ]4 W: A5 d1 i
}  J& a# M5 D8 K+ H" f& M$ i
0 S' Z' v8 N, N1 p+ d; I
module_init(led_platform_init);
7 N2 M' x$ T$ y' gmodule_exit(led_platform_exit);* z7 i7 X3 D$ D9 W& r+ d

0 G/ [! P, c/ J3 g4 @# ~4 K3 h. |MODULE_DESCRIPTION("Led platform driver");0 X/ h6 Z' w: X) M0 \2 H
MODULE_AUTHOR("Tronlong");
) U5 ?1 ?8 O( z! z/ J+ SMODULE_LICENSE("GPL");
* t$ d6 }$ v3 ~+ t# s
; J6 B5 ^, R3 F' F* q
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-28 00:07 , Processed in 0.039335 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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