diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2015-09-22 16:24:26 +0300 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2015-10-01 20:40:19 +0300 |
commit | 14a37ec6c181178a14ffb7d10a57b99ef8e6b3b3 (patch) | |
tree | a45dfbae23b47fd8f9a11961711aa98288df6fed /drivers/usb/gadget/udc/amd5536udc.c | |
parent | ec4cc6579c7334fb334ba2f30214f5c41b16c6e8 (diff) | |
download | linux-14a37ec6c181178a14ffb7d10a57b99ef8e6b3b3.tar.xz |
usb: gadget: amd5536udc: rewrite init_dma_pools
A rewrite of init_dma_pools() with proper error handling.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/udc/amd5536udc.c')
-rw-r--r-- | drivers/usb/gadget/udc/amd5536udc.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index 175ca93fe5e2..38a68582dd6b 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c @@ -3169,8 +3169,7 @@ static int init_dma_pools(struct udc *dev) sizeof(struct udc_data_dma), 0, 0); if (!dev->data_requests) { DBG(dev, "can't get request data pool\n"); - retval = -ENOMEM; - goto finished; + return -ENOMEM; } /* EP0 in dma regs = dev control regs */ @@ -3182,14 +3181,14 @@ static int init_dma_pools(struct udc *dev) if (!dev->stp_requests) { DBG(dev, "can't get stp request pool\n"); retval = -ENOMEM; - goto finished; + goto err_create_dma_pool; } /* setup */ td_stp = dma_pool_alloc(dev->stp_requests, GFP_KERNEL, &dev->ep[UDC_EP0OUT_IX].td_stp_dma); if (td_stp == NULL) { retval = -ENOMEM; - goto finished; + goto err_alloc_dma; } dev->ep[UDC_EP0OUT_IX].td_stp = td_stp; @@ -3198,12 +3197,20 @@ static int init_dma_pools(struct udc *dev) &dev->ep[UDC_EP0OUT_IX].td_phys); if (td_data == NULL) { retval = -ENOMEM; - goto finished; + goto err_alloc_phys; } dev->ep[UDC_EP0OUT_IX].td = td_data; return 0; -finished: +err_alloc_phys: + dma_pool_free(dev->stp_requests, dev->ep[UDC_EP0OUT_IX].td_stp, + dev->ep[UDC_EP0OUT_IX].td_stp_dma); +err_alloc_dma: + dma_pool_destroy(dev->stp_requests); + dev->stp_requests = NULL; +err_create_dma_pool: + dma_pool_destroy(dev->data_requests); + dev->data_requests = NULL; return retval; } |