}
 EXPORT_SYMBOL_GPL(v4l2_m2m_streamoff);
 
-__poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
-                          struct poll_table_struct *wait)
+static __poll_t v4l2_m2m_poll_for_data(struct file *file,
+                                      struct v4l2_m2m_ctx *m2m_ctx,
+                                      struct poll_table_struct *wait)
 {
-       struct video_device *vfd = video_devdata(file);
-       __poll_t req_events = poll_requested_events(wait);
        struct vb2_queue *src_q, *dst_q;
        struct vb2_buffer *src_vb = NULL, *dst_vb = NULL;
        __poll_t rc = 0;
        poll_wait(file, &src_q->done_wq, wait);
        poll_wait(file, &dst_q->done_wq, wait);
 
-       if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
-               struct v4l2_fh *fh = file->private_data;
-
-               poll_wait(file, &fh->wait, wait);
-               if (v4l2_event_pending(fh))
-                       rc = EPOLLPRI;
-               if (!(req_events & (EPOLLOUT | EPOLLWRNORM | EPOLLIN | EPOLLRDNORM)))
-                       return rc;
-       }
-
        /*
         * There has to be at least one buffer queued on each queued_list, which
         * means either in driver already or waiting for driver to claim it
        if ((!src_q->streaming || src_q->error ||
             list_empty(&src_q->queued_list)) &&
            (!dst_q->streaming || dst_q->error ||
-            list_empty(&dst_q->queued_list))) {
-               rc |= EPOLLERR;
-               goto end;
-       }
+            list_empty(&dst_q->queued_list)))
+               return EPOLLERR;
 
        spin_lock_irqsave(&dst_q->done_lock, flags);
        if (list_empty(&dst_q->done_list)) {
                 */
                if (dst_q->last_buffer_dequeued) {
                        spin_unlock_irqrestore(&dst_q->done_lock, flags);
-                       return rc | EPOLLIN | EPOLLRDNORM;
+                       return EPOLLIN | EPOLLRDNORM;
                }
        }
        spin_unlock_irqrestore(&dst_q->done_lock, flags);
                rc |= EPOLLIN | EPOLLRDNORM;
        spin_unlock_irqrestore(&dst_q->done_lock, flags);
 
-end:
+       return rc;
+}
+
+__poll_t v4l2_m2m_poll(struct file *file, struct v4l2_m2m_ctx *m2m_ctx,
+                      struct poll_table_struct *wait)
+{
+       struct video_device *vfd = video_devdata(file);
+       __poll_t req_events = poll_requested_events(wait);
+       __poll_t rc = 0;
+
+       if (req_events & (EPOLLOUT | EPOLLWRNORM | EPOLLIN | EPOLLRDNORM))
+               rc = v4l2_m2m_poll_for_data(file, m2m_ctx, wait);
+
+       if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) {
+               struct v4l2_fh *fh = file->private_data;
+
+               poll_wait(file, &fh->wait, wait);
+               if (v4l2_event_pending(fh))
+                       rc |= EPOLLPRI;
+       }
+
        return rc;
 }
 EXPORT_SYMBOL_GPL(v4l2_m2m_poll);