Re: [PATCH 8/8] usb-serial: straighten out serial_open

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

 



2009/9/1 Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>:
> This patch (as1291) removes a bunch of code from serial_open(), things
> that were rendered unnecessary by earlier patches.  A missing spinlock
> is added to protect port->port.count, which needs to be incremented
> even if the open fails but not if the tty has gotten a hangup.  The
> test for whether the hardware has been initialized, based on the use
> count, is replaced by a more transparent test of the
> ASYNCB_INITIALIZED bit in the port flags.
>
> Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
>
> ---
>
> Index: usb-2.6/drivers/usb/serial/usb-serial.c
> ===================================================================
> --- usb-2.6.orig/drivers/usb/serial/usb-serial.c
> +++ usb-2.6/drivers/usb/serial/usb-serial.c
> @@ -246,55 +246,40 @@ static int serial_install(struct tty_dri
>        return retval;
>  }
>
> -static int serial_open (struct tty_struct *tty, struct file *filp)
> +static int serial_open(struct tty_struct *tty, struct file *filp)
>  {
> -       struct usb_serial *serial;
> -       struct usb_serial_port *port;
> -       int retval = 0;
> -       int first = 0;
> -
> -       port = tty->driver_data;
> -       serial = port->serial;
> +       struct usb_serial_port *port = tty->driver_data;
> +       struct usb_serial *serial = port->serial;
> +       int retval;
>
>        dbg("%s - port %d", __func__, port->number);
>
> -       if (mutex_lock_interruptible(&port->mutex))
> -               return -ERESTARTSYS;
> -
> -       ++port->port.count;
> +       spin_lock_irq(&port->port.lock);
> +       if (!tty_hung_up_p(filp))
> +               ++port->port.count;
> +       spin_unlock_irq(&port->port.lock);

The lock is still needed  in usb_console_setup() to protect port->port.count,
isn't it?

Thanks.
-- 
Lei Ming
--
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