Linux-mmc Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] mmc: sdhci: fix an issue of mixing different types
@ 2020-01-19  3:49 Chunyan Zhang
  2020-01-19 20:12 ` Nathan Chancellor
  0 siblings, 1 reply; 2+ messages in thread
From: Chunyan Zhang @ 2020-01-19  3:49 UTC (permalink / raw)
  To: Ulf Hansson, Adrian Hunter
  Cc: linux-mmc, Faiz Abbas, Chunyan Zhang, linux-kernel,
	Chunyan Zhang, kbuild test robot

Fix an issue reported by sparse, since different type of parameter is
used on calling dmaengine_prep_slave_sg().

Fixes: 36e1da441fec (mmc: sdhci: add support for using external DMA devices)
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
 drivers/mmc/host/sdhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 30b5a624b50e..4503009f993b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1235,8 +1235,8 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
 		return -EINVAL;
 
 	desc = dmaengine_prep_slave_sg(chan, data->sg, data->sg_len,
-				       mmc_get_dma_dir(data),
-				       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
+			(enum dma_transfer_direction) mmc_get_dma_dir(data),
+			DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
 	if (!desc)
 		return -EINVAL;
 
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mmc: sdhci: fix an issue of mixing different types
  2020-01-19  3:49 [PATCH] mmc: sdhci: fix an issue of mixing different types Chunyan Zhang
@ 2020-01-19 20:12 ` Nathan Chancellor
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2020-01-19 20:12 UTC (permalink / raw)
  To: Chunyan Zhang
  Cc: Ulf Hansson, Adrian Hunter, linux-mmc, Faiz Abbas, Chunyan Zhang,
	linux-kernel, kbuild test robot, clang-built-linux

On Sun, Jan 19, 2020 at 11:49:02AM +0800, Chunyan Zhang wrote:
> Fix an issue reported by sparse, since different type of parameter is
> used on calling dmaengine_prep_slave_sg().
> 
> Fixes: 36e1da441fec (mmc: sdhci: add support for using external DMA devices)
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
> ---
>  drivers/mmc/host/sdhci.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 30b5a624b50e..4503009f993b 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1235,8 +1235,8 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
>  		return -EINVAL;
>  
>  	desc = dmaengine_prep_slave_sg(chan, data->sg, data->sg_len,
> -				       mmc_get_dma_dir(data),
> -				       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
> +			(enum dma_transfer_direction) mmc_get_dma_dir(data),
> +			DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>  	if (!desc)
>  		return -EINVAL;
>  
> -- 
> 2.20.1
> 

Clang also noticed this through its -Wenum-conversion. I don't really
like implicit conversions as I think it defeats the point of using the
enum. I had an explicit conversion locally which I attached below.
Regardless, this should resolve this issue (although I am not sure I
like the indentation shift.

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
7index 30b5a624b50e..98fa25ba3756 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1201,6 +1201,7 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
 				    struct mmc_command *cmd)
 {
 	int ret, i;
+	enum dma_transfer_direction dir;
 	struct dma_async_tx_descriptor *desc;
 	struct mmc_data *data = cmd->data;
 	struct dma_chan *chan;
@@ -1234,8 +1235,12 @@ static int sdhci_external_dma_setup(struct sdhci_host *host,
 	if (sg_cnt <= 0)
 		return -EINVAL;
 
-	desc = dmaengine_prep_slave_sg(chan, data->sg, data->sg_len,
-				       mmc_get_dma_dir(data),
+	if (mmc_get_dma_dir(data) == DMA_TO_DEVICE)
+		dir = DMA_MEM_TO_DEV;
+	else
+		dir = DMA_DEV_TO_MEM;
+
+	desc = dmaengine_prep_slave_sg(chan, data->sg, data->sg_len, dir,
 				       DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
 	if (!desc)
 		return -EINVAL;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-19  3:49 [PATCH] mmc: sdhci: fix an issue of mixing different types Chunyan Zhang
2020-01-19 20:12 ` Nathan Chancellor

Linux-mmc Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mmc/0 linux-mmc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mmc linux-mmc/ https://lore.kernel.org/linux-mmc \
		linux-mmc@vger.kernel.org
	public-inbox-index linux-mmc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mmc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git