RE: [PATCH 5/5] dmaengine: fsldma: Use dma_pool_zalloc
From: Yang-Leo Li
Date: Fri Apr 29 2016 - 17:02:36 EST
> -----Original Message-----
> From: Julia Lawall [mailto:Julia.Lawall@xxxxxxx]
> Sent: Friday, April 29, 2016 3:09 PM
> To: Li Yang <leoli@xxxxxxxxxxxxx>
> Cc: kernel-janitors@xxxxxxxxxxxxxxx; Zhang Wei <zw@xxxxxxxxxxxxx>; Vinod
> Koul <vinod.koul@xxxxxxxxx>; Dan Williams <dan.j.williams@xxxxxxxxx>;
> linuxppc-dev@xxxxxxxxxxxxxxxx; dmaengine@xxxxxxxxxxxxxxx; linux-
> kernel@xxxxxxxxxxxxxxx
> Subject: [PATCH 5/5] dmaengine: fsldma: Use dma_pool_zalloc
>
> Dma_pool_zalloc combines dma_pool_alloc and memset 0. The semantic patch
> that makes this transformation is as follows: (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression d,e;
> statement S;
> @@
>
> d =
> - dma_pool_alloc
> + dma_pool_zalloc
> (...);
> if (!d) S
> - memset(d, 0, sizeof(*d));
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@xxxxxxx>
Acked-by: Li Yang <leoyang.li@xxxxxxx>
>
> ---
> drivers/dma/fsldma.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index
> aac85c3..a8828ed 100644
> --- a/drivers/dma/fsldma.c
> +++ b/drivers/dma/fsldma.c
> @@ -462,13 +462,12 @@ static struct fsl_desc_sw
> *fsl_dma_alloc_descriptor(struct fsldma_chan *chan)
> struct fsl_desc_sw *desc;
> dma_addr_t pdesc;
>
> - desc = dma_pool_alloc(chan->desc_pool, GFP_ATOMIC, &pdesc);
> + desc = dma_pool_zalloc(chan->desc_pool, GFP_ATOMIC, &pdesc);
> if (!desc) {
> chan_dbg(chan, "out of memory for link descriptor\n");
> return NULL;
> }
>
> - memset(desc, 0, sizeof(*desc));
> INIT_LIST_HEAD(&desc->tx_list);
> dma_async_tx_descriptor_init(&desc->async_tx, &chan->common);
> desc->async_tx.tx_submit = fsl_dma_tx_submit;