summaryrefslogtreecommitdiffstats
path: root/drivers/usb/serial/mos7840.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-16 17:13:47 +0100
committerJohan Hovold <johan@kernel.org>2017-03-28 11:00:12 +0200
commit95254020235aa0c0f12bfb7d9b4cd18730dfc499 (patch)
tree46e5f4b1123fb4a988e903ec39de50082effcbc9 /drivers/usb/serial/mos7840.c
parent6a1eaf19f525ed9e4fa09ed1f05c6502a90b4ccb (diff)
downloadblackbird-op-linux-95254020235aa0c0f12bfb7d9b4cd18730dfc499.tar.gz
blackbird-op-linux-95254020235aa0c0f12bfb7d9b4cd18730dfc499.zip
USB: serial: mos7840: clean up endpoint sanity check
Clean up the endpoint sanity check by letting core verify the single interrupt endpoint, and verifying the bulk endpoints in calc_num_ports after having determined the number of ports. Note that the static type num_ports field was neither correct or used (since calc_num_ports never returns zero). Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb/serial/mos7840.c')
-rw-r--r--drivers/usb/serial/mos7840.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c
index 326d6c5055ef..770b3a470232 100644
--- a/drivers/usb/serial/mos7840.c
+++ b/drivers/usb/serial/mos7840.c
@@ -2108,23 +2108,23 @@ static int mos7840_calc_num_ports(struct usb_serial *serial,
struct usb_serial_endpoints *epds)
{
int device_type = (unsigned long)usb_get_serial_data(serial);
- int mos7840_num_ports;
+ int num_ports;
- mos7840_num_ports = (device_type >> 4) & 0x000F;
+ num_ports = (device_type >> 4) & 0x000F;
- return mos7840_num_ports;
-}
+ /*
+ * num_ports is currently never zero as device_type is one of
+ * MOSCHIP_DEVICE_ID_78{1,2,4}0.
+ */
+ if (num_ports == 0)
+ return -ENODEV;
-static int mos7840_attach(struct usb_serial *serial)
-{
- if (serial->num_bulk_in < serial->num_ports ||
- serial->num_bulk_out < serial->num_ports ||
- serial->num_interrupt_in < 1) {
+ if (epds->num_bulk_in < num_ports || epds->num_bulk_out < num_ports) {
dev_err(&serial->interface->dev, "missing endpoints\n");
return -ENODEV;
}
- return 0;
+ return num_ports;
}
static int mos7840_port_probe(struct usb_serial_port *port)
@@ -2385,7 +2385,7 @@ static struct usb_serial_driver moschip7840_4port_device = {
},
.description = DRIVER_DESC,
.id_table = id_table,
- .num_ports = 4,
+ .num_interrupt_in = 1,
.open = mos7840_open,
.close = mos7840_close,
.write = mos7840_write,
@@ -2402,7 +2402,6 @@ static struct usb_serial_driver moschip7840_4port_device = {
.tiocmset = mos7840_tiocmset,
.tiocmiwait = usb_serial_generic_tiocmiwait,
.get_icount = usb_serial_generic_get_icount,
- .attach = mos7840_attach,
.port_probe = mos7840_port_probe,
.port_remove = mos7840_port_remove,
.read_bulk_callback = mos7840_bulk_in_callback,
OpenPOWER on IntegriCloud