expected declaration specifiers or ‘...’ before ‘poll_table’
在写字符驱动的时候遇到这样的问题:
头文件
1 #include <linux/module.h>
2 #include <linux/types.h>
3 #include <linux/fs.h>
4 #include <linux/errno.h>
5 #include <linux/mm.h>
6 #include <linux/sched.h>
7 #include <linux/init.h>
8 #include <linux/cdev.h>
9 #include <asm/io.h>
10 #include <asm/system.h>
11 #include <asm/uaccess.h>
12 #include <asm/io.h>
13
14 #define GLOBALFIFO_SIZE 0x1000
15 #define MEM_CLEAR 0x1
16 #define GLOBALFIFO_MAJOR 250
其中的poll函数实现如下:
static unsigned int
184 globalfifo_poll(struct file *filp, poll_table *wait)
185 {
186 unsigned int mask = 0;
187 struct globalfifo_dev *dev = filp->private_data;
188 down(&dev->sem);
189
190 poll_wait(filp,&dev->r_wait,wait);
191 poll_wait(filp,&dev->w_wait,wait);
192
193 if (dev->current_len != 0)
194 mask |= POLLIN | POLLRDNORM;
195 if (dev->current_len != GLOBALFIFO_SIZE)
196 mask |= POLLOUT | POLLWRNORM;
197
198 up(&dev->sem);
199 return mask;
200 }
file_operations 实现如下:
static const struct file_operations globalfifo_fops = {
203 .owner = THIS_MODULE,
204 .llseek = globalfifo_llseek,
205 .read = globalfifo_read,
206 .write = globalfifo_write,
207 .ioctl = globalfifo_ioctl,
208 .poll = globalfifo_poll,
209 .open = globalfifo_open,
210 .release = globalfifo_release,
211 };
在没有写poll之前我这个驱动能够加载和运行。