USB: serial: ipaq: use calc_num_endpoints to verify endpoints
authorJohan Hovold <johan@kernel.org>
Thu, 16 Mar 2017 16:13:39 +0000 (17:13 +0100)
committerJohan Hovold <johan@kernel.org>
Tue, 28 Mar 2017 09:00:09 +0000 (11:00 +0200)
Use the calc_num_ports rather than attach callback to determine which
interface to bind to in order to avoid allocating port-resources for
interfaces that won't be bound.

Signed-off-by: Johan Hovold <johan@kernel.org>
drivers/usb/serial/ipaq.c

index df5f1a7d7c6ffd92b8ba5d7d6294b25c2373d0f3..c638571f0175b53c663bc3b2284fb9734dbbba16 100644 (file)
@@ -574,20 +574,22 @@ static int ipaq_calc_num_ports(struct usb_serial *serial,
                ipaq_num_ports = 2;
        }
 
+       /*
+        * Some of the devices in ipaq_id_table[] are composite, and we
+        * shouldn't bind to all the interfaces.  This test will rule out
+        * some obviously invalid possibilities.
+        */
+       if (epds->num_bulk_in < ipaq_num_ports ||
+                       epds->num_bulk_out < ipaq_num_ports) {
+               return -ENODEV;
+       }
+
        return ipaq_num_ports;
 }
 
 
 static int ipaq_startup(struct usb_serial *serial)
 {
-       /* Some of the devices in ipaq_id_table[] are composite, and we
-        * shouldn't bind to all the interfaces.  This test will rule out
-        * some obviously invalid possibilities.
-        */
-       if (serial->num_bulk_in < serial->num_ports ||
-                       serial->num_bulk_out < serial->num_ports)
-               return -ENODEV;
-
        if (serial->dev->actconfig->desc.bConfigurationValue != 1) {
                /*
                 * FIXME: HP iPaq rx3715, possibly others, have 1 config that