diff mbox

[v4,5/5] dmaengine: mediatek: fix zalloc-simple.cocci warnings

Message ID ede5702c460a5b4b41186a8cff1e3c29b2380c08.1518110810.git.sean.wang@mediatek.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Wang Feb. 8, 2018, 5:58 p.m. UTC
From: Fengguang Wu <fengguang.wu@intel.com>

 Use zeroing allocator rather than allocator followed by memset with 0

Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci

Fixes: c8e4b2e4ca21 ("dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC")
Cc: Sean Wang <sean.wang@mediatek.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
 drivers/dma/mediatek/mtk-hsdma.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Vinod Koul Feb. 9, 2018, 12:58 p.m. UTC | #1
On Fri, Feb 09, 2018 at 01:58:51AM +0800, sean.wang@mediatek.com wrote:
> From: Fengguang Wu <fengguang.wu@intel.com>
> 
>  Use zeroing allocator rather than allocator followed by memset with 0
> 
> Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci
> 
> Fixes: c8e4b2e4ca21 ("dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC")
> Cc: Sean Wang <sean.wang@mediatek.com>
> Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> ---
>  drivers/dma/mediatek/mtk-hsdma.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
> index 42b5b23..d3b90fe 100644
> --- a/drivers/dma/mediatek/mtk-hsdma.c
> +++ b/drivers/dma/mediatek/mtk-hsdma.c
> @@ -325,13 +325,11 @@ static int mtk_hsdma_alloc_pchan(struct mtk_hsdma_device *hsdma,
>  	 * and [MTK_DMA_SIZE ... 2 * MTK_DMA_SIZE - 1] is for RX ring.
>  	 */
>  	pc->sz_ring = 2 * MTK_DMA_SIZE * sizeof(*ring->txd);
> -	ring->txd = dma_alloc_coherent(hsdma2dev(hsdma),
> -				       pc->sz_ring, &ring->tphys,
> -				       GFP_ATOMIC | __GFP_ZERO);
> +	ring->txd = dma_zalloc_coherent(hsdma2dev(hsdma), pc->sz_ring,
> +					&ring->tphys, GFP_ATOMIC);
>  	if (!ring->txd)
>  		return -ENOMEM;
>  
> -	memset(ring->txd, 0, pc->sz_ring);

This should be folded back..

>  	ring->rxd = &ring->txd[MTK_DMA_SIZE];
>  	ring->rphys = ring->tphys + MTK_DMA_SIZE * sizeof(*ring->txd);
>  	ring->cur_tptr = 0;
> -- 
> 2.7.4
>
Julia Lawall Feb. 9, 2018, 2:55 p.m. UTC | #2
On Fri, 9 Feb 2018, Vinod Koul wrote:

> On Fri, Feb 09, 2018 at 01:58:51AM +0800, sean.wang@mediatek.com wrote:
> > From: Fengguang Wu <fengguang.wu@intel.com>
> >
> >  Use zeroing allocator rather than allocator followed by memset with 0
> >
> > Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci
> >
> > Fixes: c8e4b2e4ca21 ("dmaengine: mediatek: Add MediaTek High-Speed DMA controller for MT7622 and MT7623 SoC")
> > Cc: Sean Wang <sean.wang@mediatek.com>
> > Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
> > Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
> > Signed-off-by: Sean Wang <sean.wang@mediatek.com>
> > ---
> >  drivers/dma/mediatek/mtk-hsdma.c | 6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
> > index 42b5b23..d3b90fe 100644
> > --- a/drivers/dma/mediatek/mtk-hsdma.c
> > +++ b/drivers/dma/mediatek/mtk-hsdma.c
> > @@ -325,13 +325,11 @@ static int mtk_hsdma_alloc_pchan(struct mtk_hsdma_device *hsdma,
> >  	 * and [MTK_DMA_SIZE ... 2 * MTK_DMA_SIZE - 1] is for RX ring.
> >  	 */
> >  	pc->sz_ring = 2 * MTK_DMA_SIZE * sizeof(*ring->txd);
> > -	ring->txd = dma_alloc_coherent(hsdma2dev(hsdma),
> > -				       pc->sz_ring, &ring->tphys,
> > -				       GFP_ATOMIC | __GFP_ZERO);
> > +	ring->txd = dma_zalloc_coherent(hsdma2dev(hsdma), pc->sz_ring,
> > +					&ring->tphys, GFP_ATOMIC);
> >  	if (!ring->txd)
> >  		return -ENOMEM;
> >
> > -	memset(ring->txd, 0, pc->sz_ring);
>
> This should be folded back..

Sorry, I'm not sure what you mean by "folded back".

julia

>
> >  	ring->rxd = &ring->txd[MTK_DMA_SIZE];
> >  	ring->rphys = ring->tphys + MTK_DMA_SIZE * sizeof(*ring->txd);
> >  	ring->cur_tptr = 0;
> > --
> > 2.7.4
> >
>
> --
> ~Vinod
>
Vinod Koul Feb. 13, 2018, 6:46 a.m. UTC | #3
On Fri, Feb 09, 2018 at 03:55:58PM +0100, Julia Lawall wrote:
> 
> > > -	ring->txd = dma_alloc_coherent(hsdma2dev(hsdma),
> > > -				       pc->sz_ring, &ring->tphys,
> > > -				       GFP_ATOMIC | __GFP_ZERO);
> > > +	ring->txd = dma_zalloc_coherent(hsdma2dev(hsdma), pc->sz_ring,
> > > +					&ring->tphys, GFP_ATOMIC);
> > >  	if (!ring->txd)
> > >  		return -ENOMEM;
> > >
> > > -	memset(ring->txd, 0, pc->sz_ring);
> >
> > This should be folded back..
> 
> Sorry, I'm not sure what you mean by "folded back".

Since the original patch is also up for review in this series, it doesn't
help much to add a change and fix on top in a series. The fix should be
folded back into the original commit. IIRC Fengguang's bot also recommends
so..
Julia Lawall Feb. 13, 2018, 7:07 a.m. UTC | #4
On Tue, 13 Feb 2018, Vinod Koul wrote:

> On Fri, Feb 09, 2018 at 03:55:58PM +0100, Julia Lawall wrote:
> >
> > > > -	ring->txd = dma_alloc_coherent(hsdma2dev(hsdma),
> > > > -				       pc->sz_ring, &ring->tphys,
> > > > -				       GFP_ATOMIC | __GFP_ZERO);
> > > > +	ring->txd = dma_zalloc_coherent(hsdma2dev(hsdma), pc->sz_ring,
> > > > +					&ring->tphys, GFP_ATOMIC);
> > > >  	if (!ring->txd)
> > > >  		return -ENOMEM;
> > > >
> > > > -	memset(ring->txd, 0, pc->sz_ring);
> > >
> > > This should be folded back..
> >
> > Sorry, I'm not sure what you mean by "folded back".
>
> Since the original patch is also up for review in this series, it doesn't
> help much to add a change and fix on top in a series. The fix should be
> folded back into the original commit. IIRC Fengguang's bot also recommends
> so..

Sure, no problem.  Thanks.  (I thought you meant folding or unfolding of a
function definition).

julia
diff mbox

Patch

diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
index 42b5b23..d3b90fe 100644
--- a/drivers/dma/mediatek/mtk-hsdma.c
+++ b/drivers/dma/mediatek/mtk-hsdma.c
@@ -325,13 +325,11 @@  static int mtk_hsdma_alloc_pchan(struct mtk_hsdma_device *hsdma,
 	 * and [MTK_DMA_SIZE ... 2 * MTK_DMA_SIZE - 1] is for RX ring.
 	 */
 	pc->sz_ring = 2 * MTK_DMA_SIZE * sizeof(*ring->txd);
-	ring->txd = dma_alloc_coherent(hsdma2dev(hsdma),
-				       pc->sz_ring, &ring->tphys,
-				       GFP_ATOMIC | __GFP_ZERO);
+	ring->txd = dma_zalloc_coherent(hsdma2dev(hsdma), pc->sz_ring,
+					&ring->tphys, GFP_ATOMIC);
 	if (!ring->txd)
 		return -ENOMEM;
 
-	memset(ring->txd, 0, pc->sz_ring);
 	ring->rxd = &ring->txd[MTK_DMA_SIZE];
 	ring->rphys = ring->tphys + MTK_DMA_SIZE * sizeof(*ring->txd);
 	ring->cur_tptr = 0;