diff mbox

dmaengine: mediatek: fix zalloc-simple.cocci warnings

Message ID alpine.DEB.2.20.1802031658280.3390@hadrien (mailing list archive)
State New, archived
Headers show

Commit Message

Julia Lawall Feb. 3, 2018, 4 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: 73006a033ef0 ("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>
---

[auto build test WARNING on linus/master]
[also build test WARNING on v4.15 next-20180202]
[if your patch is applied to the wrong git tree, please drop us a note to
help improve the system]

url:
https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/dt-bindings-dmaengine-Add-MediaTek-High-Speed-DMA-controller-bindings/20180203-203814

Please take the patch only if it's a positive warning. Thanks!

 mtk-hsdma.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Julia Lawall Feb. 3, 2018, 4:41 p.m. UTC | #1
On Sat, 3 Feb 2018, Julia Lawall 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: 73006a033ef0 ("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>
> ---
>
> [auto build test WARNING on linus/master]
> [also build test WARNING on v4.15 next-20180202]
> [if your patch is applied to the wrong git tree, please drop us a note to
> help improve the system]
>
> url:
> https://github.com/0day-ci/linux/commits/sean-wang-mediatek-com/dt-bindings-dmaengine-Add-MediaTek-High-Speed-DMA-controller-bindings/20180203-203814
>
> Please take the patch only if it's a positive warning. Thanks!
>
>  mtk-hsdma.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> --- 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
>  	 * 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 | __GFP_ZERO);

Actually, __GFP_ZERO could be dropped as well.

julia

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

Patch

--- 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
 	 * 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 | __GFP_ZERO);
 	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;