USB: serial, use tty_standard_install
authorJiri Slaby <jslaby@suse.cz>
Mon, 30 Jan 2012 20:14:29 +0000 (21:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Feb 2012 23:00:56 +0000 (15:00 -0800)
But before that we need to reorder the calls so that we don't need to
lower the reference counts if usb_autopm_get_interface fails.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/serial/usb-serial.c

index 611b206591cb4f3c39abfc8ccb4520bcc7a25f36..1e30cc92719c004824d35b0ed3f4850410c6220e 100644 (file)
@@ -214,15 +214,14 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
        if (!try_module_get(serial->type->driver.owner))
                goto error_module_get;
 
-       /* perform the standard setup */
-       retval = tty_init_termios(tty);
-       if (retval)
-               goto error_init_termios;
-
        retval = usb_autopm_get_interface(serial->interface);
        if (retval)
                goto error_get_interface;
 
+       retval = tty_standard_install(driver, tty);
+       if (retval)
+               goto error_init_termios;
+
        mutex_unlock(&serial->disc_mutex);
 
        /* allow the driver to update the settings */
@@ -231,14 +230,11 @@ static int serial_install(struct tty_driver *driver, struct tty_struct *tty)
 
        tty->driver_data = port;
 
-       /* Final install (we use the default method) */
-       tty_driver_kref_get(driver);
-       tty->count++;
-       driver->ttys[idx] = tty;
        return retval;
 
- error_get_interface:
  error_init_termios:
+       usb_autopm_put_interface(serial->interface);
+ error_get_interface:
        module_put(serial->type->driver.owner);
  error_module_get:
  error_no_port: