Linux下CPLD驅(qū)動程序
static unsigned cpld_drv_poll(struct file *file, poll_table *wait)
{
unsigned int mask = 0;
poll_wait(file, eint1_waitq, wait); //不會立即休眠
if (ev_eint1)
mask |= POLLIN | POLLRDNORM; //若產(chǎn)生中斷,mask賦值,表示有數(shù)據(jù)可讀
return mask;
}
static int cpld_drv_fasync (int fd, struct file *filp, int on)
{
//printk(driver: cpld_drv_fasyncn);
return fasync_helper (fd, filp, on, eint1_async);
}
int cpld_drv_close(struct inode *inode, struct file *file)
{
free_irq(IRQ_EINT1, 1); //釋放中斷
return 0;
}
static struct file_operations cpld_drv_fops = {
.owner = THIS_MODULE,
.write = cpld_drv_write,
.read = cpld_drv_read,
.open = cpld_drv_open,
.release = cpld_drv_close,
.poll = cpld_drv_poll,
.fasync = cpld_drv_fasync,
};
評論