#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";
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);
}
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;
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);