[patch]fix usage count in usb serial generic open regarding autoresume

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

 



The resume handler has to resubmit the reading URBs if the device is
resumed while opened. But the open() method bumps the counter before
it resumes a device. The fix is to increment the counter only after
the resumption or if no resumption is attempted.

Signed-off-by: Oliver Neukum <oliver@xxxxxxxxxx>
Tested-by: Matthew Garrett <mjg@xxxxxxxxxx>

Hi Greg,

this should go into the current tree and the stable series. Technically
it fixes a regression.

	Regards
		Oliver

--

commit af2a33e9c9df3aec136d9ccaac4a803bed5c6020
Author: Oliver Neukum <oliver@xxxxxxxxxx>
Date:   Sat Jul 18 07:19:04 2009 +0200

    usb: fix counter logic in opening serial converters
    
    the usage counter must be increased only after autoresumption

diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
index bd7581b..c6f69c0 100644
--- a/drivers/usb/serial/usb-serial.c
+++ b/drivers/usb/serial/usb-serial.c
@@ -214,15 +214,13 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
 		goto bailout_port_put;
 	}
 
-	++port->port.count;
-
 	/* set up our port structure making the tty driver
 	 * remember our port object, and us it */
 	tty->driver_data = port;
 	tty_port_tty_set(&port->port, tty);
 
 	/* If the console is attached, the device is already open */
-	if (port->port.count == 1 && !port->console) {
+	if (!port->port.count && !port->console) {
 
 		/* lock this module before we call it
 		 * this may fail, which means we must bail out,
@@ -240,12 +238,16 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
 		if (retval)
 			goto bailout_module_put;
 
+		++port->port.count;
+
 		/* only call the device specific open if this
 		 * is the first time the port is opened */
 		retval = serial->type->open(tty, port, filp);
 		if (retval)
 			goto bailout_interface_put;
 		mutex_unlock(&serial->disc_mutex);
+	} else {
+		++port->port.count;
 	}
 	mutex_unlock(&port->mutex);
 	/* Now do the correct tty layer semantics */

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