diff options
author | Johan Hovold <jhovold@gmail.com> | 2014-05-26 13:23:34 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-05-27 18:04:08 -0400 |
commit | 3fff3b4343f45963c087976c772348f3051a40ee (patch) | |
tree | 59b907832b41469c9c090989b1c18f3c05e9007f /drivers/usb/serial/usb-serial.c | |
parent | c14829fad88dbeda57253590695b85ba51270621 (diff) |
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>
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index 6d40d56378d7..02de3110fe94 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -1060,6 +1060,7 @@ static void usb_serial_disconnect(struct usb_interface *interface) | |||
1060 | struct usb_serial *serial = usb_get_intfdata(interface); | 1060 | struct usb_serial *serial = usb_get_intfdata(interface); |
1061 | struct device *dev = &interface->dev; | 1061 | struct device *dev = &interface->dev; |
1062 | struct usb_serial_port *port; | 1062 | struct usb_serial_port *port; |
1063 | struct tty_struct *tty; | ||
1063 | 1064 | ||
1064 | usb_serial_console_disconnect(serial); | 1065 | usb_serial_console_disconnect(serial); |
1065 | 1066 | ||
@@ -1070,18 +1071,16 @@ static void usb_serial_disconnect(struct usb_interface *interface) | |||
1070 | 1071 | ||
1071 | for (i = 0; i < serial->num_ports; ++i) { | 1072 | for (i = 0; i < serial->num_ports; ++i) { |
1072 | port = serial->port[i]; | 1073 | port = serial->port[i]; |
1073 | if (port) { | 1074 | tty = tty_port_tty_get(&port->port); |
1074 | struct tty_struct *tty = tty_port_tty_get(&port->port); | 1075 | if (tty) { |
1075 | if (tty) { | 1076 | tty_vhangup(tty); |
1076 | tty_vhangup(tty); | 1077 | tty_kref_put(tty); |
1077 | tty_kref_put(tty); | ||
1078 | } | ||
1079 | usb_serial_port_poison_urbs(port); | ||
1080 | wake_up_interruptible(&port->port.delta_msr_wait); | ||
1081 | cancel_work_sync(&port->work); | ||
1082 | if (device_is_registered(&port->dev)) | ||
1083 | device_del(&port->dev); | ||
1084 | } | 1078 | } |
1079 | usb_serial_port_poison_urbs(port); | ||
1080 | wake_up_interruptible(&port->port.delta_msr_wait); | ||
1081 | cancel_work_sync(&port->work); | ||
1082 | if (device_is_registered(&port->dev)) | ||
1083 | device_del(&port->dev); | ||
1085 | } | 1084 | } |
1086 | if (serial->type->disconnect) | 1085 | if (serial->type->disconnect) |
1087 | serial->type->disconnect(serial); | 1086 | serial->type->disconnect(serial); |
@@ -1094,7 +1093,6 @@ static void usb_serial_disconnect(struct usb_interface *interface) | |||
1094 | int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) | 1093 | int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) |
1095 | { | 1094 | { |
1096 | struct usb_serial *serial = usb_get_intfdata(intf); | 1095 | struct usb_serial *serial = usb_get_intfdata(intf); |
1097 | struct usb_serial_port *port; | ||
1098 | int i, r = 0; | 1096 | int i, r = 0; |
1099 | 1097 | ||
1100 | serial->suspending = 1; | 1098 | serial->suspending = 1; |
@@ -1112,12 +1110,8 @@ int usb_serial_suspend(struct usb_interface *intf, pm_message_t message) | |||
1112 | } | 1110 | } |
1113 | } | 1111 | } |
1114 | 1112 | ||
1115 | for (i = 0; i < serial->num_ports; ++i) { | 1113 | for (i = 0; i < serial->num_ports; ++i) |
1116 | port = serial->port[i]; | 1114 | usb_serial_port_poison_urbs(serial->port[i]); |
1117 | if (port) | ||
1118 | usb_serial_port_poison_urbs(port); | ||
1119 | } | ||
1120 | |||
1121 | err_out: | 1115 | err_out: |
1122 | return r; | 1116 | return r; |
1123 | } | 1117 | } |
@@ -1125,14 +1119,10 @@ EXPORT_SYMBOL(usb_serial_suspend); | |||
1125 | 1119 | ||
1126 | static void usb_serial_unpoison_port_urbs(struct usb_serial *serial) | 1120 | static void usb_serial_unpoison_port_urbs(struct usb_serial *serial) |
1127 | { | 1121 | { |
1128 | struct usb_serial_port *port; | ||
1129 | int i; | 1122 | int i; |
1130 | 1123 | ||
1131 | for (i = 0; i < serial->num_ports; ++i) { | 1124 | for (i = 0; i < serial->num_ports; ++i) |
1132 | port = serial->port[i]; | 1125 | usb_serial_port_unpoison_urbs(serial->port[i]); |
1133 | if (port) | ||
1134 | usb_serial_port_unpoison_urbs(port); | ||
1135 | } | ||
1136 | } | 1126 | } |
1137 | 1127 | ||
1138 | int usb_serial_resume(struct usb_interface *intf) | 1128 | int usb_serial_resume(struct usb_interface *intf) |