mfd: dln2: 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.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Sebastian Andrzej Siewior 2018-07-02 09:31:32 +02:00 committed by Lee Jones
parent f99fea9497
commit 50d44f82c7

View File

@ -194,6 +194,7 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
struct device *dev = &dln2->interface->dev; struct device *dev = &dln2->interface->dev;
struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle]; struct dln2_mod_rx_slots *rxs = &dln2->mod_rx_slots[handle];
struct dln2_rx_context *rxc; struct dln2_rx_context *rxc;
unsigned long flags;
bool valid_slot = false; bool valid_slot = false;
if (rx_slot >= DLN2_MAX_RX_SLOTS) if (rx_slot >= DLN2_MAX_RX_SLOTS)
@ -201,18 +202,13 @@ static bool dln2_transfer_complete(struct dln2_dev *dln2, struct urb *urb,
rxc = &rxs->slots[rx_slot]; rxc = &rxs->slots[rx_slot];
/* spin_lock_irqsave(&rxs->lock, flags);
* No need to disable interrupts as this lock is not taken in interrupt
* context elsewhere in this driver. This function (or its callers) are
* also not exported to other modules.
*/
spin_lock(&rxs->lock);
if (rxc->in_use && !rxc->urb) { if (rxc->in_use && !rxc->urb) {
rxc->urb = urb; rxc->urb = urb;
complete(&rxc->done); complete(&rxc->done);
valid_slot = true; valid_slot = true;
} }
spin_unlock(&rxs->lock); spin_unlock_irqrestore(&rxs->lock, flags);
out: out:
if (!valid_slot) if (!valid_slot)