Commit 8982c844 authored by John Ogness's avatar John Ogness Committed by Greg Kroah-Hartman

usb: usb-skeleton: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.
Signed-off-by: default avatarJohn Ogness <john.ogness@linutronix.de>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0f5f7ace
...@@ -159,10 +159,11 @@ static int skel_flush(struct file *file, fl_owner_t id) ...@@ -159,10 +159,11 @@ static int skel_flush(struct file *file, fl_owner_t id)
static void skel_read_bulk_callback(struct urb *urb) static void skel_read_bulk_callback(struct urb *urb)
{ {
struct usb_skel *dev; struct usb_skel *dev;
unsigned long flags;
dev = urb->context; dev = urb->context;
spin_lock(&dev->err_lock); spin_lock_irqsave(&dev->err_lock, flags);
/* sync/async unlink faults aren't errors */ /* sync/async unlink faults aren't errors */
if (urb->status) { if (urb->status) {
if (!(urb->status == -ENOENT || if (!(urb->status == -ENOENT ||
...@@ -177,7 +178,7 @@ static void skel_read_bulk_callback(struct urb *urb) ...@@ -177,7 +178,7 @@ static void skel_read_bulk_callback(struct urb *urb)
dev->bulk_in_filled = urb->actual_length; dev->bulk_in_filled = urb->actual_length;
} }
dev->ongoing_read = 0; dev->ongoing_read = 0;
spin_unlock(&dev->err_lock); spin_unlock_irqrestore(&dev->err_lock, flags);
wake_up_interruptible(&dev->bulk_in_wait); wake_up_interruptible(&dev->bulk_in_wait);
} }
...@@ -331,6 +332,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count, ...@@ -331,6 +332,7 @@ static ssize_t skel_read(struct file *file, char *buffer, size_t count,
static void skel_write_bulk_callback(struct urb *urb) static void skel_write_bulk_callback(struct urb *urb)
{ {
struct usb_skel *dev; struct usb_skel *dev;
unsigned long flags;
dev = urb->context; dev = urb->context;
...@@ -343,9 +345,9 @@ static void skel_write_bulk_callback(struct urb *urb) ...@@ -343,9 +345,9 @@ static void skel_write_bulk_callback(struct urb *urb)
"%s - nonzero write bulk status received: %d\n", "%s - nonzero write bulk status received: %d\n",
__func__, urb->status); __func__, urb->status);
spin_lock(&dev->err_lock); spin_lock_irqsave(&dev->err_lock, flags);
dev->errors = urb->status; dev->errors = urb->status;
spin_unlock(&dev->err_lock); spin_unlock_irqrestore(&dev->err_lock, flags);
} }
/* free up our allocated buffer */ /* free up our allocated buffer */
......
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