]> git.sur5r.net Git - u-boot/blobdiff - common/usb.c
sdhci: Add sdhci support for spear devices
[u-boot] / common / usb.c
index 1c9763cb6ca50ef9816c95c2d6e0dc75952730a4..6fc0fc1c0ec75fe34f100cbfb03b207628b32885 100644 (file)
@@ -492,9 +492,9 @@ int usb_get_configuration_no(struct usb_device *dev,
 {
        int result;
        unsigned int tmp;
-       struct usb_configuration_descriptor *config;
+       struct usb_config_descriptor *config;
 
-       config = (struct usb_configuration_descriptor *)&buffer[0];
+       config = (struct usb_config_descriptor *)&buffer[0];
        result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 9);
        if (result < 9) {
                if (result < 0)
@@ -508,8 +508,8 @@ int usb_get_configuration_no(struct usb_device *dev,
        tmp = le16_to_cpu(config->wTotalLength);
 
        if (tmp > USB_BUFSIZ) {
-               USB_PRINTF("usb_get_configuration_no: failed to get " \
-                          "descriptor - too long: %d\n", tmp);
+               printf("usb_get_configuration_no: failed to get " \
+                      "descriptor - too long: %d\n", tmp);
                return -1;
        }
 
@@ -805,6 +805,18 @@ struct usb_device *usb_alloc_new_device(void *controller)
        return &usb_dev[dev_index - 1];
 }
 
+/*
+ * Free the newly created device node.
+ * Called in error cases where configuring a newly attached
+ * device fails for some reason.
+ */
+void usb_free_device(void)
+{
+       dev_index--;
+       USB_PRINTF("Freeing device node: %d\n", dev_index);
+       memset(&usb_dev[dev_index], 0, sizeof(struct usb_device));
+       usb_dev[dev_index].devnum = -1;
+}
 
 /*
  * By the time we get here, the device has gotten a new device ID
@@ -946,7 +958,13 @@ int usb_new_device(struct usb_device *dev)
        le16_to_cpus(&dev->descriptor.idProduct);
        le16_to_cpus(&dev->descriptor.bcdDevice);
        /* only support for one config for now */
-       usb_get_configuration_no(dev, tmpbuf, 0);
+       err = usb_get_configuration_no(dev, tmpbuf, 0);
+       if (err < 0) {
+               printf("usb_new_device: Cannot read configuration, " \
+                      "skipping device %04x:%04x\n",
+                      dev->descriptor.idVendor, dev->descriptor.idProduct);
+               return -1;
+       }
        usb_parse_config(dev, tmpbuf, 0);
        usb_set_maxpacket(dev);
        /* we set the default configuration here */