aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/oti6858.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-19 14:28:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-19 14:28:10 -0400
commit42bf3e27e846156e9cead6f2cd6c43fa0ceb8362 (patch)
treed20e54769315ea176c5c732de35877b4e7f08450 /drivers/usb/serial/oti6858.c
parentfb06de04192c2d0ed18599e5a6402b85382fd8d5 (diff)
parent4b35f1c52943851b310afb09047bfe991ac8f5ae (diff)
Merge tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg Kroah-Hartman: "Here are the USB patches against your 3.7-rc1 tree. There are the usual UABI header file movements, and we finally are now able to remove the dbg() macro that is over 15 years old (that had to wait for after some other trees got merged into yours during the big 3.7-rc1 merge window.) Other than that, nothing major, just a number of bugfixes and new device ids. It turns out that almost all of the usb-serial drivers had bugs in how they were handling their internal data, leaking memory, hence all of those fixups. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>" * tag 'usb-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (42 commits) USB: option: add more ZTE devices USB: option: blacklist net interface on ZTE devices usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP USB: io_ti: fix sysfs-attribute creation USB: iuu_phoenix: fix sysfs-attribute creation USB: spcp8x5: fix port-data memory leak USB: ssu100: fix port-data memory leak USB: ti_usb_3410_5052: fix port-data memory leak USB: oti6858: fix port-data memory leak USB: iuu_phoenix: fix port-data memory leak USB: kl5kusb105: fix port-data memory leak USB: io_ti: fix port-data memory leak USB: keyspan_pda: fix port-data memory leak USB: f81232: fix port-data memory leak USB: io_edgeport: fix port-data memory leak USB: kobil_sct: fix port-data memory leak USB: cypress_m8: fix port-data memory leak usb: acm: fix the computation of the number of data bits usb: Missing dma_mask in ehci-vt8500.c when probed from device-tree usb: Missing dma_mask in uhci-platform.c when probed from device-tree ...
Diffstat (limited to 'drivers/usb/serial/oti6858.c')
-rw-r--r--drivers/usb/serial/oti6858.c68
1 files changed, 28 insertions, 40 deletions
diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index 933241f03fd8..cee9a52ca891 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -137,8 +137,8 @@ static int oti6858_chars_in_buffer(struct tty_struct *tty);
137static int oti6858_tiocmget(struct tty_struct *tty); 137static int oti6858_tiocmget(struct tty_struct *tty);
138static int oti6858_tiocmset(struct tty_struct *tty, 138static int oti6858_tiocmset(struct tty_struct *tty,
139 unsigned int set, unsigned int clear); 139 unsigned int set, unsigned int clear);
140static int oti6858_startup(struct usb_serial *serial); 140static int oti6858_port_probe(struct usb_serial_port *port);
141static void oti6858_release(struct usb_serial *serial); 141static int oti6858_port_remove(struct usb_serial_port *port);
142 142
143/* device info */ 143/* device info */
144static struct usb_serial_driver oti6858_device = { 144static struct usb_serial_driver oti6858_device = {
@@ -161,8 +161,8 @@ static struct usb_serial_driver oti6858_device = {
161 .write_bulk_callback = oti6858_write_bulk_callback, 161 .write_bulk_callback = oti6858_write_bulk_callback,
162 .write_room = oti6858_write_room, 162 .write_room = oti6858_write_room,
163 .chars_in_buffer = oti6858_chars_in_buffer, 163 .chars_in_buffer = oti6858_chars_in_buffer,
164 .attach = oti6858_startup, 164 .port_probe = oti6858_port_probe,
165 .release = oti6858_release, 165 .port_remove = oti6858_port_remove,
166}; 166};
167 167
168static struct usb_serial_driver * const serial_drivers[] = { 168static struct usb_serial_driver * const serial_drivers[] = {
@@ -331,36 +331,33 @@ static void send_data(struct work_struct *work)
331 usb_serial_port_softint(port); 331 usb_serial_port_softint(port);
332} 332}
333 333
334static int oti6858_startup(struct usb_serial *serial) 334static int oti6858_port_probe(struct usb_serial_port *port)
335{ 335{
336 struct usb_serial_port *port = serial->port[0];
337 struct oti6858_private *priv; 336 struct oti6858_private *priv;
338 int i;
339
340 for (i = 0; i < serial->num_ports; ++i) {
341 priv = kzalloc(sizeof(struct oti6858_private), GFP_KERNEL);
342 if (!priv)
343 break;
344
345 spin_lock_init(&priv->lock);
346 init_waitqueue_head(&priv->intr_wait);
347/* INIT_WORK(&priv->setup_work, setup_line, serial->port[i]); */
348/* INIT_WORK(&priv->write_work, send_data, serial->port[i]); */
349 priv->port = port;
350 INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
351 INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
352
353 usb_set_serial_port_data(serial->port[i], priv);
354 }
355 if (i == serial->num_ports)
356 return 0;
357 337
358 for (--i; i >= 0; --i) { 338 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
359 priv = usb_get_serial_port_data(serial->port[i]); 339 if (!priv)
360 kfree(priv); 340 return -ENOMEM;
361 usb_set_serial_port_data(serial->port[i], NULL); 341
362 } 342 spin_lock_init(&priv->lock);
363 return -ENOMEM; 343 init_waitqueue_head(&priv->intr_wait);
344 priv->port = port;
345 INIT_DELAYED_WORK(&priv->delayed_setup_work, setup_line);
346 INIT_DELAYED_WORK(&priv->delayed_write_work, send_data);
347
348 usb_set_serial_port_data(port, priv);
349
350 return 0;
351}
352
353static int oti6858_port_remove(struct usb_serial_port *port)
354{
355 struct oti6858_private *priv;
356
357 priv = usb_get_serial_port_data(port);
358 kfree(priv);
359
360 return 0;
364} 361}
365 362
366static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port, 363static int oti6858_write(struct tty_struct *tty, struct usb_serial_port *port,
@@ -709,15 +706,6 @@ static int oti6858_ioctl(struct tty_struct *tty,
709 return -ENOIOCTLCMD; 706 return -ENOIOCTLCMD;
710} 707}
711 708
712
713static void oti6858_release(struct usb_serial *serial)
714{
715 int i;
716
717 for (i = 0; i < serial->num_ports; ++i)
718 kfree(usb_get_serial_port_data(serial->port[i]));
719}
720
721static void oti6858_read_int_callback(struct urb *urb) 709static void oti6858_read_int_callback(struct urb *urb)
722{ 710{
723 struct usb_serial_port *port = urb->context; 711 struct usb_serial_port *port = urb->context;