1.
/*1.
头文件
*/
2.
#include
3.
#include
4.
#include
5.
#include
6.
#include
7.
#include
8.
#include
9.
#include
10.
11.
static
unsigned
int
led_major
=
0
;
12.
volatile
unsigned
long
*
gpc0con
=
NULL
;
13.
volatile
unsigned
long
*
gpc0dat
=
NULL
;
14.
15.
struct
led_device
{
16.
struct
class
*
led_class
;
//
表示一类设备
,
存储某些信息
17.
struct
device
*
led_device
;
//
表示一个设备
18.
struct
cdev
*
led_cdev
;
19.
unsigned
int
val
;
20.
21.
};
22.
23.
struct
led_device
*
s5pv_led_dev
;
24.
25.
static
ssize_t
led_read
(
struct
file
*
file
,
char
__user
*
buf
,
size_t
count
,
loff_t
*
opps
)
26.
{
27.
int
ret
;
28.
29.
ret
=
copy_to_user
(
buf
,
&
s5pv_led_dev
->
val
,
count
);
30.
if
(
ret
>
0
)
31.
{
32.
printk
(
KERN_ERR
"copy to user failed!\n"
);
33.
return
ret
;
34.
}
35.
36.
printk
(
KERN_INFO
"val=%d\n"
,
s5pv_led_dev
->
val
);
37.