Re: [Bisected] [Bug #13821] Replugging USB serial converter uses new device node

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

 



On Tue 28.Jul'09 at  0:31:20 +0100, Alan Cox wrote:

> commit 3f40612e940971ecec29d5375cdcc9f9c9a9f46e
> Author: Alan Cox <alan@xxxxxxxxxxxxxxx>
> Date:   Tue Jul 28 00:23:39 2009 +0100
> 
>     tty: USB lock/refcounting fixes
>     
>     This fixes
>     - locking bug that was hidden by ecc2e05e739c30870c8e4f252b63a0c4041f2724
>     - Regression #13821
>     - Spurious warning when closing and blocking for data write out
>     
>     With these changes my PL2303 always ends up as ttyUSB0 when it should and
>     the module refcounts stay correct.
>     
>     I'll do a more wholesale split & tidy of _open in the next release or two
>     as we get a standard tty_port_open and port->ops->init port->ops->shutdown
>     call backs.
>     
>     Signed-off-by: Alan Cox <alan@xxxxxxxxxxxxxxx>




I tested the patch below and it fixed the issue completely!
Thanks for your time Alan, I appreciate your work!




> 
> diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c
> index 3c8923f..99188c9 100644
> --- a/drivers/usb/serial/usb-serial.c
> +++ b/drivers/usb/serial/usb-serial.c
> @@ -32,6 +32,7 @@
>  #include <linux/mutex.h>
>  #include <linux/list.h>
>  #include <linux/uaccess.h>
> +#include <linux/serial.h>
>  #include <linux/usb.h>
>  #include <linux/usb/serial.h>
>  #include "pl2303.h"
> @@ -184,6 +185,7 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
>  	struct usb_serial_port *port;
>  	unsigned int portNumber;
>  	int retval = 0;
> +	int first = 0;
>  
>  	dbg("%s", __func__);
>  
> @@ -223,7 +225,7 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
>  
>  	/* If the console is attached, the device is already open */
>  	if (port->port.count == 1 && !port->console) {
> -
> +		first = 1;
>  		/* lock this module before we call it
>  		 * this may fail, which means we must bail out,
>  		 * safe because we are called with BKL held */
> @@ -246,13 +248,21 @@ static int serial_open (struct tty_struct *tty, struct file *filp)
>  		if (retval)
>  			goto bailout_interface_put;
>  		mutex_unlock(&serial->disc_mutex);
> +		set_bit(ASYNCB_INITIALIZED, &port->port.flags);
>  	}
>  	mutex_unlock(&port->mutex);
>  	/* Now do the correct tty layer semantics */
>  	retval = tty_port_block_til_ready(&port->port, tty, filp);
> -	if (retval == 0)
> +	if (retval == 0) {
> +		if (!first)
> +			usb_serial_put(serial);
>  		return 0;
> -
> +	}
> +	mutex_lock(&port->mutex);
> +	if (first == 0)
> +		goto bailout_mutex_unlock;
> +	/* Undo the initial port actions */
> +	mutex_lock(&serial->disc_mutex);
>  bailout_interface_put:
>  	usb_autopm_put_interface(serial->interface);
>  bailout_module_put:
> @@ -411,7 +421,6 @@ static int serial_chars_in_buffer(struct tty_struct *tty)
>  	struct usb_serial_port *port = tty->driver_data;
>  	dbg("%s = port %d", __func__, port->number);
>  
> -	WARN_ON(!port->port.count);
>  	/* if the device was unplugged then any remaining characters
>  	   fell out of the connector ;) */
>  	if (port->serial->disconnected)
--
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