nfit/ars: Remove ars_start_flags
[linux-2.6-microblaze.git] / fs / eventpoll.c
index 752dbc4..a5d219d 100644 (file)
@@ -1749,6 +1749,7 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events,
 {
        int res = 0, eavail, timed_out = 0;
        u64 slack = 0;
+       bool waiter = false;
        wait_queue_entry_t wait;
        ktime_t expires, *to = NULL;
 
@@ -1794,14 +1795,18 @@ fetch_events:
        ep_reset_busy_poll_napi_id(ep);
 
        /*
-        * We don't have any available event to return to the caller.
-        * We need to sleep here, and we will be wake up by
-        * ep_poll_callback() when events will become available.
+        * We don't have any available event to return to the caller.  We need
+        * to sleep here, and we will be woken by ep_poll_callback() when events
+        * become available.
         */
-       init_waitqueue_entry(&wait, current);
-       spin_lock_irq(&ep->wq.lock);
-       __add_wait_queue_exclusive(&ep->wq, &wait);
-       spin_unlock_irq(&ep->wq.lock);
+       if (!waiter) {
+               waiter = true;
+               init_waitqueue_entry(&wait, current);
+
+               spin_lock_irq(&ep->wq.lock);
+               __add_wait_queue_exclusive(&ep->wq, &wait);
+               spin_unlock_irq(&ep->wq.lock);
+       }
 
        for (;;) {
                /*
@@ -1837,10 +1842,6 @@ fetch_events:
 
        __set_current_state(TASK_RUNNING);
 
-       spin_lock_irq(&ep->wq.lock);
-       __remove_wait_queue(&ep->wq, &wait);
-       spin_unlock_irq(&ep->wq.lock);
-
 send_events:
        /*
         * Try to transfer events to user space. In case we get 0 events and
@@ -1851,6 +1852,12 @@ send_events:
            !(res = ep_send_events(ep, events, maxevents)) && !timed_out)
                goto fetch_events;
 
+       if (waiter) {
+               spin_lock_irq(&ep->wq.lock);
+               __remove_wait_queue(&ep->wq, &wait);
+               spin_unlock_irq(&ep->wq.lock);
+       }
+
        return res;
 }
 
@@ -2183,7 +2190,7 @@ static int do_epoll_wait(int epfd, struct epoll_event __user *events,
                return -EINVAL;
 
        /* Verify that the area passed by the user is writeable */
-       if (!access_ok(VERIFY_WRITE, events, maxevents * sizeof(struct epoll_event)))
+       if (!access_ok(events, maxevents * sizeof(struct epoll_event)))
                return -EFAULT;
 
        /* Get the "struct file *" for the eventpoll file */