Commit 204cc473 authored by Johan Hovold's avatar Johan Hovold

USB: serial: ipaq: always register a single port

Use the calc_num_ports callback to ignore unused endpoints.

The driver binds to any interface with at least one bulk-in and one
bulk-out endpoint, but some devices can have three or more endpoints of
which only either the first or second pair of endpoints is needed.

This avoids allocating resources for unused endpoints, and specifically
a port is no longer registered for the unused first endpoint pair when
there are more than three endpoints.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
parent 03b72aec
...@@ -555,39 +555,32 @@ static int ipaq_calc_num_ports(struct usb_serial *serial, ...@@ -555,39 +555,32 @@ static int ipaq_calc_num_ports(struct usb_serial *serial,
struct usb_serial_endpoints *epds) struct usb_serial_endpoints *epds)
{ {
/* /*
* some devices have 3 endpoints, the 3rd of which * Some of the devices in ipaq_id_table[] are composite, and we
* must be ignored as it would make the core * shouldn't bind to all the interfaces. This test will rule out
* create a second port which oopses when used * some obviously invalid possibilities.
*/ */
int ipaq_num_ports = 1; if (epds->num_bulk_in == 0 || epds->num_bulk_out == 0)
return -ENODEV;
dev_dbg(&serial->dev->dev, "%s - numberofendpoints: %d\n", __func__,
(int)serial->interface->cur_altsetting->desc.bNumEndpoints);
/* /*
* a few devices have 4 endpoints, seemingly Yakuma devices, * A few devices have four endpoints, seemingly Yakuma devices, and
* and we need the second pair, so let them have 2 ports * we need the second pair.
*
* TODO: can we drop port 1 ?
*/ */
if (serial->interface->cur_altsetting->desc.bNumEndpoints > 3) { if (epds->num_bulk_in > 1 && epds->num_bulk_out > 1) {
ipaq_num_ports = 2; epds->bulk_in[0] = epds->bulk_in[1];
epds->bulk_out[0] = epds->bulk_out[1];
} }
/* /*
* Some of the devices in ipaq_id_table[] are composite, and we * Other devices have 3 endpoints, but we only use the first bulk in
* shouldn't bind to all the interfaces. This test will rule out * and out endpoints.
* some obviously invalid possibilities.
*/ */
if (epds->num_bulk_in < ipaq_num_ports || epds->num_bulk_in = 1;
epds->num_bulk_out < ipaq_num_ports) { epds->num_bulk_out = 1;
return -ENODEV;
}
return ipaq_num_ports; return 1;
} }
static int ipaq_startup(struct usb_serial *serial) static int ipaq_startup(struct usb_serial *serial)
{ {
if (serial->dev->actconfig->desc.bConfigurationValue != 1) { if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
...@@ -601,10 +594,6 @@ static int ipaq_startup(struct usb_serial *serial) ...@@ -601,10 +594,6 @@ static int ipaq_startup(struct usb_serial *serial)
return -ENODEV; return -ENODEV;
} }
dev_dbg(&serial->dev->dev,
"%s - iPAQ module configured for %d ports\n", __func__,
serial->num_ports);
return usb_reset_configuration(serial->dev); return usb_reset_configuration(serial->dev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment