All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Boris Brezillon <boris.brezillon@free-electrons.com>,
	Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Cc: linux-mtd@lists.infradead.org,
	David Woodhouse <dwmw2@infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	Marek Vasut <marek.vasut@gmail.com>,
	Cyrille Pitchen <cyrille.pitchen@atmel.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] mtd: nand: tango: Enforce DMA direction type
Date: Mon, 13 Feb 2017 11:54:46 +0100	[thread overview]
Message-ID: <bef98482-c562-57c1-785b-087a720e3807@nod.at> (raw)
In-Reply-To: <1486979107-15362-1-git-send-email-boris.brezillon@free-electrons.com>

Am 13.02.2017 um 10:45 schrieb Boris Brezillon:
> do_dma() use an integer to pass the DMA data direction information and
> pass the same value to dmaengine_prep_slave_sg().
> 
> Currently, DMA_{FROM,TO}_DEVICE match DMA_{DEV_TO_MEM,MEM_TO_DEV}
> definitions so it works fine, but assuming this will always be the case
> is not safe.
> 
> Enforce enum dma_data_direction type in the function prototype and make
> the enum dma_data_direction -> enum dma_transfer_direction conversion
> explicit.
> 
> Reported-by: Richard Weinberger <richard@nod.at>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  drivers/mtd/nand/tango_nand.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
> index 4a5e948c62df..9a0e2f85d865 100644
> --- a/drivers/mtd/nand/tango_nand.c
> +++ b/drivers/mtd/nand/tango_nand.c
> @@ -223,8 +223,8 @@ static void tango_dma_callback(void *arg)
>  	complete(arg);
>  }
>  
> -static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
> -		  int len, int page)
> +static int do_dma(struct tango_nfc *nfc, enum dma_data_direction dir, int cmd,
> +		  const void *buf, int len, int page)
>  {
>  	void __iomem *addr = nfc->reg_base + NFC_STATUS;
>  	struct dma_chan *chan = nfc->chan;
> @@ -238,7 +238,10 @@ static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
>  	if (dma_map_sg(chan->device->dev, &sg, 1, dir) != 1)
>  		return -EIO;
>  
> -	desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir, DMA_PREP_INTERRUPT);
> +	desc = dmaengine_prep_slave_sg(chan, &sg, 1,
> +				       dir == DMA_FROM_DEVICE ?
> +				       DMA_DEV_TO_MEM : DMA_MEM_TO_DEV,
> +				       DMA_PREP_INTERRUPT);
>  	if (!desc)
>  		goto dma_unmap;
>  

Reviewed-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

WARNING: multiple messages have this Message-ID (diff)
From: richard@nod.at (Richard Weinberger)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mtd: nand: tango: Enforce DMA direction type
Date: Mon, 13 Feb 2017 11:54:46 +0100	[thread overview]
Message-ID: <bef98482-c562-57c1-785b-087a720e3807@nod.at> (raw)
In-Reply-To: <1486979107-15362-1-git-send-email-boris.brezillon@free-electrons.com>

Am 13.02.2017 um 10:45 schrieb Boris Brezillon:
> do_dma() use an integer to pass the DMA data direction information and
> pass the same value to dmaengine_prep_slave_sg().
> 
> Currently, DMA_{FROM,TO}_DEVICE match DMA_{DEV_TO_MEM,MEM_TO_DEV}
> definitions so it works fine, but assuming this will always be the case
> is not safe.
> 
> Enforce enum dma_data_direction type in the function prototype and make
> the enum dma_data_direction -> enum dma_transfer_direction conversion
> explicit.
> 
> Reported-by: Richard Weinberger <richard@nod.at>
> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
>  drivers/mtd/nand/tango_nand.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/nand/tango_nand.c b/drivers/mtd/nand/tango_nand.c
> index 4a5e948c62df..9a0e2f85d865 100644
> --- a/drivers/mtd/nand/tango_nand.c
> +++ b/drivers/mtd/nand/tango_nand.c
> @@ -223,8 +223,8 @@ static void tango_dma_callback(void *arg)
>  	complete(arg);
>  }
>  
> -static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
> -		  int len, int page)
> +static int do_dma(struct tango_nfc *nfc, enum dma_data_direction dir, int cmd,
> +		  const void *buf, int len, int page)
>  {
>  	void __iomem *addr = nfc->reg_base + NFC_STATUS;
>  	struct dma_chan *chan = nfc->chan;
> @@ -238,7 +238,10 @@ static int do_dma(struct tango_nfc *nfc, int dir, int cmd, const void *buf,
>  	if (dma_map_sg(chan->device->dev, &sg, 1, dir) != 1)
>  		return -EIO;
>  
> -	desc = dmaengine_prep_slave_sg(chan, &sg, 1, dir, DMA_PREP_INTERRUPT);
> +	desc = dmaengine_prep_slave_sg(chan, &sg, 1,
> +				       dir == DMA_FROM_DEVICE ?
> +				       DMA_DEV_TO_MEM : DMA_MEM_TO_DEV,
> +				       DMA_PREP_INTERRUPT);
>  	if (!desc)
>  		goto dma_unmap;
>  

Reviewed-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

  reply	other threads:[~2017-02-13 10:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-13  9:45 [PATCH] mtd: nand: tango: Enforce DMA direction type Boris Brezillon
2017-02-13  9:45 ` Boris Brezillon
2017-02-13 10:54 ` Richard Weinberger [this message]
2017-02-13 10:54   ` Richard Weinberger
2017-02-20 12:30 ` Marc Gonzalez
2017-02-20 12:30   ` Marc Gonzalez
2017-02-20 12:35   ` Boris Brezillon
2017-02-20 12:35     ` Boris Brezillon
2017-02-20 13:10     ` [PATCH v2] " Marc Gonzalez
2017-02-20 13:10       ` Marc Gonzalez
2017-03-16  9:27       ` Boris Brezillon
2017-03-16  9:27         ` Boris Brezillon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bef98482-c562-57c1-785b-087a720e3807@nod.at \
    --to=richard@nod.at \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=cyrille.pitchen@atmel.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marc_gonzalez@sigmadesigns.com \
    --cc=marek.vasut@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.