Skip to content

Commit

Permalink
IB/ucm: Simplify ib_ucm_event()
Browse files Browse the repository at this point in the history
Use wait_event_interruptible() instead of a more complicated
open-coded equivalent.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
  • Loading branch information
Sean Hefty authored and Roland Dreier committed Apr 24, 2007
1 parent d92f764 commit 9d41b7f
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions drivers/infiniband/core/ucm.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,29 +407,18 @@ static ssize_t ib_ucm_event(struct ib_ucm_file *file,

mutex_lock(&file->file_mutex);
while (list_empty(&file->events)) {
mutex_unlock(&file->file_mutex);

if (file->filp->f_flags & O_NONBLOCK) {
result = -EAGAIN;
break;
}
if (file->filp->f_flags & O_NONBLOCK)
return -EAGAIN;

if (signal_pending(current)) {
result = -ERESTARTSYS;
break;
}
if (wait_event_interruptible(file->poll_wait,
!list_empty(&file->events)))
return -ERESTARTSYS;

prepare_to_wait(&file->poll_wait, &wait, TASK_INTERRUPTIBLE);

mutex_unlock(&file->file_mutex);
schedule();
mutex_lock(&file->file_mutex);

finish_wait(&file->poll_wait, &wait);
}

if (result)
goto done;

uevent = list_entry(file->events.next, struct ib_ucm_event, file_list);

if (ib_ucm_new_cm_id(uevent->resp.event)) {
Expand Down

0 comments on commit 9d41b7f

Please sign in to comment.