greybus: es2: fix up usb probe error messages
[cascardo/linux.git] / drivers / staging / greybus / es2.c
index 69123b7..6cb13fc 100644 (file)
@@ -46,15 +46,6 @@ MODULE_DEVICE_TABLE(usb, id_table);
 
 #define APB1_LOG_SIZE          SZ_16K
 
-/* Number of bulk in and bulk out couple */
-#define NUM_BULKS              1
-
-/* Expected number of bulk out endpoints */
-#define NUM_BULKS_OUT          NUM_BULKS
-
-/* Expected number of bulk in endpoints (including ARPC endpoint) */
-#define NUM_BULKS_IN           (NUM_BULKS + 1)
-
 /*
  * Number of CPort IN urbs in flight at any point in time.
  * Adjust if we are having stalls in the USB buffer due to not enough urbs in
@@ -65,7 +56,7 @@ MODULE_DEVICE_TABLE(usb, id_table);
 /* Number of CPort OUT urbs in flight at any point in time.
  * Adjust if we get messages saying we are out of urbs in the system log.
  */
-#define NUM_CPORT_OUT_URB      (8 * NUM_BULKS)
+#define NUM_CPORT_OUT_URB      8
 
 /*
  * Number of ARPC in urbs in flight at any point in time.
@@ -920,6 +911,7 @@ static int check_urb_status(struct urb *urb)
 static void es2_destroy(struct es2_ap_dev *es2)
 {
        struct usb_device *udev;
+       struct urb *urb;
        int i;
 
        debugfs_remove(es2->apb_log_enable_dentry);
@@ -927,10 +919,7 @@ static void es2_destroy(struct es2_ap_dev *es2)
 
        /* Tear down everything! */
        for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
-               struct urb *urb = es2->cport_out_urb[i];
-
-               if (!urb)
-                       break;
+               urb = es2->cport_out_urb[i];
                usb_kill_urb(urb);
                usb_free_urb(urb);
                es2->cport_out_urb[i] = NULL;
@@ -938,11 +927,7 @@ static void es2_destroy(struct es2_ap_dev *es2)
        }
 
        for (i = 0; i < NUM_ARPC_IN_URB; ++i) {
-               struct urb *urb = es2->arpc_urb[i];
-
-               if (!urb)
-                       break;
-               usb_free_urb(urb);
+               usb_free_urb(es2->arpc_urb[i]);
                kfree(es2->arpc_buffer[i]);
                es2->arpc_buffer[i] = NULL;
        }
@@ -1403,6 +1388,7 @@ static int ap_probe(struct usb_interface *interface,
        struct usb_device *udev;
        struct usb_host_interface *iface_desc;
        struct usb_endpoint_descriptor *endpoint;
+       __u8 ep_addr;
        int retval;
        int i;
        int num_cports;
@@ -1450,26 +1436,36 @@ static int ap_probe(struct usb_interface *interface,
        iface_desc = interface->cur_altsetting;
        for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
                endpoint = &iface_desc->endpoint[i].desc;
+               ep_addr = endpoint->bEndpointAddress;
 
                if (usb_endpoint_is_bulk_in(endpoint)) {
                        if (!bulk_in_found) {
-                               es2->cport_in.endpoint =
-                                       endpoint->bEndpointAddress;
+                               es2->cport_in.endpoint = ep_addr;
                                bulk_in_found = true;
                        } else if (!arpc_in_found) {
-                               es2->arpc_endpoint_in =
-                                       endpoint->bEndpointAddress;
+                               es2->arpc_endpoint_in = ep_addr;
                                arpc_in_found = true;
+                       } else {
+                               dev_warn(&udev->dev,
+                                        "Unused bulk IN endpoint found: 0x%02x\n",
+                                        ep_addr);
+                       }
+                       continue;
+               }
+               if (usb_endpoint_is_bulk_out(endpoint)) {
+                       if (!bulk_out_found) {
+                               es2->cport_out_endpoint = ep_addr;
+                               bulk_out_found = true;
+                       } else {
+                               dev_warn(&udev->dev,
+                                        "Unused bulk OUT endpoint found: 0x%02x\n",
+                                        ep_addr);
                        }
-               } else if (usb_endpoint_is_bulk_out(endpoint) &&
-                          (!bulk_out_found)) {
-                       es2->cport_out_endpoint = endpoint->bEndpointAddress;
-                       bulk_out_found = true;
-               } else {
-                       dev_err(&udev->dev,
-                               "Unknown endpoint type found, address 0x%02x\n",
-                               endpoint->bEndpointAddress);
+                       continue;
                }
+               dev_warn(&udev->dev,
+                        "Unknown endpoint type found, address 0x%02x\n",
+                        ep_addr);
        }
        if (!bulk_in_found || !arpc_in_found || !bulk_out_found) {
                dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n");