usb: gadget: fsl_udc: Use dma_alloc_coherent to allocate the status buffer

Change-Id: I7c17b7f8a8b89c6a687f6e2604542dabecc4cfa7
Signed-off-by: Benoit Goby <benoit@android.com>
This commit is contained in:
Benoit Goby
2010-09-23 17:58:55 -07:00
committed by Colin Cross
parent 04ace134c9
commit 3cea820b3c

View File

@@ -57,6 +57,7 @@
#define DRIVER_VERSION "Apr 20, 2007"
#define DMA_ADDR_INVALID (~(dma_addr_t)0)
#define STATUS_BUFFER_SIZE 8
#ifdef CONFIG_ARCH_TEGRA
static const char driver_name[] = "fsl-tegra-udc";
@@ -2273,8 +2274,10 @@ static int fsl_proc_read(char *page, char **start, off_t off, int count,
static void fsl_udc_release(struct device *dev)
{
complete(udc_controller->done);
#ifndef CONFIG_ARCH_TEGRA
dma_free_coherent(dev->parent, udc_controller->ep_qh_size,
udc_controller->ep_qh, udc_controller->ep_qh_dma);
#endif
kfree(udc_controller);
}
@@ -2331,8 +2334,17 @@ static int __init struct_udc_setup(struct fsl_udc *udc,
udc->status_req = container_of(fsl_alloc_request(NULL, GFP_KERNEL),
struct fsl_req, req);
/* allocate a small amount of memory to get valid address */
udc->status_req->req.buf = kmalloc(8, GFP_KERNEL);
udc->status_req->req.dma = virt_to_phys(udc->status_req->req.buf);
udc->status_req->req.buf = dma_alloc_coherent(&pdev->dev,
STATUS_BUFFER_SIZE, &udc->status_req->req.dma,
GFP_KERNEL);
if (!udc->status_req->req.buf) {
ERR("alloc status_req buffer failed\n");
#ifndef CONFIG_ARCH_TEGRA
dma_free_coherent(&pdev->dev, size, udc->ep_qh, udc->ep_qh_dma);
#endif
kfree(udc->eps);
return -ENOMEM;
}
udc->resume_state = USB_STATE_NOTATTACHED;
udc->usb_state = USB_STATE_POWERED;
@@ -2592,7 +2604,9 @@ static int __exit fsl_udc_remove(struct platform_device *pdev)
remove_proc_file();
/* Free allocated memory */
kfree(udc_controller->status_req->req.buf);
dma_free_coherent(&pdev->dev, STATUS_BUFFER_SIZE,
udc_controller->status_req->req.buf,
udc_controller->status_req->req.dma);
kfree(udc_controller->status_req);
kfree(udc_controller->eps);