ChangeSet 1.1474.148.15, 2004/01/26 16:46:29-08:00, arjanv@redhat.com [PATCH] usb: remove some sleep_on's sleep_on must die.... and it fixes a few races too ;) drivers/usb/media/dabusb.c | 12 ++++++++++-- drivers/usb/misc/auerswald.c | 4 ++-- drivers/usb/misc/tiglusb.c | 10 +++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff -Nru a/drivers/usb/media/dabusb.c b/drivers/usb/media/dabusb.c --- a/drivers/usb/media/dabusb.c Tue Jan 27 15:13:04 2004 +++ b/drivers/usb/media/dabusb.c Tue Jan 27 15:13:04 2004 @@ -781,17 +781,25 @@ static void dabusb_disconnect (struct usb_interface *intf) { + wait_queue_t __wait; pdabusb_t s = usb_get_intfdata (intf); dbg("dabusb_disconnect"); - + + init_waitqueue_entry(&__wait, current); + usb_set_intfdata (intf, NULL); if (s) { usb_deregister_dev (intf, &dabusb_class); s->remove_pending = 1; wake_up (&s->wait); + add_wait_queue(&s->remove_ok, &__wait); + set_current_state(TASK_UNINTERRUPTIBLE); if (s->state == _started) - sleep_on (&s->remove_ok); + schedule(); + current->state = TASK_RUNNING; + remove_wait_queue(&s->remove_ok, &__wait); + s->usbdev = NULL; s->overruns = 0; } diff -Nru a/drivers/usb/misc/auerswald.c b/drivers/usb/misc/auerswald.c --- a/drivers/usb/misc/auerswald.c Tue Jan 27 15:13:04 2004 +++ b/drivers/usb/misc/auerswald.c Tue Jan 27 15:13:04 2004 @@ -1927,7 +1927,6 @@ { struct usb_device *usbdev = interface_to_usbdev(intf); pauerswald_t cp = NULL; - DECLARE_WAIT_QUEUE_HEAD (wqh); unsigned int u = 0; char *pbuf; int ret; @@ -1975,7 +1974,8 @@ dbg ("Version is %X", cp->version); /* allow some time to settle the device */ - sleep_on_timeout (&wqh, HZ / 3 ); + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(HZ/3); /* Try to get a suitable textual description of the device */ /* Device name:*/ diff -Nru a/drivers/usb/misc/tiglusb.c b/drivers/usb/misc/tiglusb.c --- a/drivers/usb/misc/tiglusb.c Tue Jan 27 15:13:04 2004 +++ b/drivers/usb/misc/tiglusb.c Tue Jan 27 15:13:04 2004 @@ -397,7 +397,11 @@ static void tiglusb_disconnect (struct usb_interface *intf) { + wait_queue_t __wait; ptiglusb_t s = usb_get_intfdata (intf); + + init_waitqueue_entry(&__wait, current); + usb_set_intfdata (intf, NULL); if (!s || !s->dev) { @@ -407,8 +411,12 @@ s->remove_pending = 1; wake_up (&s->wait); + add_wait_queue(&s->wait, &__wait); + set_current_state(TASK_UNINTERRUPTIBLE); if (s->state == _started) - sleep_on (&s->remove_ok); + schedule(); + current->state = TASK_RUNNING; + remove_wait_queue(&s->wait, &__wait); down (&s->mutex); s->dev = NULL; s->opened = 0;