#include #include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include#include
//-------------class_create,device_create------
#include
/*用udev机制自动添加设备节点*/
struct class *led_class;static int led_major = 0; /*主设备号*/
static structcdev LedDevs;/*应用程序执行ioctl(fd, cmd, arg)时的第2个参数*/
#define LED_MAGIC 'k'
#define IOCTL_LED_ON _IOW (LED_MAGIC, 1, int)
#define IOCTL_LED_OFF _IOW (LED_MAGIC, 2, int)
#define IOCTL_LED_RUN _IOW (LED_MAGIC, 3, int)
#define IOCTL_LED_SHINE _IOW (LED_MAGIC, 4, int)
#define IOCTL_LED_ALLON _IOW (LED_MAGIC, 5, int)
#define IOCTL_LED_ALLOFF _IOW (LED_MAGIC, 6, int)
/*用来指定LED所用的GPIO引脚*/
static unsigned long led_table [] ={
S5PV210_MP04(4),
S5PV210_MP04(5),
S5PV210_MP04(6),
S5PV210_MP04(7),
};#define LED_NUM ARRAY_SIZE(led_table)
/*应用程序对设备文件/dev/led执行open(...)时,
* 就会调用leds_open函数*/
static int leds_open(struct inode *inode, struct file *file)
{inti;for (i = 0; i < 4; i++) {//设置GPIO引脚的功能:本驱动中LED所涉及的GPIO引脚设为输出功能
s3c_g