poll_wait()¶
Purpose¶
poll_wait() connects a driver's wait queue to the kernel poll infrastructure. It allows poll, select, and epoll to wait for driver readiness.
Prototype Pattern¶
static __poll_t mydev_poll(struct file *file, poll_table *wait)
{
poll_wait(file, &dev->wq, wait);
if (data_available(dev))
return EPOLLIN | EPOLLRDNORM;
return 0;
}
Important Concept¶
poll_wait() does not check readiness. It only registers the wait queue. The driver must still return a readiness mask based on current state.
Readiness Masks¶
| Mask | Meaning |
|---|---|
EPOLLIN |
Data is available to read |
EPOLLRDNORM |
Normal readable data is available |
EPOLLOUT |
Device can accept write data |
EPOLLERR |
Error condition |
EPOLLHUP |
Hangup condition |