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

嵌入式开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

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

[未解决] 程序注解

[复制链接]

5

主题

8

帖子

53

积分

注册会员

Rank: 2

积分
53
跳转到指定楼层
楼主
发表于 2018-1-19 19:02:07 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
求大神给下面的程序做注解,请稍详细些,谢谢。$ G. Z% ]8 P4 s. i8 C
#include <linux/init.h>
! E( F% A9 T: M! _  u* _$ \#include <linux/module.h>
1 Y9 |0 ]% x! ~  v8 f- A6 `#include <linux/kernel.h>
3 Q  J6 |% y. `& K2 q8 j: c/ J#include <linux/types.h>
; R0 q1 I$ b9 W#include <linux/gpio.h>9 k0 T% M% ?* G
#include <linux/leds.h>. k4 x( F3 q2 W& D
#include <linux/platform_device.h>3 o+ _) ^. P- W" R
4 l: s9 `  K" F. Z2 F* W$ }
#include <asm/mach-types.h>  x% M& R- }, a. X
#include <asm/mach/arch.h>( r6 R3 x. ~3 x+ Q, b) d
#include <mach/da8xx.h>9 s( s. U9 ?+ t" ?" a8 R: J
#include <mach/mux.h>& l+ Q% F, H% c. y. V1 J+ H

$ J; H! L/ [1 r; {, e& y#define DA850_USER_LED0        GPIO_TO_PIN(0, 0)' ~' L; n+ l# _& S- M
#define DA850_USER_LED1        GPIO_TO_PIN(0, 5)
4 |' R! _# Z7 l: l#define DA850_USER_LED2        GPIO_TO_PIN(0, 1)) d$ l" m  c4 y9 g5 s, q
#define DA850_USER_LED3        GPIO_TO_PIN(0, 2)3 U( Q/ @# @8 E! t
& c% b  _/ U- r) @: L& V: Y- k& U3 |: P' r
/* assign the tl som board LED-GPIOs*/
! w8 ~3 L4 D( C4 [) ]- h/ Xstatic const short da850_evm_tl_user_led_pins[] = {
1 z$ l6 X3 Y2 q: F" ]        /* These pins are definition at <mach/mux.h> file */
: A) z" Z: m) T2 g4 G) o* n: D        DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 f# g% s- G; o* \9 k' u
        -1
! o8 n; }5 z7 F; [# m7 Y( I! X};
  P6 v+ A; o0 m
& q; P. A1 Z. Mstatic struct gpio_led da850_evm_tl_leds[] = {
2 o& R' @/ b# b        {
3 ^9 |, Y# z8 S/ ?$ Z                .active_low = 0,7 L9 [+ r2 n+ U8 V* |, f2 j+ L8 t) k
                .gpio = DA850_USER_LED0,
' w' k3 R; R. @, \2 z                .name = "user_led0",
; L" O# ?' B. I/ i1 G  y                .default_trigger = "default-on",1 E, |: A& n" t  A8 i. T( I
        },1 K2 Y  c) x5 n% Q* }, K& A
        {: ~4 n6 Y+ k9 _: b- p: ?0 h! A
                .active_low = 0,
( l* D5 j! I7 k% V/ C+ _6 X% y" `                .gpio = DA850_USER_LED1,
5 B9 w8 i) a# S, y                .name = "user_led1",4 f2 A8 \. J  C( R5 t
                .default_trigger = "default-on",
; c+ D8 b( i& f" \        },
  t. D3 |& x( L& P3 E& R- H& O" Z        {$ o4 V1 {. z' E; [
                .active_low = 0,+ d6 }2 I+ O. _8 _
                .gpio = DA850_USER_LED2,9 ?9 @( P8 W- Y; ]4 c! i
                .name = "user_led2",
$ q( X1 A+ B' f; e8 a+ n                .default_trigger = "default-on",
( n4 n& x# @* M# ?        },
! n$ ~' |- e; j4 n        {
1 P* D8 x9 d1 J% \) K                .active_low = 0,
! E' o9 p  d; W% w8 i                .gpio = DA850_USER_LED3,
' Q: [+ ^& I6 h6 B# F+ `" e                .name = "user_led3",6 X6 c" n# {$ ^* l, u
                .default_trigger = "default-on",' }( f* @4 K2 ^
        },
; }! {/ e8 g/ J6 _0 N! Z; [( X};1 \! O8 J+ x& `' o( B" }1 @
/ T. J4 V5 w" `- D6 l& S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 K/ f6 w$ ~( J  l; `9 A, g. @6 w
        .leds = da850_evm_tl_leds,; Q0 e6 x( {! K5 X" _
        .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 z! p! N/ n# S7 o};. w# s6 w" C( Y% [! E1 ?
4 e" c% l* p) z
static void led_dev_release(struct device *dev)
5 B& a1 E+ g0 S$ \9 z. b" h3 c{! a0 C- e7 p, _; S4 Z7 `# T
};
. Y7 l" ^7 {" S" F4 r, x9 s
* p& |- T* b8 ^3 d: cstatic struct platform_device da850_evm_tl_leds_device = {2 G- j6 ?; I6 w* Q6 }+ b! q8 a
        .name                = "leds-gpio",
) @$ \$ u1 M) J4 b: F8 c        .id                = 1,+ f! Y$ b( i7 W
        .dev = {
. O* `! U2 k+ P4 }! [                .platform_data = &da850_evm_tl_leds_pdata,7 V, l8 x1 H  f0 D% Z
                .release = led_dev_release,! t- D, ?0 z4 z: F# S
        }( |9 \: m- ]3 w+ X9 g
};* L" L, d& c" h: f7 [1 J: p+ O/ ?

9 |6 D! k$ K3 x) d8 Wstatic int __init led_platform_init(void)" H, J: [. f' {
{
2 A: O! {3 G8 t+ J        int ret;' {$ Y; A, Z  f  T  @
#if 0
3 i3 [( F5 _# R; F8 O5 j        ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) c& I( L1 {, [
        if (ret)" a2 }1 T$ b, b9 e3 g2 C0 c
                pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 ?, u3 w% K9 V5 g8 m9 M
                                "%d\n", ret);, A% I3 W( l/ H4 Z6 s8 T
#endif  @/ G  V. j/ V$ G2 y' u7 ]9 h
        ret = platform_device_register(&da850_evm_tl_leds_device);
( S* p" w% ]9 @/ z' i        if (ret)0 }, c+ v6 i! u# {& Q
                pr_warning("Could not register som GPIO expander LEDS");
# D3 s; j$ k# Y0 e. ?        else
5 R/ n, M( M( H- ~( l' y4 o0 S                printk(KERN_INFO "LED register sucessful!\n");
: {! z) _# a3 Q( z% \$ U0 ~& v9 n3 {
        return ret;4 Q" F5 Y! l2 C3 k- Y9 f
}
! P2 M" O2 w% {  A; ^" ~+ S# k( _" ~! Z: U( K5 a
static void __exit led_platform_exit(void)6 q# t; I* f7 r& E$ }
{7 C- t7 S) E8 l  m; C
        platform_device_unregister(&da850_evm_tl_leds_device);
8 v, @2 c+ w! u' Z0 P  [' n0 S
9 P9 ?9 H0 v' P6 |0 q        printk(KERN_INFO "LED unregister!\n");" L: \/ n, y4 O- x; q
}3 Y  t% r$ c9 o+ |0 y

/ ~, R  a+ P8 h7 x# L: ~2 f2 X4 mmodule_init(led_platform_init);% D  U) A; M. g) d: F1 p
module_exit(led_platform_exit);8 x4 `2 [; E% L" p
/ t) H$ j. U  p! q1 R* A2 r
MODULE_DESCRIPTION("Led platform driver");
0 I7 Z# {4 W! ^& S0 ^MODULE_AUTHOR("Tronlong");
) s  x" ]# V" y" V$ jMODULE_LICENSE("GPL");" M1 e5 q/ S0 F6 z. C) P* Y
; S, e" U5 ]; K' z5 l! \8 z
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-12-6 02:35 , Processed in 0.038971 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2015 Comsenz Inc.

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