diff options
author | Christian Gromm <christian.gromm@microchip.com> | 2016-08-19 11:12:55 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-08-21 16:53:57 +0200 |
commit | cf6a599ef700914d9237f4dcf7afe01dd2ca6368 (patch) | |
tree | 59a5ca4e26904d9b977ad7f56358ac6ee1b6483d /drivers/staging/most | |
parent | bf9503f11dedf40158a8a5847f2d482bc15cd82b (diff) |
staging: most: hdm-usb: assign spinlock to local variable
This patch assigns the spinlock of struct mdev to local spinlock_t
variable to get rid of all the ugly dereferencing.
Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/most')
-rw-r--r-- | drivers/staging/most/hdm-usb/hdm_usb.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/staging/most/hdm-usb/hdm_usb.c b/drivers/staging/most/hdm-usb/hdm_usb.c index 8d8c72c0fbf2..4156a30d0f41 100644 --- a/drivers/staging/most/hdm-usb/hdm_usb.c +++ b/drivers/staging/most/hdm-usb/hdm_usb.c @@ -206,14 +206,15 @@ static void free_anchored_buffers(struct most_dev *mdev, unsigned int channel, { struct mbo *mbo; struct buf_anchor *anchor, *tmp; + spinlock_t *lock = mdev->anchor_list_lock + channel; /* temp. lock */ unsigned long flags; - spin_lock_irqsave(&mdev->anchor_list_lock[channel], flags); + spin_lock_irqsave(lock, flags); list_for_each_entry_safe(anchor, tmp, &mdev->anchor_list[channel], list) { struct urb *urb = anchor->urb; - spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + spin_unlock_irqrestore(lock, flags); if (likely(urb)) { mbo = urb->context; if (!irqs_disabled()) { @@ -229,11 +230,11 @@ static void free_anchored_buffers(struct most_dev *mdev, unsigned int channel, } usb_free_urb(urb); } - spin_lock_irqsave(&mdev->anchor_list_lock[channel], flags); + spin_lock_irqsave(lock, flags); list_del(&anchor->list); kfree(anchor); } - spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + spin_unlock_irqrestore(lock, flags); } /** @@ -397,12 +398,14 @@ static void hdm_write_completion(struct urb *urb) struct device *dev; unsigned int channel; unsigned long flags; + spinlock_t *lock; /* temp. lock */ mbo = urb->context; anchor = mbo->priv; mdev = to_mdev(mbo->ifp); channel = mbo->hdm_channel_id; dev = &mdev->usb_device->dev; + lock = mdev->anchor_list_lock + channel; if ((urb->status == -ENOENT) || (urb->status == -ECONNRESET) || (!mdev->is_channel_healthy[channel])) { @@ -433,9 +436,9 @@ static void hdm_write_completion(struct urb *urb) mbo->processed_length = urb->actual_length; } - spin_lock_irqsave(&mdev->anchor_list_lock[channel], flags); + spin_lock_irqsave(lock, flags); list_del(&anchor->list); - spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + spin_unlock_irqrestore(lock, flags); kfree(anchor); if (likely(mbo->complete)) @@ -559,12 +562,14 @@ static void hdm_read_completion(struct urb *urb) struct device *dev; unsigned long flags; unsigned int channel; + spinlock_t *lock; /* temp. lock */ mbo = urb->context; anchor = mbo->priv; mdev = to_mdev(mbo->ifp); channel = mbo->hdm_channel_id; dev = &mdev->usb_device->dev; + lock = mdev->anchor_list_lock + channel; if ((urb->status == -ENOENT) || (urb->status == -ECONNRESET) || (!mdev->is_channel_healthy[channel])) { @@ -601,9 +606,9 @@ static void hdm_read_completion(struct urb *urb) mbo->status = MBO_E_INVAL; } } - spin_lock_irqsave(&mdev->anchor_list_lock[channel], flags); + spin_lock_irqsave(lock, flags); list_del(&anchor->list); - spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + spin_unlock_irqrestore(lock, flags); kfree(anchor); if (likely(mbo->complete)) @@ -638,6 +643,7 @@ static int hdm_enqueue(struct most_interface *iface, int channel, unsigned long flags; unsigned long length; void *virt_address; + spinlock_t *lock; /* temp. lock */ if (unlikely(!iface || !mbo)) return -EIO; @@ -697,9 +703,10 @@ static int hdm_enqueue(struct most_interface *iface, int channel, } urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; - spin_lock_irqsave(&mdev->anchor_list_lock[channel], flags); + lock = mdev->anchor_list_lock + channel; + spin_lock_irqsave(lock, flags); list_add_tail(&anchor->list, &mdev->anchor_list[channel]); - spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + spin_unlock_irqrestore(lock, flags); retval = usb_submit_urb(urb, GFP_KERNEL); if (retval) { @@ -709,9 +716,9 @@ static int hdm_enqueue(struct most_interface *iface, int channel, return 0; _error_1: - spin_lock_irqsave(&mdev->anchor_list_lock[channel], flags); + spin_lock_irqsave(lock, flags); list_del(&anchor->list); - spin_unlock_irqrestore(&mdev->anchor_list_lock[channel], flags); + spin_unlock_irqrestore(lock, flags); kfree(anchor); _error: usb_free_urb(urb); |