aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/ftdi_sio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/serial/ftdi_sio.c')
-rw-r--r--drivers/usb/serial/ftdi_sio.c68
1 files changed, 41 insertions, 27 deletions
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index bcadb1f4f5dd..51d7bdea2869 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -1327,7 +1327,7 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port)
1327 1327
1328 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL); 1328 priv = kzalloc(sizeof(struct ftdi_private), GFP_KERNEL);
1329 if (!priv) { 1329 if (!priv) {
1330 err("%s- kmalloc(%Zd) failed.", __func__, 1330 dev_err(&port->dev, "%s- kmalloc(%Zd) failed.\n", __func__,
1331 sizeof(struct ftdi_private)); 1331 sizeof(struct ftdi_private));
1332 return -ENOMEM; 1332 return -ENOMEM;
1333 } 1333 }
@@ -1524,8 +1524,9 @@ static int ftdi_open(struct tty_struct *tty,
1524 ftdi_read_bulk_callback, port); 1524 ftdi_read_bulk_callback, port);
1525 result = usb_submit_urb(port->read_urb, GFP_KERNEL); 1525 result = usb_submit_urb(port->read_urb, GFP_KERNEL);
1526 if (result) 1526 if (result)
1527 err("%s - failed submitting read urb, error %d", 1527 dev_err(&port->dev,
1528 __func__, result); 1528 "%s - failed submitting read urb, error %d\n",
1529 __func__, result);
1529 1530
1530 1531
1531 return result; 1532 return result;
@@ -1559,7 +1560,7 @@ static void ftdi_close(struct tty_struct *tty,
1559 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 1560 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
1560 0, priv->interface, buf, 0, 1561 0, priv->interface, buf, 0,
1561 WDR_TIMEOUT) < 0) { 1562 WDR_TIMEOUT) < 0) {
1562 err("error from flowcontrol urb"); 1563 dev_err(&port->dev, "error from flowcontrol urb\n");
1563 } 1564 }
1564 1565
1565 /* drop RTS and DTR */ 1566 /* drop RTS and DTR */
@@ -1624,14 +1625,15 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1624 1625
1625 buffer = kmalloc(transfer_size, GFP_ATOMIC); 1626 buffer = kmalloc(transfer_size, GFP_ATOMIC);
1626 if (!buffer) { 1627 if (!buffer) {
1627 err("%s ran out of kernel memory for urb ...", __func__); 1628 dev_err(&port->dev,
1629 "%s ran out of kernel memory for urb ...\n", __func__);
1628 count = -ENOMEM; 1630 count = -ENOMEM;
1629 goto error_no_buffer; 1631 goto error_no_buffer;
1630 } 1632 }
1631 1633
1632 urb = usb_alloc_urb(0, GFP_ATOMIC); 1634 urb = usb_alloc_urb(0, GFP_ATOMIC);
1633 if (!urb) { 1635 if (!urb) {
1634 err("%s - no more free urbs", __func__); 1636 dev_err(&port->dev, "%s - no more free urbs\n", __func__);
1635 count = -ENOMEM; 1637 count = -ENOMEM;
1636 goto error_no_urb; 1638 goto error_no_urb;
1637 } 1639 }
@@ -1675,8 +1677,9 @@ static int ftdi_write(struct tty_struct *tty, struct usb_serial_port *port,
1675 1677
1676 status = usb_submit_urb(urb, GFP_ATOMIC); 1678 status = usb_submit_urb(urb, GFP_ATOMIC);
1677 if (status) { 1679 if (status) {
1678 err("%s - failed submitting write urb, error %d", 1680 dev_err(&port->dev,
1679 __func__, status); 1681 "%s - failed submitting write urb, error %d\n",
1682 __func__, status);
1680 count = status; 1683 count = status;
1681 goto error; 1684 goto error;
1682 } else { 1685 } else {
@@ -1783,7 +1786,8 @@ static int ftdi_chars_in_buffer(struct tty_struct *tty)
1783 buffered = (int)priv->tx_outstanding_bytes; 1786 buffered = (int)priv->tx_outstanding_bytes;
1784 spin_unlock_irqrestore(&priv->tx_lock, flags); 1787 spin_unlock_irqrestore(&priv->tx_lock, flags);
1785 if (buffered < 0) { 1788 if (buffered < 0) {
1786 err("%s outstanding tx bytes is negative!", __func__); 1789 dev_err(&port->dev, "%s outstanding tx bytes is negative!\n",
1790 __func__);
1787 buffered = 0; 1791 buffered = 0;
1788 } 1792 }
1789 return buffered; 1793 return buffered;
@@ -1799,11 +1803,12 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1799 int status = urb->status; 1803 int status = urb->status;
1800 1804
1801 if (urb->number_of_packets > 0) { 1805 if (urb->number_of_packets > 0) {
1802 err("%s transfer_buffer_length %d actual_length %d number of packets %d", 1806 dev_err(&port->dev, "%s transfer_buffer_length %d "
1803 __func__, 1807 "actual_length %d number of packets %d\n", __func__,
1804 urb->transfer_buffer_length, 1808 urb->transfer_buffer_length,
1805 urb->actual_length, urb->number_of_packets); 1809 urb->actual_length, urb->number_of_packets);
1806 err("%s transfer_flags %x ", __func__, urb->transfer_flags); 1810 dev_err(&port->dev, "%s transfer_flags %x\n", __func__,
1811 urb->transfer_flags);
1807 } 1812 }
1808 1813
1809 dbg("%s - port %d", __func__, port->number); 1814 dbg("%s - port %d", __func__, port->number);
@@ -1824,7 +1829,7 @@ static void ftdi_read_bulk_callback(struct urb *urb)
1824 } 1829 }
1825 1830
1826 if (urb != port->read_urb) 1831 if (urb != port->read_urb)
1827 err("%s - Not my urb!", __func__); 1832 dev_err(&port->dev, "%s - Not my urb!\n", __func__);
1828 1833
1829 if (status) { 1834 if (status) {
1830 /* This will happen at close every time so it is a dbg not an 1835 /* This will happen at close every time so it is a dbg not an
@@ -1927,7 +1932,8 @@ static void ftdi_process_read(struct work_struct *work)
1927 1932
1928 length = min(PKTSZ, urb->actual_length-packet_offset)-2; 1933 length = min(PKTSZ, urb->actual_length-packet_offset)-2;
1929 if (length < 0) { 1934 if (length < 0) {
1930 err("%s - bad packet length: %d", __func__, length+2); 1935 dev_err(&port->dev, "%s - bad packet length: %d\n",
1936 __func__, length+2);
1931 length = 0; 1937 length = 0;
1932 } 1938 }
1933 1939
@@ -2042,8 +2048,9 @@ static void ftdi_process_read(struct work_struct *work)
2042 2048
2043 result = usb_submit_urb(port->read_urb, GFP_ATOMIC); 2049 result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
2044 if (result) 2050 if (result)
2045 err("%s - failed resubmitting read urb, error %d", 2051 dev_err(&port->dev,
2046 __func__, result); 2052 "%s - failed resubmitting read urb, error %d\n",
2053 __func__, result);
2047 } 2054 }
2048out: 2055out:
2049 tty_kref_put(tty); 2056 tty_kref_put(tty);
@@ -2072,8 +2079,8 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state)
2072 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2079 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2073 urb_value , priv->interface, 2080 urb_value , priv->interface,
2074 buf, 0, WDR_TIMEOUT) < 0) { 2081 buf, 0, WDR_TIMEOUT) < 0) {
2075 err("%s FAILED to enable/disable break state (state was %d)", 2082 dev_err(&port->dev, "%s FAILED to enable/disable break state "
2076 __func__, break_state); 2083 "(state was %d)\n", __func__, break_state);
2077 } 2084 }
2078 2085
2079 dbg("%s break state is %d - urb is %d", __func__, 2086 dbg("%s break state is %d - urb is %d", __func__,
@@ -2145,7 +2152,7 @@ static void ftdi_set_termios(struct tty_struct *tty,
2145 case CS7: urb_value |= 7; dbg("Setting CS7"); break; 2152 case CS7: urb_value |= 7; dbg("Setting CS7"); break;
2146 case CS8: urb_value |= 8; dbg("Setting CS8"); break; 2153 case CS8: urb_value |= 8; dbg("Setting CS8"); break;
2147 default: 2154 default:
2148 err("CSIZE was set but not CS5-CS8"); 2155 dev_err(&port->dev, "CSIZE was set but not CS5-CS8\n");
2149 } 2156 }
2150 } 2157 }
2151 2158
@@ -2158,7 +2165,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2158 FTDI_SIO_SET_DATA_REQUEST_TYPE, 2165 FTDI_SIO_SET_DATA_REQUEST_TYPE,
2159 urb_value , priv->interface, 2166 urb_value , priv->interface,
2160 buf, 0, WDR_SHORT_TIMEOUT) < 0) { 2167 buf, 0, WDR_SHORT_TIMEOUT) < 0) {
2161 err("%s FAILED to set databits/stopbits/parity", __func__); 2168 dev_err(&port->dev, "%s FAILED to set "
2169 "databits/stopbits/parity\n", __func__);
2162 } 2170 }
2163 2171
2164 /* Now do the baudrate */ 2172 /* Now do the baudrate */
@@ -2169,14 +2177,17 @@ static void ftdi_set_termios(struct tty_struct *tty,
2169 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2177 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2170 0, priv->interface, 2178 0, priv->interface,
2171 buf, 0, WDR_TIMEOUT) < 0) { 2179 buf, 0, WDR_TIMEOUT) < 0) {
2172 err("%s error from disable flowcontrol urb", __func__); 2180 dev_err(&port->dev,
2181 "%s error from disable flowcontrol urb\n",
2182 __func__);
2173 } 2183 }
2174 /* Drop RTS and DTR */ 2184 /* Drop RTS and DTR */
2175 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2185 clear_mctrl(port, TIOCM_DTR | TIOCM_RTS);
2176 } else { 2186 } else {
2177 /* set the baudrate determined before */ 2187 /* set the baudrate determined before */
2178 if (change_speed(tty, port)) 2188 if (change_speed(tty, port))
2179 err("%s urb failed to set baudrate", __func__); 2189 dev_err(&port->dev, "%s urb failed to set baudrate\n",
2190 __func__);
2180 /* Ensure RTS and DTR are raised when baudrate changed from 0 */ 2191 /* Ensure RTS and DTR are raised when baudrate changed from 0 */
2181 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0) 2192 if (!old_termios || (old_termios->c_cflag & CBAUD) == B0)
2182 set_mctrl(port, TIOCM_DTR | TIOCM_RTS); 2193 set_mctrl(port, TIOCM_DTR | TIOCM_RTS);
@@ -2192,7 +2203,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2192 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2203 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2193 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface), 2204 0 , (FTDI_SIO_RTS_CTS_HS | priv->interface),
2194 buf, 0, WDR_TIMEOUT) < 0) { 2205 buf, 0, WDR_TIMEOUT) < 0) {
2195 err("urb failed to set to rts/cts flow control"); 2206 dev_err(&port->dev,
2207 "urb failed to set to rts/cts flow control\n");
2196 } 2208 }
2197 2209
2198 } else { 2210 } else {
@@ -2223,7 +2235,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2223 urb_value , (FTDI_SIO_XON_XOFF_HS 2235 urb_value , (FTDI_SIO_XON_XOFF_HS
2224 | priv->interface), 2236 | priv->interface),
2225 buf, 0, WDR_TIMEOUT) < 0) { 2237 buf, 0, WDR_TIMEOUT) < 0) {
2226 err("urb failed to set to xon/xoff flow control"); 2238 dev_err(&port->dev, "urb failed to set to "
2239 "xon/xoff flow control\n");
2227 } 2240 }
2228 } else { 2241 } else {
2229 /* else clause to only run if cflag ! CRTSCTS and iflag 2242 /* else clause to only run if cflag ! CRTSCTS and iflag
@@ -2236,7 +2249,8 @@ static void ftdi_set_termios(struct tty_struct *tty,
2236 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, 2249 FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE,
2237 0, priv->interface, 2250 0, priv->interface,
2238 buf, 0, WDR_TIMEOUT) < 0) { 2251 buf, 0, WDR_TIMEOUT) < 0) {
2239 err("urb failed to clear flow control"); 2252 dev_err(&port->dev,
2253 "urb failed to clear flow control\n");
2240 } 2254 }
2241 } 2255 }
2242 2256