提交 14a37ec6 编写于 作者: S Sudip Mukherjee 提交者: Felipe Balbi

usb: gadget: amd5536udc: rewrite init_dma_pools

A rewrite of init_dma_pools() with proper error handling.
Signed-off-by: NSudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 ec4cc657
...@@ -3169,8 +3169,7 @@ static int init_dma_pools(struct udc *dev) ...@@ -3169,8 +3169,7 @@ static int init_dma_pools(struct udc *dev)
sizeof(struct udc_data_dma), 0, 0); sizeof(struct udc_data_dma), 0, 0);
if (!dev->data_requests) { if (!dev->data_requests) {
DBG(dev, "can't get request data pool\n"); DBG(dev, "can't get request data pool\n");
retval = -ENOMEM; return -ENOMEM;
goto finished;
} }
/* EP0 in dma regs = dev control regs */ /* EP0 in dma regs = dev control regs */
...@@ -3182,14 +3181,14 @@ static int init_dma_pools(struct udc *dev) ...@@ -3182,14 +3181,14 @@ static int init_dma_pools(struct udc *dev)
if (!dev->stp_requests) { if (!dev->stp_requests) {
DBG(dev, "can't get stp request pool\n"); DBG(dev, "can't get stp request pool\n");
retval = -ENOMEM; retval = -ENOMEM;
goto finished; goto err_create_dma_pool;
} }
/* setup */ /* setup */
td_stp = dma_pool_alloc(dev->stp_requests, GFP_KERNEL, td_stp = dma_pool_alloc(dev->stp_requests, GFP_KERNEL,
&dev->ep[UDC_EP0OUT_IX].td_stp_dma); &dev->ep[UDC_EP0OUT_IX].td_stp_dma);
if (td_stp == NULL) { if (td_stp == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto finished; goto err_alloc_dma;
} }
dev->ep[UDC_EP0OUT_IX].td_stp = td_stp; dev->ep[UDC_EP0OUT_IX].td_stp = td_stp;
...@@ -3198,12 +3197,20 @@ static int init_dma_pools(struct udc *dev) ...@@ -3198,12 +3197,20 @@ static int init_dma_pools(struct udc *dev)
&dev->ep[UDC_EP0OUT_IX].td_phys); &dev->ep[UDC_EP0OUT_IX].td_phys);
if (td_data == NULL) { if (td_data == NULL) {
retval = -ENOMEM; retval = -ENOMEM;
goto finished; goto err_alloc_phys;
} }
dev->ep[UDC_EP0OUT_IX].td = td_data; dev->ep[UDC_EP0OUT_IX].td = td_data;
return 0; 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; return retval;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册