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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。( u3 c- r: Z+ Q. L
#include <linux/init.h>
" G3 p! s/ w6 s) \$ g- j1 k0 l/ B#include <linux/module.h>
0 A3 X4 F% j2 b; c#include <linux/kernel.h>7 @; J+ s9 ^1 p5 g! f3 J5 r
#include <linux/types.h>; o' Y' d7 c) s$ _* {, h
#include <linux/gpio.h>
& S. V; m  x, V. g8 L#include <linux/leds.h>- c: {7 y# |9 \7 `5 J
#include <linux/platform_device.h>
2 V. w3 X: z& e/ j$ i, S# \. z6 O+ C. a
#include <asm/mach-types.h>4 l* h6 d  r# x" ]9 m. W" F
#include <asm/mach/arch.h>
3 `$ }% h- |+ R1 h6 _$ S#include <mach/da8xx.h>- n+ u" _3 k1 G: \% X; P1 m! f1 X
#include <mach/mux.h>( U! U* d; x9 S& k+ k$ a. \$ W
- @# H' X, U- v4 H3 h% S
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)
1 M9 C7 _, w5 g( c: x3 B#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)3 |; b! q5 Q6 w8 j( O
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)
! `  X) R, C" y8 ^' l' b$ Z, V7 [#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)
# K4 [! |* A4 v8 d, M
8 w. l: l, u3 ]+ j) V& w+ F6 s7 p+ A/* assign the tl som board LED-GPIOs*/, B# e, i; g  A8 {# E
static const short da850_evm_tl_user_led_pins[] = {
- D% f9 }  z7 u# V+ P        /* These pins are definition at <mach/mux.h> file */
* s7 b4 z0 l% s+ B2 f1 G        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& S0 [' m  E8 Y) e0 ^
        -1
; H4 {9 W( R0 T5 \; n. B4 P};
5 y* U; U: o( Z3 b( Q
5 w( ]! N+ c# p; v3 x" {static struct gpio_led da850_evm_tl_leds[] = {
+ ?  g3 J5 l2 M$ ]5 A$ w        {/ ?$ l3 T* H' X$ B
                .active_low = 0,0 l5 f" S* N' {. M
                .gpio = DA850_USER_LED0,
' a0 U5 J' f# o                .name = "user_led0",
4 V% ]6 Q9 f: w- V  Y                .default_trigger = "default-on",1 j3 l; e2 N  {& w0 P8 N# D
        },' z5 x& ~# v' ^! d$ h2 C
        {2 ]$ p' }, X* F2 A; G
                .active_low = 0,
& Y6 C# \7 n" P: D% x- ~  A2 t3 @& I                .gpio = DA850_USER_LED1,7 \8 L9 j, p/ k7 c" [7 \6 n: p* {) b) s
                .name = "user_led1",8 r/ ?1 J$ X4 \" a! ?0 L
                .default_trigger = "default-on",) o# r4 x% i- D) ]% Z" ~; e
        },
1 {5 ]) m& O* L; k; @2 a' V        {
* U& S2 p4 C3 g+ r! }                .active_low = 0,
% P& ]. l1 F* f: \                .gpio = DA850_USER_LED2,
, F7 V  B1 j' {                .name = "user_led2",
6 t: T# m2 x4 X                .default_trigger = "default-on",- s' _  k8 S& t1 K( P
        },
& }# B3 Y' T2 i8 b* T7 j3 @, Y# k        {
  b/ h, U% N2 K                .active_low = 0,
! V- O5 H$ b% f# i+ L                .gpio = DA850_USER_LED3,
! O2 I4 [3 l$ u7 X/ y* i( k                .name = "user_led3",* l9 J/ x; E0 ^8 s/ W& C& I
                .default_trigger = "default-on",- N- I$ {0 e0 X( ?; S
        },' L, F- e( Y$ E# c
};
0 v' n3 T5 [( N% S. P! X. u# x9 q
& ?# C9 ?  L/ u. _  Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' u/ ?8 z* |- U
        .leds = da850_evm_tl_leds,9 T' n. w4 n4 o+ Q* X
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( X8 F8 f5 }$ I8 U$ ?1 r9 B
};
5 f, u* F% G! F; a3 r- ~; k' T4 b6 R2 \3 D# Y0 w
static void led_dev_release(struct device *dev)* s1 e/ g# C' d9 c! }+ L6 S
{
2 @, J! c8 G4 ?4 G! p7 l4 v};0 v0 H' m. n# v% }( y5 P- k

; k5 v. f1 y# G3 A1 D1 h+ g2 nstatic struct platform_device da850_evm_tl_leds_device = {- H( L1 I. b  q+ O- }: _
        .name                = "leds-gpio",  n6 v: a9 n. \$ @* v
        .id                = 1,
* r$ W/ |# n  \+ x: j  ~4 [" b        .dev = {8 q& f# L8 f3 s2 A. Z* v
                .platform_data = &da850_evm_tl_leds_pdata,: n% t+ T& z/ @. _
                .release = led_dev_release,6 L, }6 ]' r! Q( ^' H$ V$ w+ g
        }
( _( g1 R  }4 X; L$ b};4 @3 K  y2 h9 ~+ G7 a+ j5 a9 J) M
6 n5 n, I, I+ }
static int __init led_platform_init(void)
1 ]  G/ N7 \: a; f& u{( D+ P3 n9 L5 W& \1 n
        int ret;* Y# i/ `8 J8 N' b$ h' Z( X8 P, z
#if 0" B& x9 M( ]' I/ G1 u
        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 G4 G' j+ }3 j* D: w1 [. W0 K% U# a        if (ret)
/ ^# ~8 e7 b0 o' p+ r                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) b/ d+ G( p$ ]; |4 N  \) r                                "%d\n", ret);3 e+ t1 T/ m/ N& @$ `) G
#endif) h5 F$ O; K; T, A
        ret = platform_device_register(&da850_evm_tl_leds_device);
5 D4 {% l* N  Q5 S" T( W        if (ret)/ k) ~9 `! b7 v4 v
                pr_warning("Could not register som GPIO expander LEDS");& d: V1 u$ C. a+ p. D2 K3 C# h
        else
+ E- q" ?. P1 M" ]# s$ P3 C7 V                printk(KERN_INFO "LED register sucessful!\n");
5 ^; Q( S$ v8 e7 Q+ Q
( h& o8 H, r' k& I# U" x  ]$ S" R        return ret;
) e7 I; G$ k, S# g; O7 J2 v( ?. _5 c}
8 t* G: o0 B* c& c: |; l$ \4 ?# A
3 x5 L9 m1 n% q& E" Fstatic void __exit led_platform_exit(void)& Q( w) P. I! w2 K+ s; x
{
* M  E% ?6 M! J7 Q) n  q        platform_device_unregister(&da850_evm_tl_leds_device);5 m* U9 r4 e8 W, ]) P5 _. [
" h4 u6 h5 ~9 L. v  d, \
        printk(KERN_INFO "LED unregister!\n");9 m/ a9 }( d! o" K9 W4 q  n
}+ `1 j4 v  e+ q# g- z

! Z7 N* i! i4 B% @# L8 c" Qmodule_init(led_platform_init);
- W# W- \9 E- b! A6 Tmodule_exit(led_platform_exit);$ G: V0 }  G, I1 I$ M. u2 t
9 Y$ P! W) O" d" @' Z% o/ R( P
MODULE_DESCRIPTION("Led platform driver");
# h7 h2 i# [# Q) ?' u# TMODULE_AUTHOR("Tronlong");
! U" v$ n1 ~5 c: \4 wMODULE_LICENSE("GPL");
( _$ W- C) L& }4 \. R; a7 e" @2 i
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-6 16:44 , Processed in 0.036734 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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