[rft]basic autosuspend support for option driver

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

 



Hi,

this implements very basic autosuspend support for the option
driver. It'll suspend the device when no port is opened. Please test.

	Regards
		Oliver

--

diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
index 575816e..c40ad66 100644
--- a/drivers/usb/serial/option.c
+++ b/drivers/usb/serial/option.c
@@ -543,6 +543,7 @@ static struct usb_driver option_driver = {
 	.resume     = usb_serial_resume,
 	.id_table   = option_ids,
 	.no_dynamic_id = 	1,
+	.supports_autosuspend =	1,
 };
 
 /* The card has three separate interfaces, which the serial driver
@@ -1232,25 +1233,26 @@ static int option_resume(struct usb_serial *serial)
 		/* walk all ports */
 		port = serial->port[i];
 		portdata = usb_get_serial_port_data(port);
-		mutex_lock(&port->mutex);
+		/*
+		 * Locking is tricky here
+		 * we either	- depend on the freezer
+				- or are called with port->mutex held
+		 * hence no locking here
+		 */
 
 		/* skip closed ports */
-		if (!port->port.count) {
-			mutex_unlock(&port->mutex);
+		if (!port->port.count)
 			continue;
-		}
 
 		for (j = 0; j < N_IN_URB; j++) {
 			urb = portdata->in_urbs[j];
 			err = usb_submit_urb(urb, GFP_NOIO);
 			if (err < 0) {
-				mutex_unlock(&port->mutex);
 				err("%s: Error %d for bulk URB %d",
 					 __func__, err, i);
 				return err;
 			}
 		}
-		mutex_unlock(&port->mutex);
 	}
 	return 0;
 }

--
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