Commit 5e231b6b authored by Arjan van de Ven's avatar Arjan van de Ven Committed by Greg Kroah-Hartman

[PATCH] usb: remove some sleep_on's

sleep_on must die.... and it fixes a few races too ;)
parent e82e16d3
...@@ -781,17 +781,25 @@ static int dabusb_probe (struct usb_interface *intf, ...@@ -781,17 +781,25 @@ static int dabusb_probe (struct usb_interface *intf,
static void dabusb_disconnect (struct usb_interface *intf) static void dabusb_disconnect (struct usb_interface *intf)
{ {
wait_queue_t __wait;
pdabusb_t s = usb_get_intfdata (intf); pdabusb_t s = usb_get_intfdata (intf);
dbg("dabusb_disconnect"); dbg("dabusb_disconnect");
init_waitqueue_entry(&__wait, current);
usb_set_intfdata (intf, NULL); usb_set_intfdata (intf, NULL);
if (s) { if (s) {
usb_deregister_dev (intf, &dabusb_class); usb_deregister_dev (intf, &dabusb_class);
s->remove_pending = 1; s->remove_pending = 1;
wake_up (&s->wait); wake_up (&s->wait);
add_wait_queue(&s->remove_ok, &__wait);
set_current_state(TASK_UNINTERRUPTIBLE);
if (s->state == _started) 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->usbdev = NULL;
s->overruns = 0; s->overruns = 0;
} }
......
...@@ -1927,7 +1927,6 @@ static int auerswald_probe (struct usb_interface *intf, ...@@ -1927,7 +1927,6 @@ static int auerswald_probe (struct usb_interface *intf,
{ {
struct usb_device *usbdev = interface_to_usbdev(intf); struct usb_device *usbdev = interface_to_usbdev(intf);
pauerswald_t cp = NULL; pauerswald_t cp = NULL;
DECLARE_WAIT_QUEUE_HEAD (wqh);
unsigned int u = 0; unsigned int u = 0;
char *pbuf; char *pbuf;
int ret; int ret;
...@@ -1975,7 +1974,8 @@ static int auerswald_probe (struct usb_interface *intf, ...@@ -1975,7 +1974,8 @@ static int auerswald_probe (struct usb_interface *intf,
dbg ("Version is %X", cp->version); dbg ("Version is %X", cp->version);
/* allow some time to settle the device */ /* 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 */ /* Try to get a suitable textual description of the device */
/* Device name:*/ /* Device name:*/
......
...@@ -397,7 +397,11 @@ tiglusb_probe (struct usb_interface *intf, ...@@ -397,7 +397,11 @@ tiglusb_probe (struct usb_interface *intf,
static void static void
tiglusb_disconnect (struct usb_interface *intf) tiglusb_disconnect (struct usb_interface *intf)
{ {
wait_queue_t __wait;
ptiglusb_t s = usb_get_intfdata (intf); ptiglusb_t s = usb_get_intfdata (intf);
init_waitqueue_entry(&__wait, current);
usb_set_intfdata (intf, NULL); usb_set_intfdata (intf, NULL);
if (!s || !s->dev) { if (!s || !s->dev) {
...@@ -407,8 +411,12 @@ tiglusb_disconnect (struct usb_interface *intf) ...@@ -407,8 +411,12 @@ tiglusb_disconnect (struct usb_interface *intf)
s->remove_pending = 1; s->remove_pending = 1;
wake_up (&s->wait); wake_up (&s->wait);
add_wait_queue(&s->wait, &__wait);
set_current_state(TASK_UNINTERRUPTIBLE);
if (s->state == _started) if (s->state == _started)
sleep_on (&s->remove_ok); schedule();
current->state = TASK_RUNNING;
remove_wait_queue(&s->wait, &__wait);
down (&s->mutex); down (&s->mutex);
s->dev = NULL; s->dev = NULL;
s->opened = 0; s->opened = 0;
......
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