]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/usb.c
MAINTAINERS: fix Andreas Bießmann AVR32 entry
[karo-tx-uboot.git] / common / usb.c
index 1ec30bc058f708ea46b612aff8d3f3340b5dca68..1b40228b28836697b5cb4715dd269a21c995ac3e 100644 (file)
@@ -47,6 +47,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/processor.h>
+#include <linux/compiler.h>
 #include <linux/ctype.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -169,7 +170,7 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
                        unsigned short value, unsigned short index,
                        void *data, unsigned short size, int timeout)
 {
-       struct devrequest setup_packet;
+       ALLOC_CACHE_ALIGN_BUFFER(struct devrequest, setup_packet, 1);
 
        if ((timeout == 0) && (!asynch_allowed)) {
                /* request for a asynch control pipe is not allowed */
@@ -177,17 +178,18 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe,
        }
 
        /* set setup command */
-       setup_packet.requesttype = requesttype;
-       setup_packet.request = request;
-       setup_packet.value = cpu_to_le16(value);
-       setup_packet.index = cpu_to_le16(index);
-       setup_packet.length = cpu_to_le16(size);
+       setup_packet->requesttype = requesttype;
+       setup_packet->request = request;
+       setup_packet->value = cpu_to_le16(value);
+       setup_packet->index = cpu_to_le16(index);
+       setup_packet->length = cpu_to_le16(size);
        USB_PRINTF("usb_control_msg: request: 0x%X, requesttype: 0x%X, " \
                   "value 0x%X index 0x%X length 0x%X\n",
                   request, requesttype, value, index, size);
        dev->status = USB_ST_NOT_PROC; /*not yet processed */
 
-       submit_control_msg(dev, pipe, data, size, &setup_packet);
+       if (submit_control_msg(dev, pipe, data, size, setup_packet) < 0)
+               return -1;
        if (timeout == 0)
                return (int)size;
 
@@ -219,7 +221,8 @@ int usb_bulk_msg(struct usb_device *dev, unsigned int pipe,
        if (len < 0)
                return -1;
        dev->status = USB_ST_NOT_PROC; /*not yet processed */
-       submit_bulk_msg(dev, pipe, data, len);
+       if (submit_bulk_msg(dev, pipe, data, len) < 0)
+               return -1;
        while (timeout--) {
                if (!((volatile unsigned long)dev->status & USB_ST_NOT_PROC))
                        break;
@@ -261,7 +264,7 @@ int usb_maxpacket(struct usb_device *dev, unsigned long pipe)
  *
  * NOTE: Similar behaviour was observed with GCC4.6 on ARMv5.
  */
-static void  __attribute__((noinline))
+static void noinline
 usb_set_maxpacket_ep(struct usb_device *dev, int if_idx, int ep_idx)
 {
        int b;
@@ -681,7 +684,7 @@ static int usb_string_sub(struct usb_device *dev, unsigned int langid,
  */
 int usb_string(struct usb_device *dev, int index, char *buf, size_t size)
 {
-       unsigned char mybuf[USB_BUFSIZ];
+       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, mybuf, USB_BUFSIZ);
        unsigned char *tbuf;
        int err;
        unsigned int u, idx;
@@ -781,7 +784,7 @@ int usb_new_device(struct usb_device *dev)
 {
        int addr, err;
        int tmp;
-       unsigned char tmpbuf[USB_BUFSIZ];
+       ALLOC_CACHE_ALIGN_BUFFER(unsigned char, tmpbuf, USB_BUFSIZ);
 
        /* We still haven't set the Address yet */
        addr = dev->devnum;
@@ -798,12 +801,13 @@ int usb_new_device(struct usb_device *dev)
        dev->epmaxpacketin[0] = 8;
        dev->epmaxpacketout[0] = 8;
 
-       err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, &dev->descriptor, 8);
+       err = usb_get_descriptor(dev, USB_DT_DEVICE, 0, tmpbuf, 8);
        if (err < 8) {
                printf("\n      USB device not responding, " \
                       "giving up (status=%lX)\n", dev->status);
                return 1;
        }
+       memcpy(&dev->descriptor, tmpbuf, 8);
 #else
        /* This is a Windows scheme of initialization sequence, with double
         * reset of the device (Linux uses the same sequence)
@@ -892,7 +896,7 @@ int usb_new_device(struct usb_device *dev)
        tmp = sizeof(dev->descriptor);
 
        err = usb_get_descriptor(dev, USB_DT_DEVICE, 0,
-                                &dev->descriptor, sizeof(dev->descriptor));
+                                tmpbuf, sizeof(dev->descriptor));
        if (err < tmp) {
                if (err < 0)
                        printf("unable to get device descriptor (error=%d)\n",
@@ -902,14 +906,15 @@ int usb_new_device(struct usb_device *dev)
                                "(expected %i, got %i)\n", tmp, err);
                return 1;
        }
+       memcpy(&dev->descriptor, tmpbuf, sizeof(dev->descriptor));
        /* correct le values */
        le16_to_cpus(&dev->descriptor.bcdUSB);
        le16_to_cpus(&dev->descriptor.idVendor);
        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], 0);
-       usb_parse_config(dev, &tmpbuf[0], 0);
+       usb_get_configuration_no(dev, tmpbuf, 0);
+       usb_parse_config(dev, tmpbuf, 0);
        usb_set_maxpacket(dev);
        /* we set the default configuration here */
        if (usb_set_configuration(dev, dev->config.desc.bConfigurationValue)) {