[linux-driver] 请教!linux 字符设备驱动程序

70 views
Skip to first unread message

onlyfever

unread,
Apr 19, 2010, 11:26:36 PM4/19/10
to Linux设备驱动开发
请教!如何在当前驱动程序中打开另一个设备。
比如:
static irqreturn_t atmel_interrupt(int irq, void *dev_id)
{
int fd;
fd = open("/dev/buzzer", O_RDWR,1);
if (fd < 0) {
printk("open buzzer error! %d\n", fd);
}
ioctl(fd, IOCTL_BZR_BEEP, 1);
usleep(1000*100);
ioctl(fd, IOCTL_BZR_BEEP, 0);
close(fd);
return IRQ_HANDLED;
}

这样编译会出现错误:
implicit declaration of function 'open'
implicit declaration of function 'ioctl'
implicit declaration of function 'usleep'
implicit declaration of function 'close'

--
_______________________________________________
Linux设备驱动开发邮件列表 linux...@googlegroups.com
http://groups.google.gr/group/linuxdriver?hl=zh-CN
退订请使用原订阅邮箱发邮件至:linuxdriver...@googlegroups.com

Barry Song

unread,
Apr 20, 2010, 12:50:39 AM4/20/10
to linux...@googlegroups.com
你应该做的不是提问,你要读的书太多了。

2010/4/20 onlyfever <only...@gmail.com>:

孤云独闲

unread,
Apr 20, 2010, 1:28:56 AM4/20/10
to linux...@googlegroups.com
宋老师:
    你是不是可以把你翻译的<<Essential linux Device driver>>最后几章也贴上你的博客啊,让我们先睹为快啊, 等你的书太漫长咯!看英文档有点困难,很是不能理解其意.

Best Regards,
tomsun

yuanwei2088

unread,
Oct 4, 2012, 9:54:00 PM10/4/12
to linuxdriver, onlyfever
很明显 你这个错误提示你函数没声明。找不到你用的函数。
 

 
 
发件人: frank li
发送时间: 2012-09-07 13:34
收件人: linuxdriver
抄送: onlyfever
主题: Re: [linux-driver] 请教!linux 字符设备驱动程序
同样的问题

在 2010年4月20日星期二UTC+8上午11时26分36秒,onlyfever写道:
退订请使用原订阅邮箱发邮件至:linuxdriver+unsub...@googlegroups.com

陈生

unread,
Oct 5, 2012, 5:01:24 AM10/5/12
to linuxdriver
要么在内核发送信息给应用层,然后应用层像你这样子打开文件,或者其他办法。
open close ioctl都是应用层使用的,不是内核使用的。


在2012-10-05,"yuanwei2088" <yuanw...@gmail.com> 写道:
-----原始邮件-----
发件人:"yuanwei2088" <yuanw...@gmail.com>
发送时间:2012年10月5日 星期五
收件人:"linuxdriver" <linux...@googlegroups.com>;"linuxdriver" <linux...@googlegroups.com>
抄送:"onlyfever" <only...@gmail.com>
主题:回复: Re: [linux-driver] 请教!linux 字符设备驱动程序
退订请使用原订阅邮箱发邮件至:linuxdriver+unsub...@googlegroups.com


xiewen202

unread,
Oct 9, 2012, 3:22:02 AM10/9/12
to linuxdriver
可以使用sys_open,sys_close等,请不要模块编译
 
2012-10-09

xiewen202

发件人:陈生
发送时间:2012-10-05 23:08
主题:Re:回复: Re: [linux-driver] 请教!linux 字符设备驱动程序
收件人:"linuxdriver"<linux...@googlegroups.com>
抄送:
 
退订请使用原订阅邮箱发邮件至:linuxdriver...@googlegroups.com

Barry Song

unread,
Oct 17, 2012, 9:39:50 AM10/17/12
to linux...@googlegroups.com
<<Essential linux Device driver>>中文版不是早就市面上卖了吗?为什么还要等,你如果要的话,我可以发给你完整电子版。

-barry   新浪微博 @宋宝华Barry 

Barry Song

unread,
Oct 17, 2012, 9:41:20 AM10/17/12
to linux...@googlegroups.com
你为什么在kernel,而且在中断服务程序里面访问提供给userspace的interface?你可能要理解系统调用的过程。

-barry   新浪微博 @宋宝华Barry 
Reply all
Reply to author
Forward
0 new messages