diff options
author | Olivier Bornet <Olivier.Bornet@puck.ch> | 2009-06-11 07:52:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-11 11:51:01 -0400 |
commit | 5fcf62b0f1f24ee25931636216f28bc87448a60f (patch) | |
tree | 30a6ab6ff039d8293f5c06deaed0760b49c63af1 /drivers/usb | |
parent | 852e99d22f2231d232c45216b027565e3bae7add (diff) |
tty: iuu_phoenix: fix locking.
Bring in the relevant bits of the 0.9 vendor driver.
Signed-off-by: Olivier Bornet <Olivier.Bornet@puck.ch>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/serial/iuu_phoenix.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index bb572cee6ecd..637d0ddbfb42 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
@@ -650,32 +650,33 @@ static int iuu_bulk_write(struct usb_serial_port *port) | |||
650 | unsigned long flags; | 650 | unsigned long flags; |
651 | int result; | 651 | int result; |
652 | int i; | 652 | int i; |
653 | int buf_len; | ||
653 | char *buf_ptr = port->write_urb->transfer_buffer; | 654 | char *buf_ptr = port->write_urb->transfer_buffer; |
654 | dbg("%s - enter", __func__); | 655 | dbg("%s - enter", __func__); |
655 | 656 | ||
657 | spin_lock_irqsave(&priv->lock, flags); | ||
656 | *buf_ptr++ = IUU_UART_ESC; | 658 | *buf_ptr++ = IUU_UART_ESC; |
657 | *buf_ptr++ = IUU_UART_TX; | 659 | *buf_ptr++ = IUU_UART_TX; |
658 | *buf_ptr++ = priv->writelen; | 660 | *buf_ptr++ = priv->writelen; |
659 | 661 | ||
660 | memcpy(buf_ptr, priv->writebuf, | 662 | memcpy(buf_ptr, priv->writebuf, priv->writelen); |
661 | priv->writelen); | 663 | buf_len = priv->writelen; |
664 | priv->writelen = 0; | ||
665 | spin_unlock_irqrestore(&priv->lock, flags); | ||
662 | if (debug == 1) { | 666 | if (debug == 1) { |
663 | for (i = 0; i < priv->writelen; i++) | 667 | for (i = 0; i < buf_len; i++) |
664 | sprintf(priv->dbgbuf + i*2 , | 668 | sprintf(priv->dbgbuf + i*2 , |
665 | "%02X", priv->writebuf[i]); | 669 | "%02X", priv->writebuf[i]); |
666 | priv->dbgbuf[priv->writelen+i*2] = 0; | 670 | priv->dbgbuf[buf_len+i*2] = 0; |
667 | dbg("%s - writing %i chars : %s", __func__, | 671 | dbg("%s - writing %i chars : %s", __func__, |
668 | priv->writelen, priv->dbgbuf); | 672 | buf_len, priv->dbgbuf); |
669 | } | 673 | } |
670 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, | 674 | usb_fill_bulk_urb(port->write_urb, port->serial->dev, |
671 | usb_sndbulkpipe(port->serial->dev, | 675 | usb_sndbulkpipe(port->serial->dev, |
672 | port->bulk_out_endpointAddress), | 676 | port->bulk_out_endpointAddress), |
673 | port->write_urb->transfer_buffer, priv->writelen + 3, | 677 | port->write_urb->transfer_buffer, buf_len + 3, |
674 | iuu_rxcmd, port); | 678 | iuu_rxcmd, port); |
675 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); | 679 | result = usb_submit_urb(port->write_urb, GFP_ATOMIC); |
676 | spin_lock_irqsave(&priv->lock, flags); | ||
677 | priv->writelen = 0; | ||
678 | spin_unlock_irqrestore(&priv->lock, flags); | ||
679 | usb_serial_port_softint(port); | 680 | usb_serial_port_softint(port); |
680 | return result; | 681 | return result; |
681 | } | 682 | } |
@@ -769,14 +770,10 @@ static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
769 | return -ENOMEM; | 770 | return -ENOMEM; |
770 | 771 | ||
771 | spin_lock_irqsave(&priv->lock, flags); | 772 | spin_lock_irqsave(&priv->lock, flags); |
772 | if (priv->writelen > 0) { | 773 | |
773 | /* buffer already filled but not commited */ | ||
774 | spin_unlock_irqrestore(&priv->lock, flags); | ||
775 | return 0; | ||
776 | } | ||
777 | /* fill the buffer */ | 774 | /* fill the buffer */ |
778 | memcpy(priv->writebuf, buf, count); | 775 | memcpy(priv->writebuf + priv->writelen, buf, count); |
779 | priv->writelen = count; | 776 | priv->writelen += count; |
780 | spin_unlock_irqrestore(&priv->lock, flags); | 777 | spin_unlock_irqrestore(&priv->lock, flags); |
781 | 778 | ||
782 | return count; | 779 | return count; |