From: Wan Jiabing <wanjiabing@vivo.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
Ludovic Desroches <ludovic.desroches@microchip.com>,
kael_w@yeah.net, Claudiu Beznea <claudiu.beznea@microchip.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
Date: Tue, 26 Apr 2022 23:06:19 +0800 [thread overview]
Message-ID: <YmgKa4xQ+pOd2xfh@myhostname> (raw)
In-Reply-To: <CAPDyKFreW44ou8O4R53XUf7iZTGBBMM+1jmrOeh9cyEOTU-r1Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1122 bytes --]
On Tue, Apr 26, 2022 at 03:53:09PM +0200, Ulf Hansson wrote:
> On Sun, 24 Apr 2022 at 11:04, Wan Jiabing <wanjiabing@vivo.com> wrote:
> >
> > Use if and else instead of if(A) and if (!A).
> >
> > Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
> > ---
> > drivers/mmc/host/atmel-mci.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
> > index 807177c953f3..98893ccad4bd 100644
> > --- a/drivers/mmc/host/atmel-mci.c
> > +++ b/drivers/mmc/host/atmel-mci.c
> > @@ -1125,8 +1125,7 @@ atmci_prepare_data_dma(struct atmel_mci *host, struct mmc_data *data)
> > chan = host->dma.chan;
> > if (chan)
> > host->data_chan = chan;
> > -
> > - if (!chan)
> > + else
> > return -ENODEV;
>
> To make a slightly better improvement of the code, I suggest we add an
> early bail out point in the atmci_prepare_data_dma() function. Like
> below:
>
> if (!host->dma.chan)
> return -ENODEV;
>
> [...]
>
> Kind regards
> Uffe
OK
How about this new patch?
Thanks,
Wan Jiabing
[-- Attachment #2: 0001-mmc-atmel-mci-Simplify-if-chan-and-if-chan.patch --]
[-- Type: text/plain, Size: 1103 bytes --]
From ce6f779033c9a8aa2489f59c860bb2a49a67c278 Mon Sep 17 00:00:00 2001
From: Wan Jiabing <wanjiabing@vivo.com>
Date: Tue, 26 Apr 2022 23:01:18 +0800
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 <wanjiabing@vivo.com>
---
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
[-- Attachment #3: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-04-26 15:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-24 9:04 [PATCH] mmc: atmel-mci: simplify if-if to if-else Wan Jiabing
2022-04-26 13:53 ` Ulf Hansson
2022-04-26 15:06 ` Wan Jiabing [this message]
2022-04-26 22:43 ` Ulf Hansson
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=YmgKa4xQ+pOd2xfh@myhostname \
--to=wanjiabing@vivo.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.beznea@microchip.com \
--cc=kael_w@yeah.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=ludovic.desroches@microchip.com \
--cc=ulf.hansson@linaro.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox