Commit 43e6b5b4 authored by Duncan Sands's avatar Duncan Sands Committed by Greg Kroah-Hartman

[PATCH] usb speedtch: convert to using usb_kill_urb

Unlike usb_unlink_urb, usb_kill_urb guarantees that completion handlers have
finished running before it returns.  The bunch of disconnect code that waited
for completion handlers can now go away.
Signed-off-by: default avatarDuncan Sands <baldrick@free.fr>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent a0e64cc0
......@@ -1220,9 +1220,7 @@ static int udsl_usb_probe (struct usb_interface *intf, const struct usb_device_i
static void udsl_usb_disconnect (struct usb_interface *intf)
{
struct udsl_instance_data *instance = usb_get_intfdata (intf);
struct list_head *pos;
unsigned int count;
int result, i;
int i;
dbg ("udsl_usb_disconnect entered");
......@@ -1237,27 +1235,7 @@ static void udsl_usb_disconnect (struct usb_interface *intf)
tasklet_disable (&instance->receive_tasklet);
for (i = 0; i < num_rcv_urbs; i++)
if ((result = usb_unlink_urb (instance->receivers [i].urb)) < 0)
dbg ("udsl_usb_disconnect: usb_unlink_urb on receive urb %d returned %d!", i, result);
/* wait for completion handlers to finish */
do {
count = 0;
spin_lock_irq (&instance->receive_lock);
list_for_each (pos, &instance->spare_receivers) {
++count;
DEBUG_ON (count > num_rcv_urbs);
}
spin_unlock_irq (&instance->receive_lock);
dbg ("udsl_usb_disconnect: found %u spare receivers", count);
if (count == num_rcv_urbs)
break;
set_current_state (TASK_RUNNING);
schedule ();
} while (1);
usb_kill_urb (instance->receivers [i].urb);
/* no need to take the spinlock */
INIT_LIST_HEAD (&instance->filled_receive_buffers);
......@@ -1275,27 +1253,7 @@ static void udsl_usb_disconnect (struct usb_interface *intf)
tasklet_disable (&instance->send_tasklet);
for (i = 0; i < num_snd_urbs; i++)
if ((result = usb_unlink_urb (instance->senders [i].urb)) < 0)
dbg ("udsl_usb_disconnect: usb_unlink_urb on send urb %d returned %d!", i, result);
/* wait for completion handlers to finish */
do {
count = 0;
spin_lock_irq (&instance->send_lock);
list_for_each (pos, &instance->spare_senders) {
++count;
DEBUG_ON (count > num_snd_urbs);
}
spin_unlock_irq (&instance->send_lock);
dbg ("udsl_usb_disconnect: found %u spare senders", count);
if (count == num_snd_urbs)
break;
set_current_state (TASK_RUNNING);
schedule ();
} while (1);
usb_kill_urb (instance->senders [i].urb);
/* no need to take the spinlock */
INIT_LIST_HEAD (&instance->spare_senders);
......
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