diff options
Diffstat (limited to 'drivers/usb/serial/cp210x.c')
-rw-r--r-- | drivers/usb/serial/cp210x.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 28af5acc3360..eb033fc92a15 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
@@ -162,7 +162,7 @@ static const struct usb_device_id id_table[] = { | |||
162 | 162 | ||
163 | MODULE_DEVICE_TABLE(usb, id_table); | 163 | MODULE_DEVICE_TABLE(usb, id_table); |
164 | 164 | ||
165 | struct cp210x_port_private { | 165 | struct cp210x_serial_private { |
166 | __u8 bInterfaceNumber; | 166 | __u8 bInterfaceNumber; |
167 | }; | 167 | }; |
168 | 168 | ||
@@ -276,7 +276,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
276 | unsigned int *data, int size) | 276 | unsigned int *data, int size) |
277 | { | 277 | { |
278 | struct usb_serial *serial = port->serial; | 278 | struct usb_serial *serial = port->serial; |
279 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); | 279 | struct cp210x_serial_private *spriv = usb_get_serial_data(serial); |
280 | __le32 *buf; | 280 | __le32 *buf; |
281 | int result, i, length; | 281 | int result, i, length; |
282 | 282 | ||
@@ -292,7 +292,7 @@ static int cp210x_get_config(struct usb_serial_port *port, u8 request, | |||
292 | /* Issue the request, attempting to read 'size' bytes */ | 292 | /* Issue the request, attempting to read 'size' bytes */ |
293 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), | 293 | result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), |
294 | request, REQTYPE_INTERFACE_TO_HOST, 0x0000, | 294 | request, REQTYPE_INTERFACE_TO_HOST, 0x0000, |
295 | port_priv->bInterfaceNumber, buf, size, | 295 | spriv->bInterfaceNumber, buf, size, |
296 | USB_CTRL_GET_TIMEOUT); | 296 | USB_CTRL_GET_TIMEOUT); |
297 | 297 | ||
298 | /* Convert data into an array of integers */ | 298 | /* Convert data into an array of integers */ |
@@ -323,7 +323,7 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
323 | unsigned int *data, int size) | 323 | unsigned int *data, int size) |
324 | { | 324 | { |
325 | struct usb_serial *serial = port->serial; | 325 | struct usb_serial *serial = port->serial; |
326 | struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); | 326 | struct cp210x_serial_private *spriv = usb_get_serial_data(serial); |
327 | __le32 *buf; | 327 | __le32 *buf; |
328 | int result, i, length; | 328 | int result, i, length; |
329 | 329 | ||
@@ -345,13 +345,13 @@ static int cp210x_set_config(struct usb_serial_port *port, u8 request, | |||
345 | result = usb_control_msg(serial->dev, | 345 | result = usb_control_msg(serial->dev, |
346 | usb_sndctrlpipe(serial->dev, 0), | 346 | usb_sndctrlpipe(serial->dev, 0), |
347 | request, REQTYPE_HOST_TO_INTERFACE, 0x0000, | 347 | request, REQTYPE_HOST_TO_INTERFACE, 0x0000, |
348 | port_priv->bInterfaceNumber, buf, size, | 348 | spriv->bInterfaceNumber, buf, size, |
349 | USB_CTRL_SET_TIMEOUT); | 349 | USB_CTRL_SET_TIMEOUT); |
350 | } else { | 350 | } else { |
351 | result = usb_control_msg(serial->dev, | 351 | result = usb_control_msg(serial->dev, |
352 | usb_sndctrlpipe(serial->dev, 0), | 352 | usb_sndctrlpipe(serial->dev, 0), |
353 | request, REQTYPE_HOST_TO_INTERFACE, data[0], | 353 | request, REQTYPE_HOST_TO_INTERFACE, data[0], |
354 | port_priv->bInterfaceNumber, NULL, 0, | 354 | spriv->bInterfaceNumber, NULL, 0, |
355 | USB_CTRL_SET_TIMEOUT); | 355 | USB_CTRL_SET_TIMEOUT); |
356 | } | 356 | } |
357 | 357 | ||
@@ -845,36 +845,30 @@ static void cp210x_break_ctl (struct tty_struct *tty, int break_state) | |||
845 | 845 | ||
846 | static int cp210x_startup(struct usb_serial *serial) | 846 | static int cp210x_startup(struct usb_serial *serial) |
847 | { | 847 | { |
848 | struct cp210x_port_private *port_priv; | 848 | struct usb_host_interface *cur_altsetting; |
849 | int i; | 849 | struct cp210x_serial_private *spriv; |
850 | 850 | ||
851 | /* cp210x buffers behave strangely unless device is reset */ | 851 | /* cp210x buffers behave strangely unless device is reset */ |
852 | usb_reset_device(serial->dev); | 852 | usb_reset_device(serial->dev); |
853 | 853 | ||
854 | for (i = 0; i < serial->num_ports; i++) { | 854 | spriv = kzalloc(sizeof(*spriv), GFP_KERNEL); |
855 | port_priv = kzalloc(sizeof(*port_priv), GFP_KERNEL); | 855 | if (!spriv) |
856 | if (!port_priv) | 856 | return -ENOMEM; |
857 | return -ENOMEM; | ||
858 | 857 | ||
859 | port_priv->bInterfaceNumber = | 858 | cur_altsetting = serial->interface->cur_altsetting; |
860 | serial->interface->cur_altsetting->desc.bInterfaceNumber; | 859 | spriv->bInterfaceNumber = cur_altsetting->desc.bInterfaceNumber; |
861 | 860 | ||
862 | usb_set_serial_port_data(serial->port[i], port_priv); | 861 | usb_set_serial_data(serial, spriv); |
863 | } | ||
864 | 862 | ||
865 | return 0; | 863 | return 0; |
866 | } | 864 | } |
867 | 865 | ||
868 | static void cp210x_release(struct usb_serial *serial) | 866 | static void cp210x_release(struct usb_serial *serial) |
869 | { | 867 | { |
870 | struct cp210x_port_private *port_priv; | 868 | struct cp210x_serial_private *spriv; |
871 | int i; | ||
872 | 869 | ||
873 | for (i = 0; i < serial->num_ports; i++) { | 870 | spriv = usb_get_serial_data(serial); |
874 | port_priv = usb_get_serial_port_data(serial->port[i]); | 871 | kfree(spriv); |
875 | kfree(port_priv); | ||
876 | usb_set_serial_port_data(serial->port[i], NULL); | ||
877 | } | ||
878 | } | 872 | } |
879 | 873 | ||
880 | module_usb_serial_driver(serial_drivers, id_table); | 874 | module_usb_serial_driver(serial_drivers, id_table); |