ChangeSet 1.1024, 2003/03/05 14:33:27-08:00, david-b@pacbell.net

[PATCH] USB: call hcd->stop() in task context

This is the 2.4 version of a fix that's been in 2.5 for some
time now:  when an HCD dies a premature death, its cleanup
needs to be done in a task context.  The most likely case for
that would be physical cardbus eject without driver shutdown.


 drivers/usb/hcd.c |   11 ++++++++++-
 drivers/usb/hcd.h |    1 +
 2 files changed, 11 insertions(+), 1 deletion(-)


diff -Nru a/drivers/usb/hcd.c b/drivers/usb/hcd.c
--- a/drivers/usb/hcd.c	Thu Mar  6 14:22:56 2003
+++ b/drivers/usb/hcd.c	Thu Mar  6 14:22:56 2003
@@ -935,6 +935,12 @@
 
 /*-------------------------------------------------------------------------*/
 
+static void hcd_panic (void *_hcd)
+{
+	struct usb_hcd *hcd = _hcd;
+	hcd->driver->stop (hcd);
+}
+
 static void hc_died (struct usb_hcd *hcd)
 {
 	struct list_head	*devlist, *urblist;
@@ -962,7 +968,10 @@
 
 	if (urb)
 		rh_status_dequeue (hcd, urb);
-	hcd->driver->stop (hcd);
+
+	/* hcd->stop() needs a task context */
+	INIT_TQUEUE (&hcd->work, hcd_panic, hcd);
+	(void) schedule_task (&hcd->work);
 }
 
 /*-------------------------------------------------------------------------*/
diff -Nru a/drivers/usb/hcd.h b/drivers/usb/hcd.h
--- a/drivers/usb/hcd.h	Thu Mar  6 14:22:56 2003
+++ b/drivers/usb/hcd.h	Thu Mar  6 14:22:56 2003
@@ -41,6 +41,7 @@
 
 	struct timer_list	rh_timer;	/* drives root hub */
 	struct list_head	dev_list;	/* devices on this bus */
+	struct tq_struct	work;
 
 	/*
 	 * hardware info/state