2320|1

77

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

求助:关于驱动test编译问题,肯请高手帮忙。急用,万分感谢! [复制链接]

make 后的错误信息如下:
[root@localhost test]# make
gcc -Wall -DMODULE -D__KERNEL__ -DLINUX -I/usr/src/linux-2.4.20-8/include -c test.c
test.c: In function `read_test':
test.c:14: warning: implicit declaration of function `verify_area'
test.c:14: `VERIFY_WRITE' undeclared (first use in this function)
test.c:14: (Each undeclared identifier is reported only once
test.c:14: for each function it appears in.)
test.c:19: warning: implicit declaration of function `__put_user'
test.c:20: warning: statement with no effect
test.c: In function `open_tibet':
test.c:32: `MOD_INC_USE_COUNT' undeclared (first use in this function)
test.c: In function `release_tibet':
test.c:37: `MOD_DEC_USE_COUNT' undeclared (first use in this function)
test.c: At top level:
test.c:42: warning: initialization from incompatible pointer type
test.c:43: `write_test' undeclared here (not in a function)
test.c:43: initializer element is not constant
test.c:43: (near initialization for `test_fops.write')
test.c:48: `open_test' undeclared here (not in a function)
test.c:48: initializer element is not constant
test.c:48: (near initialization for `test_fops.open')
test.c:49: `release_test' undeclared here (not in a function)
test.c:49: initializer element is not constant
test.c:49: (near initialization for `test_fops.release')
test.c:27: warning: `write_tibet' defined but not used
test.c:31: warning: `open_tibet' defined but not used
test.c:36: warning: `release_tibet' defined but not used
make: *** [test.o] Error 1
========================================================================
我makefile 如下:
C=gcc
MODCFLAGS:=-Wall -DMODULE -D__KERNEL__ -DLINUX -I/usr/src/linux-2.4.20-8/include
test.o:test.c
$(CC) $(MODCFLAGS) -c test.c
========================================================================
我的C源程序如下:
#include
#include
#include
#include
#include
unsigned int test_major = 0;

static int read_test(struct inode *node, struct file *file,
char *buf, int count)
{

int left;

if (verify_area(VERIFY_WRITE,buf,count) == -EFAULT )
return -EFAULT;

for(left = count ; left > 0 ; left--)
{
__put_user(1, buf, 1);
buf ;
}
return count;
}
/********************************************************************/
static int write_tibet(struct inode *inode, struct file *file,
const char *buf, int count)
{
return count;
}
static int open_tibet(struct inode *inode, struct file *file )
{
MOD_INC_USE_COUNT;
return 0;
}
static void release_tibet(struct inode *inode, struct file *file )
{
MOD_DEC_USE_COUNT;
}
/********************************************************************/
struct file_operations test_fops = {
NULL,
read:read_test,
write:write_test,
NULL, /* test_readdir */
NULL,
NULL, /* test_ioctl */
NULL, /* test_mmap */
open:open_test,
release:release_test, NULL, /* test_fsync */
NULL, /* test_fasync */
/* nothing more£¬ fill with NULLs */
};
/******************************************************************/
int init_module(void)
{
int result;
result = register_chrdev(0, "test", &test_fops);
if (result < 0) {
printk(KERN_INFO "test: can't get major number\n");
return result;
}
if (test_major == 0){
test_major = result; /* dynamic */
return 0;
}
}
=========================================================================
不知是什么原因,恳请高手帮忙,多谢了!

最新回复

struct file_operations test_fops = { NULL, read:read_test, write:write_test, NULL, /* test_readdir */ NULL, NULL, /* test_ioctl */ NULL, /* test_mmap */ open:open_test, release:release_test, NULL, /* test_fsync */ NULL, /* test_fasync */ /* nothing more£¬ fill with NULLs */ }; 这个结构中: read:read_test, write:write_test, open:open_test, release:release_test, NULL 没有open_tibet等带_tibet的函数 要将open_tibet等中的_tibet的改为_test  详情 回复 发表于 2007-3-6 15:19
点赞 关注

回复
举报

72

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
struct file_operations test_fops = {
NULL,
read:read_test,
write:write_test,
NULL, /* test_readdir */
NULL,
NULL, /* test_ioctl */
NULL, /* test_mmap */
open:open_test,
release:release_test, NULL, /* test_fsync */
NULL, /* test_fasync */
/* nothing more£¬ fill with NULLs */
};
这个结构中:
read:read_test,
write:write_test,
open:open_test,
release:release_test, NULL

没有open_tibet等带_tibet的函数
要将open_tibet等中的_tibet的改为_test
 
 

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

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/9 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表