Implement poll for events. POLLPRI is used to notify users on incoming events. Signed-off-by: Sakari Ailus <sakari.ailus@xxxxxxxxxxxxxxx> --- drivers/media/media-device.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 0b1ab88..2a9bf80 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -956,6 +956,32 @@ static long media_device_ioctl(struct file *filp, unsigned int cmd, ioctl_info, ARRAY_SIZE(ioctl_info)); } +unsigned int media_device_poll(struct file *filp, struct poll_table_struct *wait) +{ + struct media_device_fh *fh = media_device_fh(filp); + unsigned int poll_events = poll_requested_events(wait); + int ret = 0; + + if (poll_events & (POLLIN | POLLOUT)) + return POLLERR; + + if (poll_events & POLLPRI) { + unsigned long flags; + bool empty; + + spin_lock_irqsave(&fh->kevents.lock, flags); + empty = list_empty(&fh->kevents.head); + spin_unlock_irqrestore(&fh->kevents.lock, flags); + + if (empty) + poll_wait(filp, &fh->kevents.wait, wait); + else + ret |= POLLPRI; + } + + return ret; +} + #ifdef CONFIG_COMPAT struct media_links_enum32 { @@ -1010,6 +1036,7 @@ static const struct media_file_operations media_device_fops = { .owner = THIS_MODULE, .open = media_device_open, .ioctl = media_device_ioctl, + .poll = media_device_poll, #ifdef CONFIG_COMPAT .compat_ioctl = media_device_compat_ioctl, #endif /* CONFIG_COMPAT */ -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html