Merge branch 'master' of git://git.denx.de/u-boot-usb
[oweals/u-boot.git] / drivers / usb / host / ehci-hcd.c
index 0ffd6f19ae9c641459129a09ef499dcc2e5a89c9..bc7606646bbcf9ac76ab679a8f85405ceaa6d45a 100644 (file)
@@ -910,7 +910,7 @@ ehci_submit_root(struct usb_device *dev, unsigned long pipe, void *buffer,
        }
 
        mdelay(1);
-       len = min3(srclen, le16_to_cpu(req->length), length);
+       len = min3(srclen, (int)le16_to_cpu(req->length), length);
        if (srcptr != NULL && len > 0)
                memcpy(buffer, srcptr, len);
        else
@@ -971,7 +971,6 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
        qh_list->qh_link = cpu_to_hc32((uint32_t)qh_list | QH_LINK_TYPE_QH);
        qh_list->qh_endpt1 = cpu_to_hc32(QH_ENDPT1_H(1) |
                                                QH_ENDPT1_EPS(USB_SPEED_HIGH));
-       qh_list->qh_curtd = cpu_to_hc32(QT_NEXT_TERMINATE);
        qh_list->qh_overlay.qt_next = cpu_to_hc32(QT_NEXT_TERMINATE);
        qh_list->qh_overlay.qt_altnext = cpu_to_hc32(QT_NEXT_TERMINATE);
        qh_list->qh_overlay.qt_token =
@@ -1097,6 +1096,7 @@ submit_control_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
 }
 
 struct int_queue {
+       int elementsize;
        struct QH *first;
        struct QH *current;
        struct QH *last;
@@ -1191,6 +1191,7 @@ create_int_queue(struct usb_device *dev, unsigned long pipe, int queuesize,
                debug("ehci intr queue: out of memory\n");
                goto fail1;
        }
+       result->elementsize = elementsize;
        result->first = memalign(USB_DMA_MINALIGN,
                                 sizeof(struct QH) * queuesize);
        if (!result->first) {
@@ -1327,13 +1328,18 @@ void *poll_int_queue(struct usb_device *dev, struct int_queue *queue)
                queue->current++;
        else
                queue->current = NULL;
+
+       invalidate_dcache_range((uint32_t)cur->buffer,
+                               ALIGN_END_ADDR(char, cur->buffer,
+                                              queue->elementsize));
+
        debug("Exit poll_int_queue with completed intr transfer. token is %x at %p (first at %p)\n",
              hc32_to_cpu(cur_td->qt_token), cur, queue->first);
        return cur->buffer;
 }
 
 /* Do not free buffers associated with QHs, they're owned by someone else */
-static int
+int
 destroy_int_queue(struct usb_device *dev, struct int_queue *queue)
 {
        struct ehci_ctrl *ctrl = dev->controller;
@@ -1410,9 +1416,6 @@ submit_int_msg(struct usb_device *dev, unsigned long pipe, void *buffer,
                return -EINVAL;
        }
 
-       invalidate_dcache_range((uint32_t)buffer,
-                               ALIGN_END_ADDR(char, buffer, length));
-
        ret = destroy_int_queue(dev, queue);
        if (ret < 0)
                return ret;