Commit 809a58b8 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

USB: change name of spinlock in hcd.c

This patch (as940 renames hcd_data_lock in hcd.c to hcd_urb_list_lock,
which is more descriptive of the lock's job.  It also introduces a
convenient inline routine for testing whether a particular USB device
is a root hub.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 32aca560
...@@ -99,12 +99,17 @@ EXPORT_SYMBOL_GPL (usb_bus_list_lock); ...@@ -99,12 +99,17 @@ EXPORT_SYMBOL_GPL (usb_bus_list_lock);
/* used for controlling access to virtual root hubs */ /* used for controlling access to virtual root hubs */
static DEFINE_SPINLOCK(hcd_root_hub_lock); static DEFINE_SPINLOCK(hcd_root_hub_lock);
/* used when updating hcd data */ /* used when updating an endpoint's URB list */
static DEFINE_SPINLOCK(hcd_data_lock); static DEFINE_SPINLOCK(hcd_urb_list_lock);
/* wait queue for synchronous unlinks */ /* wait queue for synchronous unlinks */
DECLARE_WAIT_QUEUE_HEAD(usb_kill_urb_queue); DECLARE_WAIT_QUEUE_HEAD(usb_kill_urb_queue);
static inline int is_root_hub(struct usb_device *udev)
{
return (udev->parent == NULL);
}
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
/* /*
...@@ -906,14 +911,13 @@ EXPORT_SYMBOL (usb_calc_bus_time); ...@@ -906,14 +911,13 @@ EXPORT_SYMBOL (usb_calc_bus_time);
static void urb_unlink(struct usb_hcd *hcd, struct urb *urb) static void urb_unlink(struct usb_hcd *hcd, struct urb *urb)
{ {
unsigned long flags; unsigned long flags;
int at_root_hub = (urb->dev == hcd->self.root_hub);
/* clear all state linking urb to this dev (and hcd) */ /* clear all state linking urb to this dev (and hcd) */
spin_lock_irqsave (&hcd_data_lock, flags); spin_lock_irqsave(&hcd_urb_list_lock, flags);
list_del_init (&urb->urb_list); list_del_init (&urb->urb_list);
spin_unlock_irqrestore (&hcd_data_lock, flags); spin_unlock_irqrestore(&hcd_urb_list_lock, flags);
if (hcd->self.uses_dma && !at_root_hub) { if (hcd->self.uses_dma && !is_root_hub(urb->dev)) {
if (usb_pipecontrol (urb->pipe) if (usb_pipecontrol (urb->pipe)
&& !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
dma_unmap_single (hcd->self.controller, urb->setup_dma, dma_unmap_single (hcd->self.controller, urb->setup_dma,
...@@ -955,7 +959,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) ...@@ -955,7 +959,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
// FIXME: verify that quiescing hc works right (RH cleans up) // FIXME: verify that quiescing hc works right (RH cleans up)
spin_lock_irqsave (&hcd_data_lock, flags); spin_lock_irqsave(&hcd_urb_list_lock, flags);
ep = (usb_pipein(urb->pipe) ? urb->dev->ep_in : urb->dev->ep_out) ep = (usb_pipein(urb->pipe) ? urb->dev->ep_in : urb->dev->ep_out)
[usb_pipeendpoint(urb->pipe)]; [usb_pipeendpoint(urb->pipe)];
if (unlikely (!ep)) if (unlikely (!ep))
...@@ -972,7 +976,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) ...@@ -972,7 +976,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
status = -ESHUTDOWN; status = -ESHUTDOWN;
break; break;
} }
spin_unlock_irqrestore (&hcd_data_lock, flags); spin_unlock_irqrestore(&hcd_urb_list_lock, flags);
if (status) { if (status) {
INIT_LIST_HEAD (&urb->urb_list); INIT_LIST_HEAD (&urb->urb_list);
usbmon_urb_submit_error(&hcd->self, urb, status); usbmon_urb_submit_error(&hcd->self, urb, status);
...@@ -986,7 +990,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags) ...@@ -986,7 +990,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
urb = usb_get_urb (urb); urb = usb_get_urb (urb);
atomic_inc (&urb->use_count); atomic_inc (&urb->use_count);
if (urb->dev == hcd->self.root_hub) { if (is_root_hub(urb->dev)) {
/* NOTE: requirement on hub callers (usbfs and the hub /* NOTE: requirement on hub callers (usbfs and the hub
* driver, for now) that URBs' urb->transfer_buffer be * driver, for now) that URBs' urb->transfer_buffer be
* valid and usb_buffer_{sync,unmap}() not be needed, since * valid and usb_buffer_{sync,unmap}() not be needed, since
...@@ -1043,7 +1047,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb) ...@@ -1043,7 +1047,7 @@ unlink1 (struct usb_hcd *hcd, struct urb *urb)
{ {
int value; int value;
if (urb->dev == hcd->self.root_hub) if (is_root_hub(urb->dev))
value = usb_rh_urb_dequeue (hcd, urb); value = usb_rh_urb_dequeue (hcd, urb);
else { else {
...@@ -1091,11 +1095,11 @@ int usb_hcd_unlink_urb (struct urb *urb, int status) ...@@ -1091,11 +1095,11 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
* that it was submitted. But as a rule it can't know whether or * that it was submitted. But as a rule it can't know whether or
* not it's already been unlinked ... so we respect the reversed * not it's already been unlinked ... so we respect the reversed
* lock sequence needed for the usb_hcd_giveback_urb() code paths * lock sequence needed for the usb_hcd_giveback_urb() code paths
* (urb lock, then hcd_data_lock) in case some other CPU is now * (urb lock, then hcd_urb_list_lock) in case some other CPU is now
* unlinking it. * unlinking it.
*/ */
spin_lock_irqsave (&urb->lock, flags); spin_lock_irqsave (&urb->lock, flags);
spin_lock (&hcd_data_lock); spin_lock(&hcd_urb_list_lock);
sys = &urb->dev->dev; sys = &urb->dev->dev;
hcd = bus_to_hcd(urb->dev->bus); hcd = bus_to_hcd(urb->dev->bus);
...@@ -1127,17 +1131,16 @@ int usb_hcd_unlink_urb (struct urb *urb, int status) ...@@ -1127,17 +1131,16 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
* finish unlinking the initial failed usb_set_address() * finish unlinking the initial failed usb_set_address()
* or device descriptor fetch. * or device descriptor fetch.
*/ */
if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) &&
&& hcd->self.root_hub != urb->dev) { !is_root_hub(urb->dev)) {
dev_warn (hcd->self.controller, "Unlink after no-IRQ? " dev_warn (hcd->self.controller, "Unlink after no-IRQ? "
"Controller is probably using the wrong IRQ." "Controller is probably using the wrong IRQ.\n");
"\n");
set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
} }
urb->status = status; urb->status = status;
spin_unlock (&hcd_data_lock); spin_unlock(&hcd_urb_list_lock);
spin_unlock_irqrestore (&urb->lock, flags); spin_unlock_irqrestore (&urb->lock, flags);
retval = unlink1 (hcd, urb); retval = unlink1 (hcd, urb);
...@@ -1146,7 +1149,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status) ...@@ -1146,7 +1149,7 @@ int usb_hcd_unlink_urb (struct urb *urb, int status)
return retval; return retval;
done: done:
spin_unlock (&hcd_data_lock); spin_unlock(&hcd_urb_list_lock);
spin_unlock_irqrestore (&urb->lock, flags); spin_unlock_irqrestore (&urb->lock, flags);
if (retval != -EIDRM && sys && sys->driver) if (retval != -EIDRM && sys && sys->driver)
dev_dbg (sys, "hcd_unlink_urb %p fail %d\n", urb, retval); dev_dbg (sys, "hcd_unlink_urb %p fail %d\n", urb, retval);
...@@ -1203,7 +1206,7 @@ void usb_hcd_endpoint_disable (struct usb_device *udev, ...@@ -1203,7 +1206,7 @@ void usb_hcd_endpoint_disable (struct usb_device *udev,
/* ep is already gone from udev->ep_{in,out}[]; no more submits */ /* ep is already gone from udev->ep_{in,out}[]; no more submits */
rescan: rescan:
spin_lock (&hcd_data_lock); spin_lock(&hcd_urb_list_lock);
list_for_each_entry (urb, &ep->urb_list, urb_list) { list_for_each_entry (urb, &ep->urb_list, urb_list) {
int tmp; int tmp;
...@@ -1211,7 +1214,7 @@ rescan: ...@@ -1211,7 +1214,7 @@ rescan:
if (urb->status != -EINPROGRESS) if (urb->status != -EINPROGRESS)
continue; continue;
usb_get_urb (urb); usb_get_urb (urb);
spin_unlock (&hcd_data_lock); spin_unlock(&hcd_urb_list_lock);
spin_lock (&urb->lock); spin_lock (&urb->lock);
tmp = urb->status; tmp = urb->status;
...@@ -1240,7 +1243,7 @@ rescan: ...@@ -1240,7 +1243,7 @@ rescan:
/* list contents may have changed */ /* list contents may have changed */
goto rescan; goto rescan;
} }
spin_unlock (&hcd_data_lock); spin_unlock(&hcd_urb_list_lock);
local_irq_enable (); local_irq_enable ();
/* synchronize with the hardware, so old configuration state /* synchronize with the hardware, so old configuration state
...@@ -1257,7 +1260,7 @@ rescan: ...@@ -1257,7 +1260,7 @@ rescan:
* endpoint_disable methods. * endpoint_disable methods.
*/ */
while (!list_empty (&ep->urb_list)) { while (!list_empty (&ep->urb_list)) {
spin_lock_irq (&hcd_data_lock); spin_lock_irq(&hcd_urb_list_lock);
/* The list may have changed while we acquired the spinlock */ /* The list may have changed while we acquired the spinlock */
urb = NULL; urb = NULL;
...@@ -1266,7 +1269,7 @@ rescan: ...@@ -1266,7 +1269,7 @@ rescan:
urb_list); urb_list);
usb_get_urb (urb); usb_get_urb (urb);
} }
spin_unlock_irq (&hcd_data_lock); spin_unlock_irq(&hcd_urb_list_lock);
if (urb) { if (urb) {
usb_kill_urb (urb); usb_kill_urb (urb);
......
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