|  | 
| 亚瑟王 发表于 2012-9-15 18:08  你的驱动有没有添加这个声明:MODULE_LICENSE("GPL");
有的 ,下边是我自己的驱动源码:刚学习驱动不久,代码写的不怎么样,包涵
 刚又试过还是出现同样的问题
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/delay.h>
 #include <linux/poll.h>
 #include <linux/irq.h>
 #include <asm/irq.h>
 #include <linux/interrupt.h>
 #include <asm/uaccess.h>
 #include <mach/regs-gpio.h>
 #include <mach/hardware.h>
 #include <linux/platform_device.h>
 #include <linux/cdev.h>
 #include <linux/miscdevice.h>
 #include <linux/device.h>
 
 #define DEVICE_NAME "butt_led"
 
 static struct class *butt_led_class;
 static struct class_deviced *butt_led_class_dev;
 
 
 static unsigned int gpio_table[]=
 {
 S3C2410_GPB5,
 S3C2410_GPB6,
 S3C2410_GPB7,
 S3C2410_GPB8,
 
 };
 static unsigned int gpio_conf_table[]=
 {
 S3C2410_GPB5_OUTP,
 S3C2410_GPB6_OUTP,
 S3C2410_GPB7_OUTP,
 S3C2410_GPB8_OUTP,
 };
 
 static int butt_led_open (struct inode *inode, struct file *file)
 {
 int i;
 for(i=0;i<4;i++)
 s3c2410_gpio_cfgpin(gpio_table,gpio_conf_table);
 
 printk("but_led open \n");
 return 0;
 }
 
 static int butt_led_ioctl (struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg)
 {
 s3c2410_gpio_setpin(gpio_table[arg],cmd);
 printk("butt_led_ioctl\n");
 return 0;
 }
 
 static struct file_operations butt_led_fops = {
 .owner = THIS_MODULE,
 .open = butt_led_open,
 .ioctl = butt_led_ioctl,
 };
 
 int major;
 static int __init butt_led_init(void)
 {
 major = register_chrdev(0,DEVICE_NAME,&butt_led_fops);
 if(major < 0)
 printk(DEVICE_NAME "can't register butt_led");
 
 butt_led_class = class_create(THIS_MODULE,"butt_led");
 
 butt_led_class_dev = device_create(butt_led_class,NULL,MKDEV(major,0),NULL,"butt_led_dev");
 //printk("major =  %d\n",major);
 return major;
 }
 
 static void __exit butt_led_exit(void)
 {
 unregister_chrdev(major,DEVICE_NAME);
 device_unregister(butt_led_class_dev);
 class_destroy(butt_led_class);
 
 }
 
 module_init(butt_led_init);
 module_exit(butt_led_exit);
 MODULE_LICENSE("GPL");
 另外,编译时总是提示两个警告,也请看看
 make -C /home/a123/lx/linux-2.6.30.4 M=`pwd` modules
 make[1]: Entering directory `/home/a123/lx/linux-2.6.30.4'
 CC [M]  /mnt/hgfs/Ub/but_led/but_led.o
 /mnt/hgfs/Ub/but_led/but_led.c: In function 'butt_led_init':
 /mnt/hgfs/Ub/but_led/but_led.c:72: warning: assignment from incompatible pointer type
 /mnt/hgfs/Ub/but_led/but_led.c: In function 'butt_led_exit':
 /mnt/hgfs/Ub/but_led/but_led.c:80: warning: passing argument 1 of 'device_unregister' from incompatible pointer type
 Building modules, stage 2.
 make[2]: Warning: File `/mnt/hgfs/Ub/but_led/but_led.o' has modification time 1.6 s in the future
 MODPOST 1 modules
 LD [M]  /mnt/hgfs/Ub/but_led/but_led.ko
 make[2]: warning:  Clock skew detected.  Your build may be incomplete.
 make[1]: Leaving directory `/home/a123/lx/linux-2.6.30.4'
 其中72行代码是 butt_led_class_dev = device_create(butt_led_class,NULL,MKDEV(major,0),NULL,"butt_led_dev");
 80行代码是 device_unregister(butt_led_class_dev);
 | 
 |