Commit c1d51dd5 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Peter Zijlstra

usb: gadget: Use completion interface instead of open coding it

ep_io() uses a completion on stack and open codes the waiting with:

  wait_event_interruptible (done.wait, done.done);
and
  wait_event (done.wait, done.done);

This waits in non-exclusive mode for complete(), but there is no reason to
do so because the completion can only be waited for by the task itself and
complete() wakes exactly one exlusive waiter.

Replace the open coded implementation with the corresponding
wait_for_completion*() functions.

No functional change.
Reported-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lkml.kernel.org/r/20200321113241.043380271@linutronix.de
parent deaa0a8a
...@@ -344,7 +344,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len) ...@@ -344,7 +344,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)
spin_unlock_irq (&epdata->dev->lock); spin_unlock_irq (&epdata->dev->lock);
if (likely (value == 0)) { if (likely (value == 0)) {
value = wait_event_interruptible (done.wait, done.done); value = wait_for_completion_interruptible(&done);
if (value != 0) { if (value != 0) {
spin_lock_irq (&epdata->dev->lock); spin_lock_irq (&epdata->dev->lock);
if (likely (epdata->ep != NULL)) { if (likely (epdata->ep != NULL)) {
...@@ -353,7 +353,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len) ...@@ -353,7 +353,7 @@ ep_io (struct ep_data *epdata, void *buf, unsigned len)
usb_ep_dequeue (epdata->ep, epdata->req); usb_ep_dequeue (epdata->ep, epdata->req);
spin_unlock_irq (&epdata->dev->lock); spin_unlock_irq (&epdata->dev->lock);
wait_event (done.wait, done.done); wait_for_completion(&done);
if (epdata->status == -ECONNRESET) if (epdata->status == -ECONNRESET)
epdata->status = -EINTR; epdata->status = -EINTR;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment