summaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2017-03-16 17:13:54 +0100
committerJohan Hovold <johan@kernel.org>2017-03-28 11:14:12 +0200
commitbc4c2c15cbfc3747d0c14f547beb5d46cbe43641 (patch)
tree499def73704bbeb4953477c426d98d30a4805e72 /drivers/usb
parentea3c6ebdcb4e6f9e1b16d9ced983a8f9131abd01 (diff)
downloadop-kernel-dev-bc4c2c15cbfc3747d0c14f547beb5d46cbe43641.zip
op-kernel-dev-bc4c2c15cbfc3747d0c14f547beb5d46cbe43641.tar.gz
USB: serial: mxuport: register two ports for unknown devices
Print a message and register two ports for interfaces for which we do not know how many ports there are instead of binding, allocating resources, but not register any ports. This provides a hint that anyone adding a dynamic device id must also provide a reference id (driver info) from which the port count can be retrieved, for example: echo <vid> <pid> 0 0x110A 0x1410 > new_id Signed-off-by: Johan Hovold <johan@kernel.org>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/serial/mxuport.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/drivers/usb/serial/mxuport.c b/drivers/usb/serial/mxuport.c
index bf543e6..3355737 100644
--- a/drivers/usb/serial/mxuport.c
+++ b/drivers/usb/serial/mxuport.c
@@ -950,17 +950,23 @@ static int mxuport_calc_num_ports(struct usb_serial *serial,
struct usb_serial_endpoints *epds)
{
unsigned long features = (unsigned long)usb_get_serial_data(serial);
+ int num_ports;
+
+ if (features & MX_UPORT_2_PORT) {
+ num_ports = 2;
+ } else if (features & MX_UPORT_4_PORT) {
+ num_ports = 4;
+ } else if (features & MX_UPORT_8_PORT) {
+ num_ports = 8;
+ } else if (features & MX_UPORT_16_PORT) {
+ num_ports = 16;
+ } else {
+ dev_warn(&serial->interface->dev,
+ "unknown device, assuming two ports\n");
+ num_ports = 2;
+ }
- if (features & MX_UPORT_2_PORT)
- return 2;
- if (features & MX_UPORT_4_PORT)
- return 4;
- if (features & MX_UPORT_8_PORT)
- return 8;
- if (features & MX_UPORT_16_PORT)
- return 16;
-
- return 0;
+ return num_ports;
}
/* Get the version of the firmware currently running. */
@@ -1367,7 +1373,6 @@ static struct usb_serial_driver mxuport_device = {
},
.description = "MOXA UPort",
.id_table = mxuport_idtable,
- .num_ports = 0,
.probe = mxuport_probe,
.port_probe = mxuport_port_probe,
.attach = mxuport_attach,
OpenPOWER on IntegriCloud