USB: serial: remove overly defensive port tests
The only way a port pointer may be NULL is if probe() failed, and in that case neither disconnect(), resume(), or reset_resume() will be called. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
c14829fad8
Коммит
3fff3b4343
|
@ -1060,6 +1060,7 @@ static void usb_serial_disconnect(struct usb_interface *interface)
|
||||||
struct usb_serial *serial = usb_get_intfdata(interface);
|
struct usb_serial *serial = usb_get_intfdata(interface);
|
||||||
struct device *dev = &interface->dev;
|
struct device *dev = &interface->dev;
|
||||||
struct usb_serial_port *port;
|
struct usb_serial_port *port;
|
||||||
|
struct tty_struct *tty;
|
||||||
|
|
||||||
usb_serial_console_disconnect(serial);
|
usb_serial_console_disconnect(serial);
|
||||||
|
|
||||||
|
@ -1070,18 +1071,16 @@ static void usb_serial_disconnect(struct usb_interface *interface)
|
||||||
|
|
||||||
for (i = 0; i < serial->num_ports; ++i) {
|
for (i = 0; i < serial->num_ports; ++i) {
|
||||||
port = serial->port[i];
|
port = serial->port[i];
|
||||||
if (port) {
|
tty = tty_port_tty_get(&port->port);
|
||||||
struct tty_struct *tty = tty_port_tty_get(&port->port);
|
if (tty) {
|
||||||
if (tty) {
|
tty_vhangup(tty);
|
||||||
tty_vhangup(tty);
|
tty_kref_put(tty);
|
||||||
tty_kref_put(tty);
|
|
||||||
}
|
|
||||||
usb_serial_port_poison_urbs(port);
|
|
||||||
wake_up_interruptible(&port->port.delta_msr_wait);
|
|
||||||
cancel_work_sync(&port->work);
|
|
||||||
if (device_is_registered(&port->dev))
|
|
||||||
device_del(&port->dev);
|
|
||||||
}
|
}
|
||||||
|
usb_serial_port_poison_urbs(port);
|
||||||
|
wake_up_interruptible(&port->port.delta_msr_wait);
|
||||||
|
cancel_work_sync(&port->work);
|
||||||
|
if (device_is_registered(&port->dev))
|
||||||
|
device_del(&port->dev);
|
||||||
}
|
}
|
||||||
if (serial->type->disconnect)
|
if (serial->type->disconnect)
|
||||||
serial->type->disconnect(serial);
|
serial->type->disconnect(serial);
|
||||||
|
@ -1094,7 +1093,6 @@ static void usb_serial_disconnect(struct usb_interface *interface)
|
||||||
int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
|
int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
|
||||||
{
|
{
|
||||||
struct usb_serial *serial = usb_get_intfdata(intf);
|
struct usb_serial *serial = usb_get_intfdata(intf);
|
||||||
struct usb_serial_port *port;
|
|
||||||
int i, r = 0;
|
int i, r = 0;
|
||||||
|
|
||||||
serial->suspending = 1;
|
serial->suspending = 1;
|
||||||
|
@ -1112,12 +1110,8 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < serial->num_ports; ++i) {
|
for (i = 0; i < serial->num_ports; ++i)
|
||||||
port = serial->port[i];
|
usb_serial_port_poison_urbs(serial->port[i]);
|
||||||
if (port)
|
|
||||||
usb_serial_port_poison_urbs(port);
|
|
||||||
}
|
|
||||||
|
|
||||||
err_out:
|
err_out:
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -1125,14 +1119,10 @@ EXPORT_SYMBOL(usb_serial_suspend);
|
||||||
|
|
||||||
static void usb_serial_unpoison_port_urbs(struct usb_serial *serial)
|
static void usb_serial_unpoison_port_urbs(struct usb_serial *serial)
|
||||||
{
|
{
|
||||||
struct usb_serial_port *port;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < serial->num_ports; ++i) {
|
for (i = 0; i < serial->num_ports; ++i)
|
||||||
port = serial->port[i];
|
usb_serial_port_unpoison_urbs(serial->port[i]);
|
||||||
if (port)
|
|
||||||
usb_serial_port_unpoison_urbs(port);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int usb_serial_resume(struct usb_interface *intf)
|
int usb_serial_resume(struct usb_interface *intf)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче