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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。. Z, z7 X  E! \9 M
#include <linux/init.h>
, |+ L9 U: O  ?#include <linux/module.h>
$ }8 I: `. A6 R! ~- [#include <linux/kernel.h>" d; u/ u. y7 F0 m+ W) J
#include <linux/types.h>* \1 M% h( G! f' ]
#include <linux/gpio.h>" I, o( L( H; O. \# n6 ~7 U
#include <linux/leds.h>/ f" _* ~3 A7 I. ^/ q6 p
#include <linux/platform_device.h>
. y7 ]& U% C4 k- m: |4 k0 h3 K1 m/ u' @) I. x
#include <asm/mach-types.h>+ S6 g. m# o  j# a% x1 K9 R
#include <asm/mach/arch.h>
1 m  ~0 j  N5 m5 c# ?#include <mach/da8xx.h>
- O6 d& s" R/ J! _! ?3 |! B& H#include <mach/mux.h>
5 \! i9 B& g$ E* s  D( G) i. l1 e# m& s" V
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)6 d. C& f: R$ g/ j+ @$ f- W
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
0 l; k) a8 b# P% n0 v& x/ W#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)" K& c0 V* r; p( ]6 ]2 e% Q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)& A& B/ S: D( |* A) ^  @
3 j8 Q0 e8 m  ?
/* assign the tl som board LED-GPIOs*/
& t6 Y6 |/ L6 n0 ]7 q2 @1 dstatic const short da850_evm_tl_user_led_pins[] = {
" g; }1 ~8 a8 Y9 `1 F. `        /* These pins are definition at <mach/mux.h> file */
( N! H) j" a  e" A9 j  k! y/ F* T7 M        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; ?# k# s$ i6 ?1 E5 p1 u. _        -1! m; w& M' o3 ~
};7 h! ]5 y! u8 d$ E2 L; N! y& L
. v) g+ f2 {, g2 b6 {$ |5 T7 J% E
static struct gpio_led da850_evm_tl_leds[] = {
* o' G9 z7 S( p- r        {4 H3 R8 O! Q& N, A+ Z! \, C
                .active_low = 0,9 f* r8 E/ ^  |& U# h$ Y8 M8 t/ H
                .gpio = DA850_USER_LED0,
- C1 e" w  r  b( I                .name = "user_led0",
7 a- L2 m; F$ j) [0 J5 w7 |                .default_trigger = "default-on",
! {3 q! ^, \, ^        },
( y! x7 y( _9 g2 e9 J' @7 w1 D' `        {
' Y" a' d' V- u$ X8 c                .active_low = 0,  x: D7 c9 x# S8 z" k
                .gpio = DA850_USER_LED1,
7 g& g' ~7 z! Y& Y1 E                .name = "user_led1",2 f5 R9 G) H) W# I) \6 e3 x) c
                .default_trigger = "default-on",2 k) i8 n4 w) ^# _, m% q
        },) z% P& R7 [5 ]( |# s" X+ ^
        {
; K" n8 U# H+ C5 F( B6 s& g                .active_low = 0,; C6 b) p, L5 o  X( p# |
                .gpio = DA850_USER_LED2,
& U. Q7 z9 Z6 `7 b7 P                .name = "user_led2",
4 _0 s+ [6 h4 q: l. M' T! X( M                .default_trigger = "default-on",
7 t' L) u- b; j# i4 P6 n2 A        },
5 M' E& o4 i. T9 n& c4 `, a        {
% y/ V& A. G9 r8 s, B* w                .active_low = 0,
  u; i, T: K) C6 x# A0 O* P                .gpio = DA850_USER_LED3,4 I( u$ F  C$ K+ o: y' ?
                .name = "user_led3",; N0 |8 d/ t3 E3 ~. y3 r0 \
                .default_trigger = "default-on",7 i- t" u: I; }) \
        },
. h0 |* ]# H2 d/ M# R9 r2 p};- t0 L) H; h+ m. J+ U

2 E+ k+ k# @( I! r, Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" p6 ^& N% W8 c2 L/ U6 B8 e8 M& J9 ~/ F        .leds = da850_evm_tl_leds,: w6 o  A: b' }7 }& j/ |
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),  n4 l: Z! j6 Q, _
};
7 R+ q- n) s. L9 {) x$ Q1 |  r# c, M8 C7 l7 P
static void led_dev_release(struct device *dev)
1 P1 z1 |+ G# C0 p2 Y{9 g1 ?, n: `8 x4 L9 a
};
* X  z, n& |% `( i. b
& v& N" b2 C4 cstatic struct platform_device da850_evm_tl_leds_device = {0 m: g& {! w; l/ b* F
        .name                = "leds-gpio",) r8 X1 F  l$ a' D* \
        .id                = 1,
+ t& \5 F1 }- K$ y! ~        .dev = {0 z4 t# E1 @' a0 X9 Y, P/ O
                .platform_data = &da850_evm_tl_leds_pdata,- J* N# Y$ _9 t# G; a% `: A
                .release = led_dev_release,
5 t" e$ U  D' e$ \+ E+ a, k. t9 {1 w        }
' w) q5 g, |8 ?7 ~! e7 n: S1 Z};6 S3 f" k0 |9 Y, b/ S
' [4 t& d2 D1 T8 u
static int __init led_platform_init(void)
0 I% f0 x- {+ `' Q3 H5 x{
- O/ U: y) a/ V, @0 |% m# O5 z        int ret;
/ Z9 k7 e3 v/ T6 r! p+ O6 j#if 0
; S, X! F# o& W$ A8 o8 l! G        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* b# g% D, i8 ~% e' P& G; r7 q5 V
        if (ret)  v, X. J( h- [5 @; T1 L0 t0 u
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
  {) }) I8 |0 Q/ u; j! Q( y                                "%d\n", ret);: N. O) {' B: u3 U  {
#endif: Y. o2 ^7 s$ b
        ret = platform_device_register(&da850_evm_tl_leds_device);$ `. c" D, f5 Q/ M
        if (ret), M1 s) _2 M" h
                pr_warning("Could not register som GPIO expander LEDS");
1 W: U" D  p9 ^, S$ S6 o7 x7 g1 T        else
$ X1 C* k$ x/ i9 p2 r. I                printk(KERN_INFO "LED register sucessful!\n");
# h0 Q% r) I: X7 ^
  x3 j" ]8 l& G$ @4 G! x        return ret;3 K" P- |+ E3 Q5 f! L; n
}
3 i1 m' h6 ^( n- W' L# w/ Z  A' ^7 I- [
static void __exit led_platform_exit(void)3 a+ {+ A7 E& U/ j2 q& f6 u
{
4 E& v1 H% y0 y6 @' q" |2 I4 q% S$ Q9 L% W        platform_device_unregister(&da850_evm_tl_leds_device);
5 R2 Z2 p9 s) m% u3 \, M* S; a4 x; p
        printk(KERN_INFO "LED unregister!\n");
. M+ \3 X: q, `6 t4 J& I1 n7 P; M}4 r  o; Z# D3 S( _5 R& D
+ _$ r1 V: g* S. L. w
module_init(led_platform_init);2 B9 z) _$ k5 d, |, R% I; P
module_exit(led_platform_exit);% \. n" H% L4 D; c/ ~

0 D6 s1 C, o' fMODULE_DESCRIPTION("Led platform driver");2 b8 e- z( d6 c' f
MODULE_AUTHOR("Tronlong");7 Q4 h6 o0 U# i
MODULE_LICENSE("GPL");
, f' p- h- `9 Z% s
- c7 g5 M) Z  l2 p1 h6 ?- P
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-4 14:01 , Processed in 0.044466 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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