LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 982|回复: 1

求助 !! 编译驱动出错

[复制链接]
发表于 2007-8-14 22:29:25 | 显示全部楼层 |阅读模式
各位师兄,小弟依据资料自己改了个驱动。想学习一下,结果编译出现了问题,望哪位大哥指点一下。
static unsigned long led_table[]={
S3C2410_GPF4,
S3C2410_GPF5,
S3C2410_GPF6,
S3C2410_GPF7,
S3C2410_GPF4_OUTP,
S3C2410_GPF5_OUTP,
S3C2410_GPF6_OUTP,
S3C2410_GPF7_OUTP,

};
static int leds_ioctl(struct inode *inode, struct file *file, unsigned int cmd,unsigned long arg) {
int channel=100;
switch(cmd) {
case 0:
case 1:
if (arg > 3) {
return -EINVAL;
}
s3c2410_gpio_setpin(led_table[arg],!cmd);
break;
default:
return -EINVAL;
} return channel;
}
#define DEVICE_NAME "xu.led"
static int LED_MAJOR=222 ;
static struct class *my_class;
static struct file_operations xu_led={
.owner= THIS_MODULE,
.ioctl= leds_ioctl,
};
static int __init xu_init(void)
{int ret,err,i;
ret=register_chrdev(LED_MAJOR,"xu.led",&xu_led);
if(ret<0){
printk("xu.led cant be register\n");
return ret;
}
/*LED_MAJOR=ret;*/
my_class=class_create(THIS_MOCULE,"xu.led");
if(IS_ERR(my_class)){
err=ptr_err(my_class) ;
goto out_class;
class_device_create(my_class,MKDEV(LED_MAJOR,0),NULL,"xu.led"
);
err=devfs_mk_cdev(MKDEV(LED_MAJOR,0),S_IFCHR | S_IRUGO | S_IWUSR,
"xu.led");
if(err)
goto out_class;
for(i=0;i<4;i++){
s3c2410_gpio_cfgpin(led_table,led_table[i+4]);
s3c2410_gpio_setpin(led_table,1); }
printk("led driver initialized\n");
goto out;
out_class:
class_device_destroy(my_class,MKDEV(LED_MAJOR, 0));
class_destroy(my_class);
out_chrdev:
unregister_chrdev(LED_MAJOR, "xu.led");
out:
return 0; }
static void __exit xu_exit(void){
class_device_destroy(my_class,MKDEV(LED_MAJOR, 0));
class_destroy(my_class);
unregister_chrdev(LED_MAJOR,"xu.led");
devfs_remove("xu.led");
printk("xu.led driver removed\n");
}

module_init(xu_init);
module_exit(xu_exit);
error: variable `xu_led' has initializer but incomplete type
LED.c:59: error: unknown field `owner' specified in initializer
error: unknown field `ioctl' specified in initializer
error: `THIS_MOCULE' undeclared (first use in this function)
LED.c:76: error: `S_IRUGO' undeclared (first use in this function)
LED.c:101: error: initializer element is not constant
LED.c:101: error: parse error at end of input
LED.c:58: error: storage size of `xu_led' isn't known
小弟初学者,被这个问题折腾几天了。望师兄指点。
发表于 2007-8-25 22:25:18 | 显示全部楼层
看一下,linux device driver, third edition 吧.
回复 支持 反对

使用道具 举报

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

本版积分规则

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