当前位置: 技术问答>linux和unix
expected declaration specifiers or ‘...’ before ‘poll_table’
来源: 互联网 发布时间:2016-11-19
本文导语: 在写字符驱动的时候遇到这样的问题: 头文件 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 14 #...
在写字符驱动的时候遇到这样的问题:
头文件
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
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之前我这个驱动能够加载和运行。
头文件
1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
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之前我这个驱动能够加载和运行。
|
好像是少了头文件,加上这个再试试
#include
#include