gpiodrv.c 代码如下: #include <linux/config.h> #include <linux/init.h> #include <linux/module.h> #include <linux/fs.h> #include <linux/iobuf.h> #include <linux/kernel.h> #include <linux/major.h> #include <asm/uaccess.h> #include <asm/io.h> #include <linux/vmalloc.h> #define IOPORT_MAJOR 220 #define GPFCON (*(volatile unsigned *)0x56000050) #define GPFDAT (*(volatile unsigned *)0x56000054) #define GPFUP (*(volatile unsigned *)0x56000058) int gpio_open(struct inode *, struct file*); int gpio_release(struct inode*, struct file*); int gpio_ctl_ioctl(struct inode *, struct file*, unsigned int, unsigned long); static struct file_operations gpio_ctl_fops = { ioctl : gpio_ctl_ioctl, open : gpio_open, release : gpio_release, }; #define LED1_ON() (GPFDAT &= ~0X10) #define LED1_OFF() (GPFDAT |= 0X10) #define LED2_ON() (GPFDAT &= ~0X20) #define LED2_OFF() (GPFDAT |= 0X20) #define LED3_ON() (GPFDAT &= ~0X40) #define LED3_OFF() (GPFDAT |= 0X40) #define LED4_ON() (GPFDAT &= ~0X80) #define LED4_OFF() (GPFDAT |= 0X80) static int LedStatus; void LedSet(int led) { LedStatus = led; if(LedStatus & 0x01) LED1_ON(); else LED1_OFF(); }
void LedDisp(void) { udelay(0x500000); LedSet(0x02); udelay(0x500000); LedSet(0x01);
}
static int __init gpio_init(void) { int err = 0; printk("gpio inint\n"); err = register_chrdev(IOPORT_MAJOR, "gpio", &gpio_ctl_fops); if(err) { printk("fail to register\n"); return -1; } printk("success to register \n"); return 0; } int gpio_open(struct inode* inode, struct file* fllp) { GPFCON = 0X5500; GPFUP = 0XFF; printk("open gpio devices\n"); return 0; } int gpio_release(struct inode *inode, struct file* fillp) { printk("release this device\n"); return 0; } int gpio_ctl_ioctl(struct inode *inode, struct file *flip,unsigned \ int command, unsigned long arg) { int err =0; if(command == 1) { while(arg--) { LedDisp(); printk("......"); } printk("\n"); return 0; } return err; }
module_init(gpio_init); module_exit(gpio_release);
我的编译方法是:arm-linux-gcc -O2 -DMODULE -D__KERNEL__ -c gpiodrv.c 提示如下: gpiodrv.c: In function `__cleanup_module_inline': gpiodrv.c:113: warning: return from incompatible pointer type
请问哪里出了问题,我看了半天也没看出问题出来,谢谢高手指教。
|