usb: gadget: amd5536udc: fix error path

Handle the error properly instead of calling the pci remove function.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
This commit is contained in:
Sudip Mukherjee 2015-09-22 18:54:27 +05:30 committed by Felipe Balbi
parent 14a37ec6c1
commit 580693bb3b

View file

@ -3107,6 +3107,17 @@ static void udc_remove(struct udc *dev)
udc = NULL; udc = NULL;
} }
/* free all the dma pools */
static void free_dma_pools(struct udc *dev)
{
dma_pool_free(dev->stp_requests, dev->ep[UDC_EP0OUT_IX].td,
dev->ep[UDC_EP0OUT_IX].td_phys);
dma_pool_free(dev->stp_requests, dev->ep[UDC_EP0OUT_IX].td_stp,
dev->ep[UDC_EP0OUT_IX].td_stp_dma);
dma_pool_destroy(dev->stp_requests);
dma_pool_destroy(dev->data_requests);
}
/* Reset all pci context */ /* Reset all pci context */
static void udc_pci_remove(struct pci_dev *pdev) static void udc_pci_remove(struct pci_dev *pdev)
{ {
@ -3297,7 +3308,7 @@ static int udc_pci_probe(
if (use_dma) { if (use_dma) {
retval = init_dma_pools(dev); retval = init_dma_pools(dev);
if (retval != 0) if (retval != 0)
goto finished; goto err_dma;
} }
dev->phys_addr = resource; dev->phys_addr = resource;
@ -3305,13 +3316,17 @@ static int udc_pci_probe(
dev->pdev = pdev; dev->pdev = pdev;
/* general probing */ /* general probing */
if (udc_probe(dev) == 0) if (udc_probe(dev)) {
return 0; retval = -ENODEV;
goto err_probe;
finished: }
udc_pci_remove(pdev); return 0;
return retval;
err_probe:
if (use_dma)
free_dma_pools(dev);
err_dma:
free_irq(pdev->irq, dev);
err_irq: err_irq:
iounmap(dev->virt_addr); iounmap(dev->virt_addr);
err_ioremap: err_ioremap: