2022-04-25 08:06:21

by Jiabing Wan

[permalink] [raw]
Subject: [PATCH] mmc: atmel-mci: simplify if-if to if-else

Use if and else instead of if(A) and if (!A).

Signed-off-by: Wan Jiabing <[email protected]>
---
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;

if (data->flags & MMC_DATA_READ) {
--
2.35.1


2022-04-26 18:18:56

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else

On Sun, 24 Apr 2022 at 11:04, Wan Jiabing <[email protected]> wrote:
>
> Use if and else instead of if(A) and if (!A).
>
> Signed-off-by: Wan Jiabing <[email protected]>
> ---
> 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

2022-04-27 09:47:49

by Ulf Hansson

[permalink] [raw]
Subject: Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else

On Tue, 26 Apr 2022 at 17:06, Wan Jiabing <[email protected]> wrote:
>
> On Tue, Apr 26, 2022 at 03:53:09PM +0200, Ulf Hansson wrote:
> > On Sun, 24 Apr 2022 at 11:04, Wan Jiabing <[email protected]> wrote:
> > >
> > > Use if and else instead of if(A) and if (!A).
> > >
> > > Signed-off-by: Wan Jiabing <[email protected]>
> > > ---
> > > 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?

Please post a new version in plain text, not as an attachment.

Kind regards
Uffe

2022-04-27 11:09:42

by Jiabing Wan

[permalink] [raw]
Subject: Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else

On Tue, Apr 26, 2022 at 03:53:09PM +0200, Ulf Hansson wrote:
> On Sun, 24 Apr 2022 at 11:04, Wan Jiabing <[email protected]> wrote:
> >
> > Use if and else instead of if(A) and if (!A).
> >
> > Signed-off-by: Wan Jiabing <[email protected]>
> > ---
> > 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


Attachments:
(No filename) (1.14 kB)
0001-mmc-atmel-mci-Simplify-if-chan-and-if-chan.patch (1.11 kB)
Download all attachments