2022-04-27 12:29:19

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] mmc: atmel-mci: Simplify if(chan) and if(!chan)

Use if(!host->dma.chan) instead of if(chan) and if(!chan) to make
code better.

Signed-off-by: Wan Jiabing <[email protected]>
---
drivers/mmc/host/atmel-mci.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 807177c953f3..91d52ba7a39f 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -1122,13 +1122,12 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
}

/* If we don't have a channel, we can't do DMA */
- chan = host->dma.chan;
- if (chan)
- host->data_chan = chan;
-
- if (!chan)
+ if (!host->dma.chan)
return -ENODEV;

+ chan = host->dma.chan;
+ host->data_chan = chan;
+
if (data->flags & MMC_DATA_READ) {
host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM;
maxburst = atmci_convert_chksize(host,
--
2.35.3


2022-05-04 15:34:48

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: atmel-mci: Simplify if(chan) and if(!chan)

On Wed, 27 Apr 2022 at 14:03, Wan Jiabing <[email protected]> wrote:
>
> Use if(!host->dma.chan) instead of if(chan) and if(!chan) to make
> code better.
>
> Signed-off-by: Wan Jiabing <[email protected]>

Applied for next, thanks!

Kind regards
Uffe


> ---
> drivers/mmc/host/atmel-mci.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> index 807177c953f3..91d52ba7a39f 100644
> --- a/drivers/mmc/host/atmel-mci.c
> +++ b/drivers/mmc/host/atmel-mci.c
> @@ -1122,13 +1122,12 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
> }
>
> /* If we don't have a channel, we can't do DMA */
> - chan = host->dma.chan;
> - if (chan)
> - host->data_chan = chan;
> -
> - if (!chan)
> + if (!host->dma.chan)
> return -ENODEV;
>
> + chan = host->dma.chan;
> + host->data_chan = chan;
> +
> if (data->flags & MMC_DATA_READ) {
> host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM;
> maxburst = atmci_convert_chksize(host,
> --
> 2.35.3
>