Merge git://git.denx.de/u-boot-socfpga
[platform/kernel/u-boot.git] / drivers / usb / gadget / f_thor.c
index 2596b2e..cd4d9e6 100644 (file)
@@ -17,7 +17,9 @@
 
 #include <errno.h>
 #include <common.h>
+#include <console.h>
 #include <malloc.h>
+#include <memalign.h>
 #include <version.h>
 #include <linux/usb/ch9.h>
 #include <linux/usb/gadget.h>
@@ -568,7 +570,7 @@ static void thor_tx_data(unsigned char *data, int len)
 
        dev->in_req->length = len;
 
-       debug("%s: dev->in_req->length:%d to_cpy:%d\n", __func__,
+       debug("%s: dev->in_req->length:%d to_cpy:%zd\n", __func__,
              dev->in_req->length, sizeof(data));
 
        status = usb_ep_queue(dev->in_ep, dev->in_req, 0);
@@ -775,7 +777,7 @@ static int thor_func_bind(struct usb_configuration *c, struct usb_function *f)
                goto fail;
        }
        dev->req->buf = memalign(CONFIG_SYS_CACHELINE_SIZE,
-                                gadget->ep0->maxpacket);
+                                THOR_PACKET_SIZE);
        if (!dev->req->buf) {
                status = -ENOMEM;
                goto fail;
@@ -889,6 +891,7 @@ static void thor_func_disable(struct usb_function *f)
        }
 
        if (dev->out_ep->driver_data) {
+               free(dev->out_req->buf);
                dev->out_req->buf = NULL;
                usb_ep_free_request(dev->out_ep, dev->out_req);
                usb_ep_disable(dev->out_ep);