Skip to content

Commit

Permalink
usb: gadget: drop null test before destroy functions
Browse files Browse the repository at this point in the history
Remove unneeded NULL test.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ expression x; @@
-if (x != NULL)
  \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Julia Lawall authored and Felipe Balbi committed Sep 21, 2015
1 parent 9a9ce1d commit 51b91b7
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions drivers/usb/gadget/udc/bdc/bdc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,7 @@ static void bdc_mem_free(struct bdc *bdc)
bdc->scratchpad.buff, bdc->scratchpad.sp_dma);

/* Destroy the dma pools */
if (bdc->bd_table_pool)
dma_pool_destroy(bdc->bd_table_pool);
dma_pool_destroy(bdc->bd_table_pool);

/* Free the bdc_ep array */
kfree(bdc->bdc_ep_array);
Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/gadget/udc/gr_udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2117,8 +2117,7 @@ static int gr_remove(struct platform_device *pdev)
return -EBUSY;

gr_dfs_delete(dev);
if (dev->desc_pool)
dma_pool_destroy(dev->desc_pool);
dma_pool_destroy(dev->desc_pool);
platform_set_drvdata(pdev, NULL);

gr_free_request(&dev->epi[0].ep, &dev->ep0reqi->req);
Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/gadget/udc/mv_u3d_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,8 +1767,7 @@ static int mv_u3d_remove(struct platform_device *dev)
usb_del_gadget_udc(&u3d->gadget);

/* free memory allocated in probe */
if (u3d->trb_pool)
dma_pool_destroy(u3d->trb_pool);
dma_pool_destroy(u3d->trb_pool);

if (u3d->ep_context)
dma_free_coherent(&dev->dev, u3d->ep_context_size,
Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/gadget/udc/mv_udc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2100,8 +2100,7 @@ static int mv_udc_remove(struct platform_device *pdev)
}

/* free memory allocated in probe */
if (udc->dtd_pool)
dma_pool_destroy(udc->dtd_pool);
dma_pool_destroy(udc->dtd_pool);

if (udc->ep_dqh)
dma_free_coherent(&pdev->dev, udc->ep_dqh_size,
Expand Down

0 comments on commit 51b91b7

Please sign in to comment.