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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
+ t6 q( F; _! h8 [2 ?  \) u#include <linux/init.h>
$ h; O; y  e; w& s1 U8 e#include <linux/module.h>
: a, S) n/ c8 F1 ^0 _5 e; p+ k: d#include <linux/kernel.h>
  E  y1 a8 Q* @. l, K#include <linux/types.h>
) f; O! h. N7 {" [, m* h#include <linux/gpio.h>/ v; U6 i; Q. [
#include <linux/leds.h>
) O; L" f, N7 h#include <linux/platform_device.h>/ O1 f9 C( U) W9 p: r2 @3 Z( B% n
$ W2 s, |1 s7 H/ X6 O
#include <asm/mach-types.h>
( _& @4 g8 N$ d# c) @#include <asm/mach/arch.h>
: z5 v3 S7 T! R; {- R#include <mach/da8xx.h>
$ `! q  u( h0 h! U3 L% K9 P#include <mach/mux.h>
; I! \' ^4 M2 H0 d' I7 r5 u) q5 c! h+ f" ?2 c
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)2 O5 p8 e& F. u+ u4 e7 C  |' f' H
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
) L! Q7 h) Q4 F5 l) Z) [# |9 ~#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
* N1 E  Z7 S6 n#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)) I1 n% H9 V9 [/ W8 T
  v( h, s% p! R0 E: Q+ r2 u4 \
/* assign the tl som board LED-GPIOs*/# u3 ~; ~, l" B1 \& s0 K4 a# T
static const short da850_evm_tl_user_led_pins[] = {6 G' z  H) i0 A! p% Y7 k
        /* These pins are definition at <mach/mux.h> file */9 _+ R  k# }/ M2 Z
        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& G! ~2 l5 [" e        -12 V& }: N! j& c0 }0 ]- ]; O  h
};1 l" g+ V4 j. p# `! J, |' P

1 L4 s: E- O" {8 k; t8 M' astatic struct gpio_led da850_evm_tl_leds[] = {) R. m9 }' n3 R
        {
& w8 L' b* n/ w                .active_low = 0,
: {/ n8 O1 n6 F" @# m                .gpio = DA850_USER_LED0,
9 K, Y6 d/ ]+ h6 z                .name = "user_led0",9 f6 D# V  Y7 h
                .default_trigger = "default-on",  j% x$ B$ q) Q
        },
$ _- d- H  x. y* J. @        {' I0 x, |$ g$ @" c! w, ^9 _8 P
                .active_low = 0,, [4 U2 H) a4 `/ {1 G
                .gpio = DA850_USER_LED1,: U6 g, W2 E7 X
                .name = "user_led1",
, Z1 Y2 j" [3 _  j                .default_trigger = "default-on",) K; W4 D/ G+ r1 f/ R
        },/ h, v4 `% |( f" \9 F3 g* k% }( M
        {% L( |/ @/ z+ H! b6 W
                .active_low = 0,
3 `4 U7 u( k$ |$ {7 m4 x                .gpio = DA850_USER_LED2,
8 N  O0 t1 C. Q; b$ Z1 T                .name = "user_led2",
" B$ ]: m- H) ^) ^9 T5 P7 w                .default_trigger = "default-on",
0 B4 C3 W' b( A" `# ]/ E7 \6 f. h        },
: {0 T7 t1 r9 V- t/ I5 M/ a' ~        {5 t& A( f7 K+ r1 D5 b- i7 \
                .active_low = 0,0 D" }" \# s% n& o: p
                .gpio = DA850_USER_LED3,6 W% u( w# C' B" L; ]
                .name = "user_led3",/ y; c# x: [& S+ t2 S1 F7 s
                .default_trigger = "default-on",# K- g/ |( a( H0 _* J4 [
        },: \& T4 p4 i/ \1 l6 j
};
; ?9 I4 P7 _. k& b" \8 n# I) |" ]/ P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 Z% }6 A9 R7 l9 f8 C( u; [4 ~* ~        .leds = da850_evm_tl_leds,! p  [* E" w2 ?( _7 w
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# W' W. U  V2 C& `
};
/ ^0 R4 Q+ W& V- m0 G
" J* Z2 B1 b: y5 _+ V  k- ]static void led_dev_release(struct device *dev)) f, Q: J7 a$ N2 I' ~% P. X
{# a& Q6 p' E, J( m; L; i& g
};
2 h$ s, x$ z; O# \8 s% N$ K! v% p# m3 J! d
static struct platform_device da850_evm_tl_leds_device = {/ O1 ~, p" @" S" h
        .name                = "leds-gpio",2 E* N' V/ R+ o3 A
        .id                = 1,6 t5 ?& A8 N. {) C
        .dev = {& ~' _) o: m$ R3 Q
                .platform_data = &da850_evm_tl_leds_pdata,; v- j+ v9 E% H$ J# J
                .release = led_dev_release,: D4 L0 p3 n! l1 R9 h
        }7 _0 J' ]/ N' {  f
};' e6 v! \, V( @- {9 c

) r" {: b0 {0 W! b8 q* h. i: r/ ^3 Istatic int __init led_platform_init(void)
6 k7 p  p! {3 W{  z6 t1 v  g- y- C- R* P0 h9 g
        int ret;5 F6 Z. F9 ]9 h+ |0 J/ d
#if 0" A% Q9 O5 _# ~5 m) _7 \0 E' A
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 j/ B2 S/ a: F7 T' U2 R
        if (ret)
  i' x0 ?6 A; G% c+ c. @- w                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. @3 ^  {6 Z" G1 M& ~                                "%d\n", ret);
2 a9 `: h% N# V% Z* ?/ ]' q) V' K#endif
; V( i! W/ ], |$ Z# I* p        ret = platform_device_register(&da850_evm_tl_leds_device);5 ~/ L4 h% j  t+ e, u) n8 {
        if (ret)/ L' ^2 Z" z) C) n! ~& P
                pr_warning("Could not register som GPIO expander LEDS");9 B% G9 ~4 O" N: ^
        else( q* A* W8 s6 Z6 M
                printk(KERN_INFO "LED register sucessful!\n");2 V/ A: z6 l  _) Z: p5 H; L8 [

2 {, b# G* p/ w, Q6 A        return ret;3 x! P$ X: G2 Y9 u
}
$ N" Q1 l& |2 a0 W# g* W; x# W( |" L9 @
static void __exit led_platform_exit(void)
! Q! e* Z/ t  \; a{% g" n6 B" V" y
        platform_device_unregister(&da850_evm_tl_leds_device);
" t5 E; p# v" a2 F% W* h6 t  ^/ o# J7 g  r! [/ P- \) g& O/ l# E
        printk(KERN_INFO "LED unregister!\n");' F! h+ H7 t3 V) W3 }0 x
}- t# z* d" o; e! {+ k8 B2 M

0 \( _0 V" W& g2 K" A+ Nmodule_init(led_platform_init);4 `$ _& q0 }4 e" |3 ]8 }( L8 c! V2 `
module_exit(led_platform_exit);
4 Y& J% x) T8 B& ~' A6 [: a
# O6 p6 E2 T* j, R- Y! s% X* L3 EMODULE_DESCRIPTION("Led platform driver");
2 O. T4 y' k5 D1 mMODULE_AUTHOR("Tronlong");
8 G7 J1 W0 S- B+ g0 I" QMODULE_LICENSE("GPL");
8 ~4 ?# M$ p/ M$ \2 b
6 r3 t" o; T* s. L/ W4 G- P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2026-1-7 04:22 , Processed in 0.042383 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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