diff options
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r-- | drivers/usb/serial/mos7840.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c index 7e998081e1cd..f981b08ff32f 100644 --- a/drivers/usb/serial/mos7840.c +++ b/drivers/usb/serial/mos7840.c | |||
@@ -303,15 +303,12 @@ static int mos7840_set_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
303 | /* For the UART control registers, the application number need | 303 | /* For the UART control registers, the application number need |
304 | to be Or'ed */ | 304 | to be Or'ed */ |
305 | if (port->serial->num_ports == 4) { | 305 | if (port->serial->num_ports == 4) { |
306 | val |= (((__u16) port->number - | 306 | val |= ((__u16)port->port_number + 1) << 8; |
307 | (__u16) (port->serial->minor)) + 1) << 8; | ||
308 | } else { | 307 | } else { |
309 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { | 308 | if (port->port_number == 0) { |
310 | val |= (((__u16) port->number - | 309 | val |= ((__u16)port->port_number + 1) << 8; |
311 | (__u16) (port->serial->minor)) + 1) << 8; | ||
312 | } else { | 310 | } else { |
313 | val |= (((__u16) port->number - | 311 | val |= ((__u16)port->port_number + 2) << 8; |
314 | (__u16) (port->serial->minor)) + 2) << 8; | ||
315 | } | 312 | } |
316 | } | 313 | } |
317 | dev_dbg(&port->dev, "%s application number is %x\n", __func__, val); | 314 | dev_dbg(&port->dev, "%s application number is %x\n", __func__, val); |
@@ -340,16 +337,12 @@ static int mos7840_get_uart_reg(struct usb_serial_port *port, __u16 reg, | |||
340 | 337 | ||
341 | /* Wval is same as application number */ | 338 | /* Wval is same as application number */ |
342 | if (port->serial->num_ports == 4) { | 339 | if (port->serial->num_ports == 4) { |
343 | Wval = | 340 | Wval = ((__u16)port->port_number + 1) << 8; |
344 | (((__u16) port->number - (__u16) (port->serial->minor)) + | ||
345 | 1) << 8; | ||
346 | } else { | 341 | } else { |
347 | if (((__u16) port->number - (__u16) (port->serial->minor)) == 0) { | 342 | if (port->port_number == 0) { |
348 | Wval = (((__u16) port->number - | 343 | Wval = ((__u16)port->port_number + 1) << 8; |
349 | (__u16) (port->serial->minor)) + 1) << 8; | ||
350 | } else { | 344 | } else { |
351 | Wval = (((__u16) port->number - | 345 | Wval = ((__u16)port->port_number + 2) << 8; |
352 | (__u16) (port->serial->minor)) + 2) << 8; | ||
353 | } | 346 | } |
354 | } | 347 | } |
355 | dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval); | 348 | dev_dbg(&port->dev, "%s application number is %x\n", __func__, Wval); |
@@ -631,9 +624,7 @@ static void mos7840_interrupt_callback(struct urb *urb) | |||
631 | 624 | ||
632 | for (i = 0; i < serial->num_ports; i++) { | 625 | for (i = 0; i < serial->num_ports; i++) { |
633 | mos7840_port = mos7840_get_port_private(serial->port[i]); | 626 | mos7840_port = mos7840_get_port_private(serial->port[i]); |
634 | wval = | 627 | wval = ((__u16)serial->port[i]->port_number + 1) << 8; |
635 | (((__u16) serial->port[i]->number - | ||
636 | (__u16) (serial->minor)) + 1) << 8; | ||
637 | if (mos7840_port->open) { | 628 | if (mos7840_port->open) { |
638 | if (sp[i] & 0x01) { | 629 | if (sp[i] & 0x01) { |
639 | dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i); | 630 | dev_dbg(&urb->dev->dev, "SP%d No Interrupt !!!\n", i); |
@@ -1065,8 +1056,8 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1065 | * (can't set it up in mos7840_startup as the * | 1056 | * (can't set it up in mos7840_startup as the * |
1066 | * structures were not set up at that time.) */ | 1057 | * structures were not set up at that time.) */ |
1067 | 1058 | ||
1068 | dev_dbg(&port->dev, "port number is %d\n", port->number); | 1059 | dev_dbg(&port->dev, "port number is %d\n", port->port_number); |
1069 | dev_dbg(&port->dev, "serial number is %d\n", port->serial->minor); | 1060 | dev_dbg(&port->dev, "minor number is %d\n", port->serial->minor); |
1070 | dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress); | 1061 | dev_dbg(&port->dev, "Bulkin endpoint is %d\n", port->bulk_in_endpointAddress); |
1071 | dev_dbg(&port->dev, "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress); | 1062 | dev_dbg(&port->dev, "BulkOut endpoint is %d\n", port->bulk_out_endpointAddress); |
1072 | dev_dbg(&port->dev, "Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress); | 1063 | dev_dbg(&port->dev, "Interrupt endpoint is %d\n", port->interrupt_in_endpointAddress); |
@@ -1074,9 +1065,7 @@ static int mos7840_open(struct tty_struct *tty, struct usb_serial_port *port) | |||
1074 | mos7840_port->read_urb = port->read_urb; | 1065 | mos7840_port->read_urb = port->read_urb; |
1075 | 1066 | ||
1076 | /* set up our bulk in urb */ | 1067 | /* set up our bulk in urb */ |
1077 | if ((serial->num_ports == 2) | 1068 | if ((serial->num_ports == 2) && (((__u16)port->port_number % 2) != 0)) { |
1078 | && ((((__u16)port->number - | ||
1079 | (__u16)(port->serial->minor)) % 2) != 0)) { | ||
1080 | usb_fill_bulk_urb(mos7840_port->read_urb, | 1069 | usb_fill_bulk_urb(mos7840_port->read_urb, |
1081 | serial->dev, | 1070 | serial->dev, |
1082 | usb_rcvbulkpipe(serial->dev, | 1071 | usb_rcvbulkpipe(serial->dev, |
@@ -1199,7 +1188,7 @@ static void mos7840_close(struct usb_serial_port *port) | |||
1199 | mos7840_port->read_urb_busy = false; | 1188 | mos7840_port->read_urb_busy = false; |
1200 | 1189 | ||
1201 | port0->open_ports--; | 1190 | port0->open_ports--; |
1202 | dev_dbg(&port->dev, "%s in close%d:in port%d\n", __func__, port0->open_ports, port->number); | 1191 | dev_dbg(&port->dev, "%s in close%d\n", __func__, port0->open_ports); |
1203 | if (port0->open_ports == 0) { | 1192 | if (port0->open_ports == 0) { |
1204 | if (serial->port[0]->interrupt_in_urb) { | 1193 | if (serial->port[0]->interrupt_in_urb) { |
1205 | dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n"); | 1194 | dev_dbg(&port->dev, "Shutdown interrupt_in_urb\n"); |
@@ -1435,9 +1424,7 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, | |||
1435 | memcpy(urb->transfer_buffer, current_position, transfer_size); | 1424 | memcpy(urb->transfer_buffer, current_position, transfer_size); |
1436 | 1425 | ||
1437 | /* fill urb with data and submit */ | 1426 | /* fill urb with data and submit */ |
1438 | if ((serial->num_ports == 2) | 1427 | if ((serial->num_ports == 2) && (((__u16)port->port_number % 2) != 0)) { |
1439 | && ((((__u16)port->number - | ||
1440 | (__u16)(port->serial->minor)) % 2) != 0)) { | ||
1441 | usb_fill_bulk_urb(urb, | 1428 | usb_fill_bulk_urb(urb, |
1442 | serial->dev, | 1429 | serial->dev, |
1443 | usb_sndbulkpipe(serial->dev, | 1430 | usb_sndbulkpipe(serial->dev, |
@@ -1732,10 +1719,9 @@ static int mos7840_send_cmd_write_baud_rate(struct moschip_port *mos7840_port, | |||
1732 | if (mos7840_serial_paranoia_check(port->serial, __func__)) | 1719 | if (mos7840_serial_paranoia_check(port->serial, __func__)) |
1733 | return -1; | 1720 | return -1; |
1734 | 1721 | ||
1735 | number = mos7840_port->port->number - mos7840_port->port->serial->minor; | 1722 | number = mos7840_port->port->port_number; |
1736 | 1723 | ||
1737 | dev_dbg(&port->dev, "%s - port = %d, baud = %d\n", __func__, | 1724 | dev_dbg(&port->dev, "%s - baud = %d\n", __func__, baudRate); |
1738 | mos7840_port->port->number, baudRate); | ||
1739 | /* reset clk_uart_sel in spregOffset */ | 1725 | /* reset clk_uart_sel in spregOffset */ |
1740 | if (baudRate > 115200) { | 1726 | if (baudRate > 115200) { |
1741 | #ifdef HW_flow_control | 1727 | #ifdef HW_flow_control |
@@ -2016,7 +2002,6 @@ static void mos7840_set_termios(struct tty_struct *tty, | |||
2016 | tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); | 2002 | tty->termios.c_cflag, RELEVANT_IFLAG(tty->termios.c_iflag)); |
2017 | dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, | 2003 | dev_dbg(&port->dev, "%s - old clfag %08x old iflag %08x\n", __func__, |
2018 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); | 2004 | old_termios->c_cflag, RELEVANT_IFLAG(old_termios->c_iflag)); |
2019 | dev_dbg(&port->dev, "%s - port %d\n", __func__, port->number); | ||
2020 | 2005 | ||
2021 | /* change the port settings to the new ones specified */ | 2006 | /* change the port settings to the new ones specified */ |
2022 | 2007 | ||
@@ -2084,7 +2069,7 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port, | |||
2084 | 2069 | ||
2085 | tmp.type = PORT_16550A; | 2070 | tmp.type = PORT_16550A; |
2086 | tmp.line = mos7840_port->port->serial->minor; | 2071 | tmp.line = mos7840_port->port->serial->minor; |
2087 | tmp.port = mos7840_port->port->number; | 2072 | tmp.port = mos7840_port->port->port_number; |
2088 | tmp.irq = 0; | 2073 | tmp.irq = 0; |
2089 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; | 2074 | tmp.flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ; |
2090 | tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; | 2075 | tmp.xmit_fifo_size = NUM_URBS * URB_TRANSFER_BUFFER_SIZE; |
@@ -2240,7 +2225,7 @@ static int mos7840_port_probe(struct usb_serial_port *port) | |||
2240 | /* we set up the pointers to the endpoints in the mos7840_open * | 2225 | /* we set up the pointers to the endpoints in the mos7840_open * |
2241 | * function, as the structures aren't created yet. */ | 2226 | * function, as the structures aren't created yet. */ |
2242 | 2227 | ||
2243 | pnum = port->number - serial->minor; | 2228 | pnum = port->port_number; |
2244 | 2229 | ||
2245 | dev_dbg(&port->dev, "mos7840_startup: configuring port %d\n", pnum); | 2230 | dev_dbg(&port->dev, "mos7840_startup: configuring port %d\n", pnum); |
2246 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); | 2231 | mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL); |
@@ -2261,7 +2246,6 @@ static int mos7840_port_probe(struct usb_serial_port *port) | |||
2261 | * usb-serial.c:get_free_serial() and cannot therefore be used | 2246 | * usb-serial.c:get_free_serial() and cannot therefore be used |
2262 | * to index device instances */ | 2247 | * to index device instances */ |
2263 | mos7840_port->port_num = pnum + 1; | 2248 | mos7840_port->port_num = pnum + 1; |
2264 | dev_dbg(&port->dev, "port->number = %d\n", port->number); | ||
2265 | dev_dbg(&port->dev, "port->serial->minor = %d\n", port->serial->minor); | 2249 | dev_dbg(&port->dev, "port->serial->minor = %d\n", port->serial->minor); |
2266 | dev_dbg(&port->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num); | 2250 | dev_dbg(&port->dev, "mos7840_port->port_num = %d\n", mos7840_port->port_num); |
2267 | dev_dbg(&port->dev, "serial->minor = %d\n", serial->minor); | 2251 | dev_dbg(&port->dev, "serial->minor = %d\n", serial->minor); |