diff options
Diffstat (limited to 'drivers/usb/serial/usb-serial.c')
-rw-r--r-- | drivers/usb/serial/usb-serial.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/drivers/usb/serial/usb-serial.c b/drivers/usb/serial/usb-serial.c index b157c48e8b78..8be3f39891c7 100644 --- a/drivers/usb/serial/usb-serial.c +++ b/drivers/usb/serial/usb-serial.c | |||
@@ -214,7 +214,7 @@ static int serial_open (struct tty_struct *tty, struct file *filp) | |||
214 | /* set up our port structure making the tty driver | 214 | /* set up our port structure making the tty driver |
215 | * remember our port object, and us it */ | 215 | * remember our port object, and us it */ |
216 | tty->driver_data = port; | 216 | tty->driver_data = port; |
217 | port->port.tty = tty; | 217 | tty_port_tty_set(&port->port, tty); |
218 | 218 | ||
219 | if (port->port.count == 1) { | 219 | if (port->port.count == 1) { |
220 | 220 | ||
@@ -246,7 +246,7 @@ bailout_module_put: | |||
246 | bailout_mutex_unlock: | 246 | bailout_mutex_unlock: |
247 | port->port.count = 0; | 247 | port->port.count = 0; |
248 | tty->driver_data = NULL; | 248 | tty->driver_data = NULL; |
249 | port->port.tty = NULL; | 249 | tty_port_tty_set(&port->port, NULL); |
250 | mutex_unlock(&port->mutex); | 250 | mutex_unlock(&port->mutex); |
251 | bailout_kref_put: | 251 | bailout_kref_put: |
252 | usb_serial_put(serial); | 252 | usb_serial_put(serial); |
@@ -276,10 +276,11 @@ static void serial_close(struct tty_struct *tty, struct file *filp) | |||
276 | port->serial->type->close(tty, port, filp); | 276 | port->serial->type->close(tty, port, filp); |
277 | 277 | ||
278 | if (port->port.count == (port->console? 1 : 0)) { | 278 | if (port->port.count == (port->console? 1 : 0)) { |
279 | if (port->port.tty) { | 279 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
280 | if (port->port.tty->driver_data) | 280 | if (tty) { |
281 | port->port.tty->driver_data = NULL; | 281 | if (tty->driver_data) |
282 | port->port.tty = NULL; | 282 | tty->driver_data = NULL; |
283 | tty_port_tty_set(&port->port, NULL); | ||
283 | } | 284 | } |
284 | } | 285 | } |
285 | 286 | ||
@@ -508,11 +509,12 @@ static void usb_serial_port_work(struct work_struct *work) | |||
508 | if (!port) | 509 | if (!port) |
509 | return; | 510 | return; |
510 | 511 | ||
511 | tty = port->port.tty; | 512 | tty = tty_port_tty_get(&port->port); |
512 | if (!tty) | 513 | if (!tty) |
513 | return; | 514 | return; |
514 | 515 | ||
515 | tty_wakeup(tty); | 516 | tty_wakeup(tty); |
517 | tty_kref_put(tty); | ||
516 | } | 518 | } |
517 | 519 | ||
518 | static void port_release(struct device *dev) | 520 | static void port_release(struct device *dev) |
@@ -733,7 +735,9 @@ int usb_serial_probe(struct usb_interface *interface, | |||
733 | ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && | 735 | ((le16_to_cpu(dev->descriptor.idVendor) == ATEN_VENDOR_ID) && |
734 | (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || | 736 | (le16_to_cpu(dev->descriptor.idProduct) == ATEN_PRODUCT_ID)) || |
735 | ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && | 737 | ((le16_to_cpu(dev->descriptor.idVendor) == ALCOR_VENDOR_ID) && |
736 | (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID))) { | 738 | (le16_to_cpu(dev->descriptor.idProduct) == ALCOR_PRODUCT_ID)) || |
739 | ((le16_to_cpu(dev->descriptor.idVendor) == SIEMENS_VENDOR_ID) && | ||
740 | (le16_to_cpu(dev->descriptor.idProduct) == SIEMENS_PRODUCT_ID_EF81))) { | ||
737 | if (interface != dev->actconfig->interface[0]) { | 741 | if (interface != dev->actconfig->interface[0]) { |
738 | /* check out the endpoints of the other interface*/ | 742 | /* check out the endpoints of the other interface*/ |
739 | iface_desc = dev->actconfig->interface[0]->cur_altsetting; | 743 | iface_desc = dev->actconfig->interface[0]->cur_altsetting; |
@@ -817,6 +821,7 @@ int usb_serial_probe(struct usb_interface *interface, | |||
817 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); | 821 | port = kzalloc(sizeof(struct usb_serial_port), GFP_KERNEL); |
818 | if (!port) | 822 | if (!port) |
819 | goto probe_error; | 823 | goto probe_error; |
824 | tty_port_init(&port->port); | ||
820 | port->serial = serial; | 825 | port->serial = serial; |
821 | spin_lock_init(&port->lock); | 826 | spin_lock_init(&port->lock); |
822 | mutex_init(&port->mutex); | 827 | mutex_init(&port->mutex); |
@@ -1038,8 +1043,11 @@ void usb_serial_disconnect(struct usb_interface *interface) | |||
1038 | for (i = 0; i < serial->num_ports; ++i) { | 1043 | for (i = 0; i < serial->num_ports; ++i) { |
1039 | port = serial->port[i]; | 1044 | port = serial->port[i]; |
1040 | if (port) { | 1045 | if (port) { |
1041 | if (port->port.tty) | 1046 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
1042 | tty_hangup(port->port.tty); | 1047 | if (tty) { |
1048 | tty_hangup(tty); | ||
1049 | tty_kref_put(tty); | ||
1050 | } | ||
1043 | kill_traffic(port); | 1051 | kill_traffic(port); |
1044 | } | 1052 | } |
1045 | } | 1053 | } |
@@ -1113,7 +1121,8 @@ static int __init usb_serial_init(void) | |||
1113 | 1121 | ||
1114 | result = bus_register(&usb_serial_bus_type); | 1122 | result = bus_register(&usb_serial_bus_type); |
1115 | if (result) { | 1123 | if (result) { |
1116 | err("%s - registering bus driver failed", __func__); | 1124 | printk(KERN_ERR "usb-serial: %s - registering bus driver " |
1125 | "failed\n", __func__); | ||
1117 | goto exit_bus; | 1126 | goto exit_bus; |
1118 | } | 1127 | } |
1119 | 1128 | ||
@@ -1134,25 +1143,28 @@ static int __init usb_serial_init(void) | |||
1134 | tty_set_operations(usb_serial_tty_driver, &serial_ops); | 1143 | tty_set_operations(usb_serial_tty_driver, &serial_ops); |
1135 | result = tty_register_driver(usb_serial_tty_driver); | 1144 | result = tty_register_driver(usb_serial_tty_driver); |
1136 | if (result) { | 1145 | if (result) { |
1137 | err("%s - tty_register_driver failed", __func__); | 1146 | printk(KERN_ERR "usb-serial: %s - tty_register_driver failed\n", |
1147 | __func__); | ||
1138 | goto exit_reg_driver; | 1148 | goto exit_reg_driver; |
1139 | } | 1149 | } |
1140 | 1150 | ||
1141 | /* register the USB driver */ | 1151 | /* register the USB driver */ |
1142 | result = usb_register(&usb_serial_driver); | 1152 | result = usb_register(&usb_serial_driver); |
1143 | if (result < 0) { | 1153 | if (result < 0) { |
1144 | err("%s - usb_register failed", __func__); | 1154 | printk(KERN_ERR "usb-serial: %s - usb_register failed\n", |
1155 | __func__); | ||
1145 | goto exit_tty; | 1156 | goto exit_tty; |
1146 | } | 1157 | } |
1147 | 1158 | ||
1148 | /* register the generic driver, if we should */ | 1159 | /* register the generic driver, if we should */ |
1149 | result = usb_serial_generic_register(debug); | 1160 | result = usb_serial_generic_register(debug); |
1150 | if (result < 0) { | 1161 | if (result < 0) { |
1151 | err("%s - registering generic driver failed", __func__); | 1162 | printk(KERN_ERR "usb-serial: %s - registering generic " |
1163 | "driver failed\n", __func__); | ||
1152 | goto exit_generic; | 1164 | goto exit_generic; |
1153 | } | 1165 | } |
1154 | 1166 | ||
1155 | info(DRIVER_DESC); | 1167 | printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n"); |
1156 | 1168 | ||
1157 | return result; | 1169 | return result; |
1158 | 1170 | ||
@@ -1166,7 +1178,8 @@ exit_reg_driver: | |||
1166 | bus_unregister(&usb_serial_bus_type); | 1178 | bus_unregister(&usb_serial_bus_type); |
1167 | 1179 | ||
1168 | exit_bus: | 1180 | exit_bus: |
1169 | err("%s - returning with error %d", __func__, result); | 1181 | printk(KERN_ERR "usb-serial: %s - returning with error %d\n", |
1182 | __func__, result); | ||
1170 | put_tty_driver(usb_serial_tty_driver); | 1183 | put_tty_driver(usb_serial_tty_driver); |
1171 | return result; | 1184 | return result; |
1172 | } | 1185 | } |
@@ -1225,11 +1238,11 @@ int usb_serial_register(struct usb_serial_driver *driver) | |||
1225 | 1238 | ||
1226 | retval = usb_serial_bus_register(driver); | 1239 | retval = usb_serial_bus_register(driver); |
1227 | if (retval) { | 1240 | if (retval) { |
1228 | err("problem %d when registering driver %s", | 1241 | printk(KERN_ERR "usb-serial: problem %d when registering " |
1229 | retval, driver->description); | 1242 | "driver %s\n", retval, driver->description); |
1230 | list_del(&driver->driver_list); | 1243 | list_del(&driver->driver_list); |
1231 | } else | 1244 | } else |
1232 | info("USB Serial support registered for %s", | 1245 | printk(KERN_INFO "USB Serial support registered for %s\n", |
1233 | driver->description); | 1246 | driver->description); |
1234 | 1247 | ||
1235 | return retval; | 1248 | return retval; |
@@ -1240,7 +1253,8 @@ EXPORT_SYMBOL_GPL(usb_serial_register); | |||
1240 | void usb_serial_deregister(struct usb_serial_driver *device) | 1253 | void usb_serial_deregister(struct usb_serial_driver *device) |
1241 | { | 1254 | { |
1242 | /* must be called with BKL held */ | 1255 | /* must be called with BKL held */ |
1243 | info("USB Serial deregistering driver %s", device->description); | 1256 | printk(KERN_INFO "USB Serial deregistering driver %s\n", |
1257 | device->description); | ||
1244 | list_del(&device->driver_list); | 1258 | list_del(&device->driver_list); |
1245 | usb_serial_bus_deregister(device); | 1259 | usb_serial_bus_deregister(device); |
1246 | } | 1260 | } |