diff options
Diffstat (limited to 'drivers/usb/serial/visor.c')
-rw-r--r-- | drivers/usb/serial/visor.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c index 95a2936e902e..88949f7884ca 100644 --- a/drivers/usb/serial/visor.c +++ b/drivers/usb/serial/visor.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
26 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
27 | #include <linux/usb.h> | 27 | #include <linux/usb.h> |
28 | #include "usb-serial.h" | 28 | #include <linux/usb/serial.h> |
29 | #include "visor.h" | 29 | #include "visor.h" |
30 | 30 | ||
31 | /* | 31 | /* |
@@ -302,7 +302,6 @@ static int visor_open (struct usb_serial_port *port, struct file *filp) | |||
302 | spin_lock_irqsave(&priv->lock, flags); | 302 | spin_lock_irqsave(&priv->lock, flags); |
303 | priv->bytes_in = 0; | 303 | priv->bytes_in = 0; |
304 | priv->bytes_out = 0; | 304 | priv->bytes_out = 0; |
305 | priv->outstanding_urbs = 0; | ||
306 | priv->throttled = 0; | 305 | priv->throttled = 0; |
307 | spin_unlock_irqrestore(&priv->lock, flags); | 306 | spin_unlock_irqrestore(&priv->lock, flags); |
308 | 307 | ||
@@ -435,13 +434,25 @@ static int visor_write (struct usb_serial_port *port, const unsigned char *buf, | |||
435 | 434 | ||
436 | static int visor_write_room (struct usb_serial_port *port) | 435 | static int visor_write_room (struct usb_serial_port *port) |
437 | { | 436 | { |
437 | struct visor_private *priv = usb_get_serial_port_data(port); | ||
438 | unsigned long flags; | ||
439 | |||
438 | dbg("%s - port %d", __FUNCTION__, port->number); | 440 | dbg("%s - port %d", __FUNCTION__, port->number); |
439 | 441 | ||
440 | /* | 442 | /* |
441 | * We really can take anything the user throws at us | 443 | * We really can take anything the user throws at us |
442 | * but let's pick a nice big number to tell the tty | 444 | * but let's pick a nice big number to tell the tty |
443 | * layer that we have lots of free space | 445 | * layer that we have lots of free space, unless we don't. |
444 | */ | 446 | */ |
447 | |||
448 | spin_lock_irqsave(&priv->lock, flags); | ||
449 | if (priv->outstanding_urbs > URB_UPPER_LIMIT * 2 / 3) { | ||
450 | spin_unlock_irqrestore(&priv->lock, flags); | ||
451 | dbg("%s - write limit hit\n", __FUNCTION__); | ||
452 | return 0; | ||
453 | } | ||
454 | spin_unlock_irqrestore(&priv->lock, flags); | ||
455 | |||
445 | return 2048; | 456 | return 2048; |
446 | } | 457 | } |
447 | 458 | ||
@@ -758,15 +769,22 @@ static int visor_calc_num_ports (struct usb_serial *serial) | |||
758 | 769 | ||
759 | static int generic_startup(struct usb_serial *serial) | 770 | static int generic_startup(struct usb_serial *serial) |
760 | { | 771 | { |
772 | struct usb_serial_port **ports = serial->port; | ||
761 | struct visor_private *priv; | 773 | struct visor_private *priv; |
762 | int i; | 774 | int i; |
763 | 775 | ||
764 | for (i = 0; i < serial->num_ports; ++i) { | 776 | for (i = 0; i < serial->num_ports; ++i) { |
765 | priv = kzalloc (sizeof(*priv), GFP_KERNEL); | 777 | priv = kzalloc (sizeof(*priv), GFP_KERNEL); |
766 | if (!priv) | 778 | if (!priv) { |
779 | while (i-- != 0) { | ||
780 | priv = usb_get_serial_port_data(ports[i]); | ||
781 | usb_set_serial_port_data(ports[i], NULL); | ||
782 | kfree(priv); | ||
783 | } | ||
767 | return -ENOMEM; | 784 | return -ENOMEM; |
785 | } | ||
768 | spin_lock_init(&priv->lock); | 786 | spin_lock_init(&priv->lock); |
769 | usb_set_serial_port_data(serial->port[i], priv); | 787 | usb_set_serial_port_data(ports[i], priv); |
770 | } | 788 | } |
771 | return 0; | 789 | return 0; |
772 | } | 790 | } |
@@ -876,7 +894,18 @@ static int clie_5_attach (struct usb_serial *serial) | |||
876 | 894 | ||
877 | static void visor_shutdown (struct usb_serial *serial) | 895 | static void visor_shutdown (struct usb_serial *serial) |
878 | { | 896 | { |
897 | struct visor_private *priv; | ||
898 | int i; | ||
899 | |||
879 | dbg("%s", __FUNCTION__); | 900 | dbg("%s", __FUNCTION__); |
901 | |||
902 | for (i = 0; i < serial->num_ports; i++) { | ||
903 | priv = usb_get_serial_port_data(serial->port[i]); | ||
904 | if (priv) { | ||
905 | usb_set_serial_port_data(serial->port[i], NULL); | ||
906 | kfree(priv); | ||
907 | } | ||
908 | } | ||
880 | } | 909 | } |
881 | 910 | ||
882 | static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) | 911 | static int visor_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg) |