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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |正序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。
, P1 D0 |* `. v4 s#include <linux/init.h>0 K! G( b# J3 g& M- l
#include <linux/module.h>
9 j7 J2 Q1 `' ^4 i#include <linux/kernel.h>* U* x) S! A" R6 f% |- l
#include <linux/types.h>$ P, A  h' F$ N! Z
#include <linux/gpio.h>2 X: S1 ~* I/ G% q/ h
#include <linux/leds.h>
3 \6 |. p3 _0 s0 ~9 {2 }( w1 U+ ~* ^6 R#include <linux/platform_device.h>0 N# M1 A5 t# w1 q2 k1 G
: S: }. F# m# R$ v2 Q4 i! I1 l, R
#include <asm/mach-types.h>
; u1 S8 ~0 t. y" m3 D  O#include <asm/mach/arch.h>9 [9 U8 F; [1 J
#include <mach/da8xx.h>3 G2 @7 Y# ]1 Y& g, H" }% {2 A
#include <mach/mux.h>. F& y$ ]$ w  ^
. T" F3 v0 V* q3 M
#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)1 G  [* Z: D# R6 n0 N
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)5 K* ?7 y- I3 F( W* D
#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)( ^% V& [1 {$ W- ~+ q/ t
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)  W& o9 A: c  e; C' U( j
& Q0 y. h/ H8 v4 n3 t$ [
/* assign the tl som board LED-GPIOs*/% a& |" o; v2 P. w9 X
static const short da850_evm_tl_user_led_pins[] = {
+ o1 u" B5 A' y# \        /* These pins are definition at <mach/mux.h> file */
2 l  W/ e, L/ e4 M* A; x        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: {& n) E" P! u, |$ v4 e
        -1
* k0 |* W6 r0 R, n. k};% C3 Q* O: W3 [) S

5 k, z3 Y9 m8 P! m3 q9 G$ dstatic struct gpio_led da850_evm_tl_leds[] = {5 Z6 t, p- c+ O' l
        {3 T- Z1 m% K& i9 r  |
                .active_low = 0,% V* w' x: r$ M0 g
                .gpio = DA850_USER_LED0,
8 }2 T- G* _; i# g. K( v3 {, D1 m                .name = "user_led0",7 I4 N6 `% J1 W( {( K
                .default_trigger = "default-on",8 A! D" f3 X! z; b( K. f4 p
        },0 n8 x* |2 H% S7 T, _! V
        {
# B( i: f* M8 b                .active_low = 0,; h+ W! e6 `- H3 H  q3 O* |
                .gpio = DA850_USER_LED1,
: N# H# n& G3 m- Q) d! Y+ u                .name = "user_led1",
9 t, t5 o$ [0 n* ~                .default_trigger = "default-on",
0 D  j) @  H7 ?$ i        },) Q& M8 H9 K/ g7 E! V! W5 b5 |
        {2 S; Q6 z$ @6 j& k
                .active_low = 0,
8 n5 b+ l' g& m0 @5 u, V9 ^                .gpio = DA850_USER_LED2,; q( U5 N4 {0 W6 R) R
                .name = "user_led2",5 u2 Z2 G' S& v8 }- S8 _( [9 Q  H8 c, P
                .default_trigger = "default-on",: b; t' `% R  s. ^
        },4 d6 [8 Y. L1 ?# n0 i4 a! c
        {
% Z3 i8 o: A3 b: m( {3 ~& F                .active_low = 0,/ \( ]* ]: f* p' u
                .gpio = DA850_USER_LED3,$ `; G6 q; l; L/ K# w1 k+ v
                .name = "user_led3",/ Y2 z" ]% |3 n* {" B" M' W7 i' q
                .default_trigger = "default-on",
  N  E* |& f5 a7 T9 |/ ]        },
0 b; C/ z8 J* X+ n$ @1 _) w};, ?0 q/ D- T8 v6 k
5 ^2 y# B, O5 w% s2 {( `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ y3 R2 }& C* a0 Z  X( r        .leds = da850_evm_tl_leds,
( a6 k7 ]$ Z  j9 s. x        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ R7 {2 u; F3 k1 j7 F};& T% }# x- y1 i0 r: y+ X$ B6 e
* J7 _# ]9 u2 S! s5 d
static void led_dev_release(struct device *dev)
& p- ?9 ^9 O9 P- u4 g{2 c, r  T+ B, o5 `9 H
};5 V( C! ~- m' m4 |
! u/ O2 U  B, p6 L  P% c& d8 r
static struct platform_device da850_evm_tl_leds_device = {
* P6 _8 \9 A2 }8 r# _. v        .name                = "leds-gpio",0 a6 q8 j; I: x- c
        .id                = 1,
1 l3 T# z3 k6 f& f# k4 }        .dev = {
1 _; o; i2 ^3 I( K) ?) r; f+ Y                .platform_data = &da850_evm_tl_leds_pdata,
$ L7 F+ H$ r, A. i0 g  q; V                .release = led_dev_release,
2 e7 b$ c. O# r- x        }, ]' S0 o0 r$ u- N- J2 r! m/ x# u! a4 p
};
& k# `: t* ~# N  q3 }! V& \; v7 _6 x! {
static int __init led_platform_init(void)
8 }( b# r' }6 w7 h{. P- I$ R" I7 y# A/ [) j
        int ret;! ?0 f( J9 ]: ^3 G- p6 U8 u
#if 0
2 L  A! u5 n) M/ ?4 U# m4 p/ M        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: T; {' o4 ?# i! x$ }, I4 R( }3 m
        if (ret)
- u! t% Y% U, q- z                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 _  \0 e2 J1 c/ w  h7 G                                "%d\n", ret);0 r( K# ]! o" ~8 ^; J9 f, t
#endif
$ I& Z3 W, l- J& X        ret = platform_device_register(&da850_evm_tl_leds_device);
& S; {; t* [- Q. V        if (ret)& `( K5 ^8 l9 V8 {  m: ~$ L
                pr_warning("Could not register som GPIO expander LEDS");
- O( S, k) X9 p! F/ \) o        else
- [  F3 Z% [$ e, n                printk(KERN_INFO "LED register sucessful!\n");
! A* U" m& N4 p, I8 c0 E& M/ C0 z
) _+ k/ o1 y6 x        return ret;6 s6 _3 Z+ l5 D
}
6 b- {" E; x) k- f" ], S5 S) j; t! L
static void __exit led_platform_exit(void)
1 X9 U: ^* f0 \2 |2 j{
" m9 H! m" ^0 N8 E        platform_device_unregister(&da850_evm_tl_leds_device);* h. E0 s' @! ]) }4 W
, I& r  U7 m" `' L0 G) s
        printk(KERN_INFO "LED unregister!\n");0 E. x  h8 D$ d/ w7 r
}1 F" K$ b+ j6 F8 g* B$ }* Z

% V' P: @5 s1 L2 Nmodule_init(led_platform_init);& x" Z4 g5 |/ ?& H6 Y/ i% E$ e4 m( w
module_exit(led_platform_exit);
; [1 y( @3 L- G9 ~1 s6 t
  G4 g0 ~, n5 ^MODULE_DESCRIPTION("Led platform driver");
. v6 F2 U; r+ D! p3 W/ X0 w& bMODULE_AUTHOR("Tronlong");, N& v9 H, V; e) `0 H2 L
MODULE_LICENSE("GPL");& W+ q, n5 Q; u$ J4 Z  ~
7 h8 Y1 y& g: ^8 L9 g
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-4 07:32 , Processed in 0.036527 second(s), 25 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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