static struct fasync_struct *button_async;
static int fifth_drv_fasync (int fd, struct file *filp, int on)
{
return fasync_helper (fd, filp, on, &button_async); // 主要用于初始化button_async
}
/*
* fasync_helper() is used by some character device drivers (mainly mice)
* to set up the fasync queue. It returns negative on error, 0 if it did
* no changes and positive if it added/deleted the entry.
*/
int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fapp)
{
struct fasync_struct *fa, **fp;
struct fasync_struct *new = NULL;
int result = 0;
if (on) {
new = kmem_cache_alloc(fasync_cache, GFP_KERNEL);

这篇博客详细介绍了Linux内核中用于字符设备驱动的异步通知机制,包括fasync_helper函数的使用,它用于初始化fasync_queue,以及kill_fasync函数,用于发送SIGIO信号到应用层。通过fcntl设置FASYNC标志,当设备状态改变时,驱动会调用.fasync方法,实现异步通知。
最低0.47元/天 解锁文章
6700

被折叠的 条评论
为什么被折叠?



