[RFT 04/06]usb: cdc-wdm: Fix submission of URB after suspension

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From dff03e8a410b72275d5b3b45732fe3258dd34116 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oliver@xxxxxxxxxx>
Date: Wed, 10 Feb 2010 11:31:34 +0100
Subject: [PATCH 4/6] usb: cdc-wdm: Fix submission of URB after suspension

There's a window under which cdc-wdm may submit
an URB to a device about to be suspended. This
introduces a flag to prevent it.

Signed-off-by: Oliver Neukum <neukum@xxxxxxxxxxxxx>
---
 drivers/usb/class/cdc-wdm.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 5ef40c8..d7dcf41 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -53,7 +53,7 @@ MODULE_DEVICE_TABLE (usb, wdm_ids);
 #define WDM_INT_STALL		5
 #define WDM_POLL_RUNNING	6
 #define WDM_RESPONDING		7
-
+#define WDM_SUSPENDING		8
 
 #define WDM_MAX			16
 
@@ -231,7 +231,8 @@ static void wdm_int_callback(struct urb *urb)
 	spin_lock(&desc->iuspin);
 	clear_bit(WDM_READ, &desc->flags);
 	set_bit(WDM_RESPONDING, &desc->flags);
-	if (!test_bit(WDM_DISCONNECTING, &desc->flags)) {
+	if (!test_bit(WDM_DISCONNECTING, &desc->flags)
+		&& !test_bit(WDM_SUSPENDING, &desc->flags)) {
 		rv = usb_submit_urb(desc->response, GFP_ATOMIC);
 		dev_dbg(&desc->intf->dev, "%s: usb_submit_urb %d",
 			__func__, rv);
@@ -800,6 +801,7 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
 		rv = -EBUSY;
 	} else {
 #endif
+		set_bit(WDM_SUSPENDING, &desc->flags);
 		cancel_work_sync(&desc->rxwork);
 		kill_urbs(desc);
 #ifdef CONFIG_PM
@@ -830,6 +832,7 @@ static int wdm_resume(struct usb_interface *intf)
 	dev_dbg(&desc->intf->dev, "wdm%d_resume\n", intf->minor);
 	mutex_lock(&desc->lock);
 	rv = recover_from_urb_loss(desc);
+	clear_bit(WDM_SUSPENDING, &desc->flags);
 	mutex_unlock(&desc->lock);
 	return rv;
 }
-- 
1.6.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux