Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
809a58b8 32aca560

+26 -23
+26 -23
drivers/usb/core/hcd.c
··· 99 99 /* used for controlling access to virtual root hubs */ 100 100 static DEFINE_SPINLOCK(hcd_root_hub_lock); 101 101 102 - /* used when updating hcd data */ 103 - static DEFINE_SPINLOCK(hcd_data_lock); 102 + /* used when updating an endpoint's URB list */ 103 + static DEFINE_SPINLOCK(hcd_urb_list_lock); 104 104 105 105 /* wait queue for synchronous unlinks */ 106 106 DECLARE_WAIT_QUEUE_HEAD(usb_kill_urb_queue); 107 + 108 + static inline int is_root_hub(struct usb_device *udev) 109 + { 110 + return (udev->parent == NULL); 111 + } 107 112 108 113 /*-------------------------------------------------------------------------*/ 109 114 ··· 911 906 static void urb_unlink(struct usb_hcd *hcd, struct urb *urb) 912 907 { 913 908 unsigned long flags; 914 - int at_root_hub = (urb->dev == hcd->self.root_hub); 915 909 916 910 /* clear all state linking urb to this dev (and hcd) */ 917 - spin_lock_irqsave (&hcd_data_lock, flags); 911 + spin_lock_irqsave(&hcd_urb_list_lock, flags); 918 912 list_del_init (&urb->urb_list); 919 - spin_unlock_irqrestore (&hcd_data_lock, flags); 913 + spin_unlock_irqrestore(&hcd_urb_list_lock, flags); 920 914 921 - if (hcd->self.uses_dma && !at_root_hub) { 915 + if (hcd->self.uses_dma && !is_root_hub(urb->dev)) { 922 916 if (usb_pipecontrol (urb->pipe) 923 917 && !(urb->transfer_flags & URB_NO_SETUP_DMA_MAP)) 924 918 dma_unmap_single (hcd->self.controller, urb->setup_dma, ··· 959 955 960 956 // FIXME: verify that quiescing hc works right (RH cleans up) 961 957 962 - spin_lock_irqsave (&hcd_data_lock, flags); 958 + spin_lock_irqsave(&hcd_urb_list_lock, flags); 963 959 ep = (usb_pipein(urb->pipe) ? urb->dev->ep_in : urb->dev->ep_out) 964 960 [usb_pipeendpoint(urb->pipe)]; 965 961 if (unlikely (!ep)) ··· 976 972 status = -ESHUTDOWN; 977 973 break; 978 974 } 979 - spin_unlock_irqrestore (&hcd_data_lock, flags); 975 + spin_unlock_irqrestore(&hcd_urb_list_lock, flags); 980 976 if (status) { 981 977 INIT_LIST_HEAD (&urb->urb_list); 982 978 usbmon_urb_submit_error(&hcd->self, urb, status); ··· 990 986 urb = usb_get_urb (urb); 991 987 atomic_inc (&urb->use_count); 992 988 993 - if (urb->dev == hcd->self.root_hub) { 989 + if (is_root_hub(urb->dev)) { 994 990 /* NOTE: requirement on hub callers (usbfs and the hub 995 991 * driver, for now) that URBs' urb->transfer_buffer be 996 992 * valid and usb_buffer_{sync,unmap}() not be needed, since ··· 1047 1043 { 1048 1044 int value; 1049 1045 1050 - if (urb->dev == hcd->self.root_hub) 1046 + if (is_root_hub(urb->dev)) 1051 1047 value = usb_rh_urb_dequeue (hcd, urb); 1052 1048 else { 1053 1049 ··· 1095 1091 * that it was submitted. But as a rule it can't know whether or 1096 1092 * not it's already been unlinked ... so we respect the reversed 1097 1093 * lock sequence needed for the usb_hcd_giveback_urb() code paths 1098 - * (urb lock, then hcd_data_lock) in case some other CPU is now 1094 + * (urb lock, then hcd_urb_list_lock) in case some other CPU is now 1099 1095 * unlinking it. 1100 1096 */ 1101 1097 spin_lock_irqsave (&urb->lock, flags); 1102 - spin_lock (&hcd_data_lock); 1098 + spin_lock(&hcd_urb_list_lock); 1103 1099 1104 1100 sys = &urb->dev->dev; 1105 1101 hcd = bus_to_hcd(urb->dev->bus); ··· 1131 1127 * finish unlinking the initial failed usb_set_address() 1132 1128 * or device descriptor fetch. 1133 1129 */ 1134 - if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) 1135 - && hcd->self.root_hub != urb->dev) { 1130 + if (!test_bit(HCD_FLAG_SAW_IRQ, &hcd->flags) && 1131 + !is_root_hub(urb->dev)) { 1136 1132 dev_warn (hcd->self.controller, "Unlink after no-IRQ? " 1137 - "Controller is probably using the wrong IRQ." 1138 - "\n"); 1133 + "Controller is probably using the wrong IRQ.\n"); 1139 1134 set_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); 1140 1135 } 1141 1136 1142 1137 urb->status = status; 1143 1138 1144 - spin_unlock (&hcd_data_lock); 1139 + spin_unlock(&hcd_urb_list_lock); 1145 1140 spin_unlock_irqrestore (&urb->lock, flags); 1146 1141 1147 1142 retval = unlink1 (hcd, urb); ··· 1149 1146 return retval; 1150 1147 1151 1148 done: 1152 - spin_unlock (&hcd_data_lock); 1149 + spin_unlock(&hcd_urb_list_lock); 1153 1150 spin_unlock_irqrestore (&urb->lock, flags); 1154 1151 if (retval != -EIDRM && sys && sys->driver) 1155 1152 dev_dbg (sys, "hcd_unlink_urb %p fail %d\n", urb, retval); ··· 1206 1203 1207 1204 /* ep is already gone from udev->ep_{in,out}[]; no more submits */ 1208 1205 rescan: 1209 - spin_lock (&hcd_data_lock); 1206 + spin_lock(&hcd_urb_list_lock); 1210 1207 list_for_each_entry (urb, &ep->urb_list, urb_list) { 1211 1208 int tmp; 1212 1209 ··· 1214 1211 if (urb->status != -EINPROGRESS) 1215 1212 continue; 1216 1213 usb_get_urb (urb); 1217 - spin_unlock (&hcd_data_lock); 1214 + spin_unlock(&hcd_urb_list_lock); 1218 1215 1219 1216 spin_lock (&urb->lock); 1220 1217 tmp = urb->status; ··· 1243 1240 /* list contents may have changed */ 1244 1241 goto rescan; 1245 1242 } 1246 - spin_unlock (&hcd_data_lock); 1243 + spin_unlock(&hcd_urb_list_lock); 1247 1244 local_irq_enable (); 1248 1245 1249 1246 /* synchronize with the hardware, so old configuration state ··· 1260 1257 * endpoint_disable methods. 1261 1258 */ 1262 1259 while (!list_empty (&ep->urb_list)) { 1263 - spin_lock_irq (&hcd_data_lock); 1260 + spin_lock_irq(&hcd_urb_list_lock); 1264 1261 1265 1262 /* The list may have changed while we acquired the spinlock */ 1266 1263 urb = NULL; ··· 1269 1266 urb_list); 1270 1267 usb_get_urb (urb); 1271 1268 } 1272 - spin_unlock_irq (&hcd_data_lock); 1269 + spin_unlock_irq(&hcd_urb_list_lock); 1273 1270 1274 1271 if (urb) { 1275 1272 usb_kill_urb (urb);