aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2008-12-12 08:38:45 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 13:00:08 -0500
commit49367d8f1d9f26482cf7089489e90f0afd0a942c (patch)
treee0b8beb733f49772f258f90ce7af856a10fbdaac /drivers/usb
parent3b23dd6f8a718e5339de4f7d86ce76a078b5f771 (diff)
USB: mark "reject" field of struct urb as atomic_t
It is enough to protect accesses to reject field of urb by marking it as atomic_t,also it is the only reason of existence of usb_reject_lock,so remove the lock to make code more clean. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Acked-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/hcd.c6
-rw-r--r--drivers/usb/core/urb.c23
2 files changed, 8 insertions, 21 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index a0079876d74e..3c711db55d86 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1010,7 +1010,7 @@ int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb)
1010 spin_lock(&hcd_urb_list_lock); 1010 spin_lock(&hcd_urb_list_lock);
1011 1011
1012 /* Check that the URB isn't being killed */ 1012 /* Check that the URB isn't being killed */
1013 if (unlikely(urb->reject)) { 1013 if (unlikely(atomic_read(&urb->reject))) {
1014 rc = -EPERM; 1014 rc = -EPERM;
1015 goto done; 1015 goto done;
1016 } 1016 }
@@ -1340,7 +1340,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
1340 INIT_LIST_HEAD(&urb->urb_list); 1340 INIT_LIST_HEAD(&urb->urb_list);
1341 atomic_dec(&urb->use_count); 1341 atomic_dec(&urb->use_count);
1342 atomic_dec(&urb->dev->urbnum); 1342 atomic_dec(&urb->dev->urbnum);
1343 if (urb->reject) 1343 if (atomic_read(&urb->reject))
1344 wake_up(&usb_kill_urb_queue); 1344 wake_up(&usb_kill_urb_queue);
1345 usb_put_urb(urb); 1345 usb_put_urb(urb);
1346 } 1346 }
@@ -1444,7 +1444,7 @@ void usb_hcd_giveback_urb(struct usb_hcd *hcd, struct urb *urb, int status)
1444 urb->status = status; 1444 urb->status = status;
1445 urb->complete (urb); 1445 urb->complete (urb);
1446 atomic_dec (&urb->use_count); 1446 atomic_dec (&urb->use_count);
1447 if (unlikely (urb->reject)) 1447 if (unlikely(atomic_read(&urb->reject)))
1448 wake_up (&usb_kill_urb_queue); 1448 wake_up (&usb_kill_urb_queue);
1449 usb_put_urb (urb); 1449 usb_put_urb (urb);
1450} 1450}
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c
index 1f68af9db3f7..b5e9948698bf 100644
--- a/drivers/usb/core/urb.c
+++ b/drivers/usb/core/urb.c
@@ -10,7 +10,6 @@
10 10
11#define to_urb(d) container_of(d, struct urb, kref) 11#define to_urb(d) container_of(d, struct urb, kref)
12 12
13static DEFINE_SPINLOCK(usb_reject_lock);
14 13
15static void urb_destroy(struct kref *kref) 14static void urb_destroy(struct kref *kref)
16{ 15{
@@ -131,9 +130,7 @@ void usb_anchor_urb(struct urb *urb, struct usb_anchor *anchor)
131 urb->anchor = anchor; 130 urb->anchor = anchor;
132 131
133 if (unlikely(anchor->poisoned)) { 132 if (unlikely(anchor->poisoned)) {
134 spin_lock(&usb_reject_lock); 133 atomic_inc(&urb->reject);
135 urb->reject++;
136 spin_unlock(&usb_reject_lock);
137 } 134 }
138 135
139 spin_unlock_irqrestore(&anchor->lock, flags); 136 spin_unlock_irqrestore(&anchor->lock, flags);
@@ -565,16 +562,12 @@ void usb_kill_urb(struct urb *urb)
565 might_sleep(); 562 might_sleep();
566 if (!(urb && urb->dev && urb->ep)) 563 if (!(urb && urb->dev && urb->ep))
567 return; 564 return;
568 spin_lock_irq(&usb_reject_lock); 565 atomic_inc(&urb->reject);
569 ++urb->reject;
570 spin_unlock_irq(&usb_reject_lock);
571 566
572 usb_hcd_unlink_urb(urb, -ENOENT); 567 usb_hcd_unlink_urb(urb, -ENOENT);
573 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 568 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
574 569
575 spin_lock_irq(&usb_reject_lock); 570 atomic_dec(&urb->reject);
576 --urb->reject;
577 spin_unlock_irq(&usb_reject_lock);
578} 571}
579EXPORT_SYMBOL_GPL(usb_kill_urb); 572EXPORT_SYMBOL_GPL(usb_kill_urb);
580 573
@@ -606,9 +599,7 @@ void usb_poison_urb(struct urb *urb)
606 might_sleep(); 599 might_sleep();
607 if (!(urb && urb->dev && urb->ep)) 600 if (!(urb && urb->dev && urb->ep))
608 return; 601 return;
609 spin_lock_irq(&usb_reject_lock); 602 atomic_inc(&urb->reject);
610 ++urb->reject;
611 spin_unlock_irq(&usb_reject_lock);
612 603
613 usb_hcd_unlink_urb(urb, -ENOENT); 604 usb_hcd_unlink_urb(urb, -ENOENT);
614 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); 605 wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0);
@@ -617,14 +608,10 @@ EXPORT_SYMBOL_GPL(usb_poison_urb);
617 608
618void usb_unpoison_urb(struct urb *urb) 609void usb_unpoison_urb(struct urb *urb)
619{ 610{
620 unsigned long flags;
621
622 if (!urb) 611 if (!urb)
623 return; 612 return;
624 613
625 spin_lock_irqsave(&usb_reject_lock, flags); 614 atomic_dec(&urb->reject);
626 --urb->reject;
627 spin_unlock_irqrestore(&usb_reject_lock, flags);
628} 615}
629EXPORT_SYMBOL_GPL(usb_unpoison_urb); 616EXPORT_SYMBOL_GPL(usb_unpoison_urb);
630 617