aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-08-24 15:42:39 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-10-12 17:55:23 -0400
commit1431d2a44ccf68a547094976f363f94177ab00c6 (patch)
treeea02b1f45fe22214778d4986bc2d1b7051dcdced
parent4a00027dcb088bf90fa8fb14a7e8ba3506d78f22 (diff)
USB: get rid of urb->lock
Now that urb->status isn't used, urb->lock doesn't protect anything. This patch (as980) removes it and replaces it with a private mutex in the one remaining place it was still used: usb_kill_urb. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/core/urb.c11
-rw-r--r--include/linux/usb.h4
2 files changed, 6 insertions, 9 deletions
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 19f5f66c2733..76db76fdb4ec 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -39,7 +39,6 @@ void usb_init_urb(struct urb *urb)
39 if (urb) { 39 if (urb) {
40 memset(urb, 0, sizeof(*urb)); 40 memset(urb, 0, sizeof(*urb));
41 kref_init(&urb->kref); 41 kref_init(&urb->kref);
42 spin_lock_init(&urb->lock);
43 INIT_LIST_HEAD(&urb->anchor_list); 42 INIT_LIST_HEAD(&urb->anchor_list);
44 } 43 }
45} 44}
@@ -541,19 +540,21 @@ int usb_unlink_urb(struct urb *urb)
541 */ 540 */
542void usb_kill_urb(struct urb *urb) 541void usb_kill_urb(struct urb *urb)
543{ 542{
543 static DEFINE_MUTEX(reject_mutex);
544
544 might_sleep(); 545 might_sleep();
545 if (!(urb && urb->dev && urb->ep)) 546 if (!(urb && urb->dev && urb->ep))
546 return; 547 return;
547 spin_lock_irq(&urb->lock); 548 mutex_lock(&reject_mutex);
548 ++urb->reject; 549 ++urb->reject;
549 spin_unlock_irq(&urb->lock); 550 mutex_unlock(&reject_mutex);
550 551
551 usb_hcd_unlink_urb(urb, -ENOENT); 552 usb_hcd_unlink_urb(urb, -ENOENT);
552 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 553 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
553 554
554 spin_lock_irq(&urb->lock); 555 mutex_lock(&reject_mutex);
555 --urb->reject; 556 --urb->reject;
556 spin_unlock_irq(&urb->lock); 557 mutex_unlock(&reject_mutex);
557} 558}
558 559
559/** 560/**
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 5c7b79088add..5b14b4c81fd6 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1241,7 +1241,6 @@ struct urb
1241{ 1241{
1242 /* private: usb core and host controller only fields in the urb */ 1242 /* private: usb core and host controller only fields in the urb */
1243 struct kref kref; /* reference count of the URB */ 1243 struct kref kref; /* reference count of the URB */
1244 spinlock_t lock; /* lock for the URB */
1245 void *hcpriv; /* private data for host controller */ 1244 void *hcpriv; /* private data for host controller */
1246 atomic_t use_count; /* concurrent submissions counter */ 1245 atomic_t use_count; /* concurrent submissions counter */
1247 u8 reject; /* submissions will fail */ 1246 u8 reject; /* submissions will fail */
@@ -1299,7 +1298,6 @@ static inline void usb_fill_control_urb (struct urb *urb,
1299 usb_complete_t complete_fn, 1298 usb_complete_t complete_fn,
1300 void *context) 1299 void *context)
1301{ 1300{
1302 spin_lock_init(&urb->lock);
1303 urb->dev = dev; 1301 urb->dev = dev;
1304 urb->pipe = pipe; 1302 urb->pipe = pipe;
1305 urb->setup_packet = setup_packet; 1303 urb->setup_packet = setup_packet;
@@ -1330,7 +1328,6 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
1330 usb_complete_t complete_fn, 1328 usb_complete_t complete_fn,
1331 void *context) 1329 void *context)
1332{ 1330{
1333 spin_lock_init(&urb->lock);
1334 urb->dev = dev; 1331 urb->dev = dev;
1335 urb->pipe = pipe; 1332 urb->pipe = pipe;
1336 urb->transfer_buffer = transfer_buffer; 1333 urb->transfer_buffer = transfer_buffer;
@@ -1366,7 +1363,6 @@ static inline void usb_fill_int_urb (struct urb *urb,
1366 void *context, 1363 void *context,
1367 int interval) 1364 int interval)
1368{ 1365{
1369 spin_lock_init(&urb->lock);
1370 urb->dev = dev; 1366 urb->dev = dev;
1371 urb->pipe = pipe; 1367 urb->pipe = pipe;
1372 urb->transfer_buffer = transfer_buffer; 1368 urb->transfer_buffer = transfer_buffer;