aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-01-03 10:39:53 -0500
committerJohan Hovold <johan@kernel.org>2017-01-04 04:37:20 -0500
commitfde1faf872ed86d88e245191bc15a8e57368cd1c (patch)
treef8c2a8ae64f45c21be3fae46b267bb1152d8b0f5
parent75dd211e773afcbc264677b0749d1cf7d937ab2d (diff)
USB: serial: mos7720: fix parallel probe
A static usb-serial-driver structure that is used to initialise the interrupt URB was modified during probe depending on the currently probed device type, something which could break a parallel probe of a device of a different type. Fix this up by overriding the default completion callback for MCS7715 devices in attach() instead. We may want to use two usb-serial driver instances for the two types later. Fixes: fb088e335d78 ("USB: serial: add support for serial port on the moschip 7715") Cc: stable <stable@vger.kernel.org> Signed-off-by: Johan Hovold <johan@kernel.org>
-rw-r--r--drivers/usb/serial/mos7720.c30
1 files changed, 7 insertions, 23 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index e494821ae528..d6c4441db5f8 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -65,8 +65,6 @@ struct moschip_port {
65 struct urb *write_urb_pool[NUM_URBS]; 65 struct urb *write_urb_pool[NUM_URBS];
66}; 66};
67 67
68static struct usb_serial_driver moschip7720_2port_driver;
69
70#define USB_VENDOR_ID_MOSCHIP 0x9710 68#define USB_VENDOR_ID_MOSCHIP 0x9710
71#define MOSCHIP_DEVICE_ID_7720 0x7720 69#define MOSCHIP_DEVICE_ID_7720 0x7720
72#define MOSCHIP_DEVICE_ID_7715 0x7715 70#define MOSCHIP_DEVICE_ID_7715 0x7715
@@ -970,25 +968,6 @@ static void mos7720_bulk_out_data_callback(struct urb *urb)
970 tty_port_tty_wakeup(&mos7720_port->port->port); 968 tty_port_tty_wakeup(&mos7720_port->port->port);
971} 969}
972 970
973/*
974 * mos77xx_probe
975 * this function installs the appropriate read interrupt endpoint callback
976 * depending on whether the device is a 7720 or 7715, thus avoiding costly
977 * run-time checks in the high-frequency callback routine itself.
978 */
979static int mos77xx_probe(struct usb_serial *serial,
980 const struct usb_device_id *id)
981{
982 if (id->idProduct == MOSCHIP_DEVICE_ID_7715)
983 moschip7720_2port_driver.read_int_callback =
984 mos7715_interrupt_callback;
985 else
986 moschip7720_2port_driver.read_int_callback =
987 mos7720_interrupt_callback;
988
989 return 0;
990}
991
992static int mos77xx_calc_num_ports(struct usb_serial *serial) 971static int mos77xx_calc_num_ports(struct usb_serial *serial)
993{ 972{
994 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct); 973 u16 product = le16_to_cpu(serial->dev->descriptor.idProduct);
@@ -1946,6 +1925,12 @@ static int mos7720_startup(struct usb_serial *serial)
1946 tmp->interrupt_in_endpointAddress; 1925 tmp->interrupt_in_endpointAddress;
1947 serial->port[1]->interrupt_in_urb = NULL; 1926 serial->port[1]->interrupt_in_urb = NULL;
1948 serial->port[1]->interrupt_in_buffer = NULL; 1927 serial->port[1]->interrupt_in_buffer = NULL;
1928
1929 if (serial->port[0]->interrupt_in_urb) {
1930 struct urb *urb = serial->port[0]->interrupt_in_urb;
1931
1932 urb->complete = mos7715_interrupt_callback;
1933 }
1949 } 1934 }
1950 1935
1951 /* setting configuration feature to one */ 1936 /* setting configuration feature to one */
@@ -2060,7 +2045,6 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2060 .close = mos7720_close, 2045 .close = mos7720_close,
2061 .throttle = mos7720_throttle, 2046 .throttle = mos7720_throttle,
2062 .unthrottle = mos7720_unthrottle, 2047 .unthrottle = mos7720_unthrottle,
2063 .probe = mos77xx_probe,
2064 .attach = mos7720_startup, 2048 .attach = mos7720_startup,
2065 .release = mos7720_release, 2049 .release = mos7720_release,
2066 .port_probe = mos7720_port_probe, 2050 .port_probe = mos7720_port_probe,
@@ -2074,7 +2058,7 @@ static struct usb_serial_driver moschip7720_2port_driver = {
2074 .chars_in_buffer = mos7720_chars_in_buffer, 2058 .chars_in_buffer = mos7720_chars_in_buffer,
2075 .break_ctl = mos7720_break, 2059 .break_ctl = mos7720_break,
2076 .read_bulk_callback = mos7720_bulk_in_callback, 2060 .read_bulk_callback = mos7720_bulk_in_callback,
2077 .read_int_callback = NULL /* dynamically assigned in probe() */ 2061 .read_int_callback = mos7720_interrupt_callback,
2078}; 2062};
2079 2063
2080static struct usb_serial_driver * const serial_drivers[] = { 2064static struct usb_serial_driver * const serial_drivers[] = {