led驱动编绎能不过?
时间:2010-07-28
来源:互联网
编绎器版本:arm-linux-gcc 2.9.5
内核版本:2.6.12
Make时出错如下提示,请高手指点。
复制代码
内核版本:2.6.12
Make时出错如下提示,请高手指点。
- S3C2440_LEDS.C
-
- #include <linux/config.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/fs.h>
- #include <linux/init.h>
- #include <linux/devfs_fs_kernel.h>
- #include <linux/miscdevice.h>
- #include <linux/delay.h>
- #include <asm/irq.h>
- #include <asm/arch/regs-gpio.h>
- #include <asm/hardware.h>
-
-
- #define DEVICE_NAME "leds" //定义设备名
- #define LED_MAJOR 231 //手动定义主设备号
-
- //定义要操作的设备,把每一个led作为结构体的一个成员
- static unsigned long led_table [] = {
- S3C2410_GPF3,
- S3C2410_GPF4,
- S3C2410_GPF5,
- S3C2410_GPF6,
- S3C2410_GPF7,
-
- };
-
- //对设备进行设置,结构体的每一个成员是对对应led的设置
- static unsigned int led_cfg_table [] = {
- S3C2410_GPF3_OUTP,
- S3C2410_GPF4_OUTP,
- S3C2410_GPF5_OUTP,
- S3C2410_GPF6_OUTP,
- S3C2410_GPF7_OUTP,
-
- };
- static struct cdev *cd=NULL;
- //设备驱动程序中对设备的I/O通道进行管理的函数,用来实现对led的操作
- static int s3c2440_leds_ioctl(
- struct inode *inode,
- struct file *file,
- unsigned int cmd,
- unsigned long arg)
- {
- switch(cmd) {
- case 0:
- case 1:
- if (arg > 4) {
- return -EINVAL;
- }
- s3c2410_gpio_setpin(led_table[arg], !cmd);
- return 0;
- default:
- return -EINVAL;
- }
- }
- static struct file_operations s3c2440_leds_fops = {
- .owner = THIS_MODULE,
- .ioctl = s3c2440_leds_ioctl,
- };
-
- //模块加载函数
- static int s3c2440_leds_init(void)
- {
- int ret;
- int i;
- int result;
-
- dev_t devno = MKDEV(LED_MAJOR, 0);
- //注册设备号
-
- result = register_chrdev_region(devno, 1, DEVICE_NAME);
- if(result<0)
- {
- printk(DEVICE_NAME " initialized fail :device num busy\n");
- return result;
- }
-
- cd =cdev_alloc();
- if(cd==NULL)
- {
- printk(KERN_NOTICE "CDEV_ALLOC ERROR");
-
- unregister_chrdev_region(MKDEV(LED_MAJOR, 0), 1);
- return -20;
- }
- cdev_init(cd, &s3c2440_leds_fops);
- cd->owner = THIS_MODULE;
- cd->ops = &s3c2440_leds_fops;
- ret = cdev_add(cd, devno, 1);
- if (ret)
- {
- printk(KERN_NOTICE "CDEV_ADD LED ERROR");
- kfree(cd);
- unregister_chrdev_region(MKDEV(LED_MAJOR, 0), 1);
- return -10;
- }
-
-
- devfs_mk_cdev(MKDEV(LED_MAJOR, 0), S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP, DEVICE_NAME);
-
- for (i = 0; i < 5; i++) {
- s3c2410_gpio_cfgpin(led_table[i], led_cfg_table[i]);
- s3c2410_gpio_setpin(led_table[i], 1);
- }
-
- printk(DEVICE_NAME " initialized OK\n");
- return 0;
- }
-
- //模块卸载函数
- static void s3c2440_leds_exit(void)
- {
- devfs_remove(DEVICE_NAME);
- cdev_del(cd);
- unregister_chrdev_region(MKDEV(LED_MAJOR, 0), 1);
-
- }
-
-
- //MODULE_AUTHOR("HeLun);
- MODULE_LICENSE("Dual BSD/GPL");
-
-
-
- module_init(s3c2440_leds_init);
- module_exit(s3c2440_leds_exit);
- Makefile
- obj-m :=s3c2440_leds.o
- KERNELDIR := /helun/driver/linux-2.6.12
- default:
- make -C $(KERNELDIR) M=$(shell pwd) modules
- install:
- insmod s3c2440_leds.ko
- uninstall:
- rmmod s3c2440_leds.ko
- clean:
- make -C $(KERNELDIR) M=$(shell pwd) clean
-
- 编绎出错:
- >make
- make -C /helun/driver/linux-2.6.12 M=/helun/driver/led_Helun modules
- make[1]: Entering directory `/helun/driver/linux-2.6.12'
- CC [M] /helun/driver/led_Helun/s3c2440_leds.o
- /helun/driver/led_Helun/s3c2440_leds.c: In function `s3c2440_leds_init':
- /helun/driver/led_Helun/s3c2440_leds.c:78: warning: implicit declaration of function `cdev_alloc'
- /helun/driver/led_Helun/s3c2440_leds.c:78: warning: assignment makes pointer from integer without a cast
- /helun/driver/led_Helun/s3c2440_leds.c:86: warning: implicit declaration of function `cdev_init'
- /helun/driver/led_Helun/s3c2440_leds.c:87: dereferencing pointer to incomplete type
- /helun/driver/led_Helun/s3c2440_leds.c:88: dereferencing pointer to incomplete type
- /helun/driver/led_Helun/s3c2440_leds.c:89: warning: implicit declaration of function `cdev_add'
- /helun/driver/led_Helun/s3c2440_leds.c: In function `s3c2440_leds_exit':
- /helun/driver/led_Helun/s3c2440_leds.c:114: warning: implicit declaration of function `cdev_del'
- make[2]: *** [/helun/driver/led_Helun/s3c2440_leds.o] 错误 1
- make[1]: *** [_module_/helun/driver/led_Helun] 错误 2
- make[1]: Leaving directory `/helun/driver/linux-2.6.12'
作者: helun 发布时间: 2010-07-28
提示信息中有一些Warnig,解决了先。
作者: Godbach 发布时间: 2010-07-28
看样子好像是s3c2440_leds_init里面参数有误
作者: 0vk0 发布时间: 2010-07-28
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28