2016-04-29 20:24:35

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 0/5] 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>
@@
type T;
T *d;
expression e;
statement S;
@@

d =
- dma_pool_alloc
+ dma_pool_zalloc
(...);
if (!d) S
- memset(d, 0, sizeof(T));

@@
expression d,e;
statement S;
@@

d =
- dma_pool_alloc
+ dma_pool_zalloc
(...);
if (!d) S
- memset(d, 0, sizeof(*d));
// </smpl>

---

drivers/crypto/marvell/tdma.c | 5 ++---
drivers/dma/fsldma.c | 3 +--
drivers/dma/ioat/init.c | 5 ++---
drivers/dma/mmp_pdma.c | 3 +--
drivers/dma/xilinx/xilinx_vdma.c | 3 +--
5 files changed, 7 insertions(+), 12 deletions(-)


2016-04-29 20:24:32

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 1/5] dmaengine: mmp_pdma: 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 <[email protected]>

---
drivers/dma/mmp_pdma.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/mmp_pdma.c b/drivers/dma/mmp_pdma.c
index e39457f..56f1fd6 100644
--- a/drivers/dma/mmp_pdma.c
+++ b/drivers/dma/mmp_pdma.c
@@ -364,13 +364,12 @@ mmp_pdma_alloc_descriptor(struct mmp_pdma_chan *chan)
struct mmp_pdma_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) {
dev_err(chan->dev, "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->chan);
/* each desc has submit */

2016-04-29 20:24:37

by Julia Lawall

[permalink] [raw]
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 <[email protected]>

---
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;

2016-04-29 20:24:53

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 4/5] crypto: 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 <[email protected]>

---

drivers/crypto/marvell/tdma.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/marvell/tdma.c b/drivers/crypto/marvell/tdma.c
index 7642798..0ad8f1e 100644
--- a/drivers/crypto/marvell/tdma.c
+++ b/drivers/crypto/marvell/tdma.c
@@ -99,12 +99,11 @@ mv_cesa_dma_add_desc(struct mv_cesa_tdma_chain *chain, gfp_t flags)
struct mv_cesa_tdma_desc *new_tdma = NULL;
dma_addr_t dma_handle;

- new_tdma = dma_pool_alloc(cesa_dev->dma->tdma_desc_pool, flags,
- &dma_handle);
+ new_tdma = dma_pool_zalloc(cesa_dev->dma->tdma_desc_pool, flags,
+ &dma_handle);
if (!new_tdma)
return ERR_PTR(-ENOMEM);

- memset(new_tdma, 0, sizeof(*new_tdma));
new_tdma->cur_dma = dma_handle;
if (chain->last) {
chain->last->next_dma = cpu_to_le32(dma_handle);

2016-04-29 20:25:19

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 3/5] dmaengine: ioatdma: 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 <[email protected]>

---

drivers/dma/ioat/init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index efdee1a..d4c63d4 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -690,12 +690,11 @@ static int ioat_alloc_chan_resources(struct dma_chan *c)
/* allocate a completion writeback area */
/* doing 2 32bit writes to mmio since 1 64b write doesn't work */
ioat_chan->completion =
- dma_pool_alloc(ioat_chan->ioat_dma->completion_pool,
- GFP_KERNEL, &ioat_chan->completion_dma);
+ dma_pool_zalloc(ioat_chan->ioat_dma->completion_pool,
+ GFP_KERNEL, &ioat_chan->completion_dma);
if (!ioat_chan->completion)
return -ENOMEM;

- memset(ioat_chan->completion, 0, sizeof(*ioat_chan->completion));
writel(((u64)ioat_chan->completion_dma) & 0x00000000FFFFFFFF,
ioat_chan->reg_base + IOAT_CHANCMP_OFFSET_LOW);
writel(((u64)ioat_chan->completion_dma) >> 32,

2016-04-29 20:26:40

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 2/5] dmaengine: vdma: 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 <[email protected]>

---
drivers/dma/xilinx/xilinx_vdma.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/dma/xilinx/xilinx_vdma.c b/drivers/dma/xilinx/xilinx_vdma.c
index a95d603..6a70987 100644
--- a/drivers/dma/xilinx/xilinx_vdma.c
+++ b/drivers/dma/xilinx/xilinx_vdma.c
@@ -343,11 +343,10 @@ xilinx_vdma_alloc_tx_segment(struct xilinx_vdma_chan *chan)
struct xilinx_vdma_tx_segment *segment;
dma_addr_t phys;

- segment = dma_pool_alloc(chan->desc_pool, GFP_ATOMIC, &phys);
+ segment = dma_pool_zalloc(chan->desc_pool, GFP_ATOMIC, &phys);
if (!segment)
return NULL;

- memset(segment, 0, sizeof(*segment));
segment->phys = phys;

return segment;

2016-04-29 20:37:55

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH 4/5] crypto: Use dma_pool_zalloc

On Fri, 29 Apr 2016 22:09:11 +0200
Julia Lawall <[email protected]> wrote:

> 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 <[email protected]>

Acked-by: Boris Brezillon <[email protected]>

>
> ---
>
> drivers/crypto/marvell/tdma.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/crypto/marvell/tdma.c b/drivers/crypto/marvell/tdma.c
> index 7642798..0ad8f1e 100644
> --- a/drivers/crypto/marvell/tdma.c
> +++ b/drivers/crypto/marvell/tdma.c
> @@ -99,12 +99,11 @@ mv_cesa_dma_add_desc(struct mv_cesa_tdma_chain *chain, gfp_t flags)
> struct mv_cesa_tdma_desc *new_tdma = NULL;
> dma_addr_t dma_handle;
>
> - new_tdma = dma_pool_alloc(cesa_dev->dma->tdma_desc_pool, flags,
> - &dma_handle);
> + new_tdma = dma_pool_zalloc(cesa_dev->dma->tdma_desc_pool, flags,
> + &dma_handle);
> if (!new_tdma)
> return ERR_PTR(-ENOMEM);
>
> - memset(new_tdma, 0, sizeof(*new_tdma));
> new_tdma->cur_dma = dma_handle;
> if (chain->last) {
> chain->last->next_dma = cpu_to_le32(dma_handle);



--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

2016-04-29 21:02:33

by Leo Li

[permalink] [raw]
Subject: RE: [PATCH 5/5] dmaengine: fsldma: Use dma_pool_zalloc



> -----Original Message-----
> From: Julia Lawall [mailto:[email protected]]
> Sent: Friday, April 29, 2016 3:09 PM
> To: Li Yang <[email protected]>
> Cc: [email protected]; Zhang Wei <[email protected]>; Vinod
> Koul <[email protected]>; Dan Williams <[email protected]>;
> [email protected]; [email protected]; linux-
> [email protected]
> 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 <[email protected]>

Acked-by: Li Yang <[email protected]>

>
> ---
> 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;

2016-04-29 21:13:46

by Soren Brinkmann

[permalink] [raw]
Subject: Re: [PATCH 2/5] dmaengine: vdma: Use dma_pool_zalloc

On Fri, 2016-04-29 at 22:09:09 +0200, Julia Lawall wrote:
> 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 <[email protected]>
Acked-by: Sören Brinkmann <[email protected]>

Sören