All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mmc: atmel-mci: simplify if-if to if-else
@ 2022-04-24  9:04 ` Wan Jiabing
  0 siblings, 0 replies; 8+ messages in thread
From: Wan Jiabing @ 2022-04-24  9:04 UTC (permalink / raw)
  To: Ludovic Desroches, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: kael_w, Wan Jiabing

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;
 
 	if (data->flags & MMC_DATA_READ) {
-- 
2.35.1


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

* [PATCH] mmc: atmel-mci: simplify if-if to if-else
@ 2022-04-24  9:04 ` Wan Jiabing
  0 siblings, 0 replies; 8+ messages in thread
From: Wan Jiabing @ 2022-04-24  9:04 UTC (permalink / raw)
  To: Ludovic Desroches, Ulf Hansson, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-mmc, linux-arm-kernel, linux-kernel
  Cc: kael_w, Wan Jiabing

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;
 
 	if (data->flags & MMC_DATA_READ) {
-- 
2.35.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
  2022-04-24  9:04 ` Wan Jiabing
@ 2022-04-26 13:53   ` Ulf Hansson
  -1 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2022-04-26 13:53 UTC (permalink / raw)
  To: Wan Jiabing
  Cc: Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-mmc, linux-arm-kernel, linux-kernel,
	kael_w

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

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

* Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
@ 2022-04-26 13:53   ` Ulf Hansson
  0 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2022-04-26 13:53 UTC (permalink / raw)
  To: Wan Jiabing
  Cc: Alexandre Belloni, linux-mmc, linux-kernel, Ludovic Desroches,
	kael_w, Claudiu Beznea, linux-arm-kernel

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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
  2022-04-26 13:53   ` Ulf Hansson
@ 2022-04-26 15:06     ` Wan Jiabing
  -1 siblings, 0 replies; 8+ messages in thread
From: Wan Jiabing @ 2022-04-26 15:06 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-mmc, linux-arm-kernel, linux-kernel,
	kael_w

[-- 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


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

* Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
@ 2022-04-26 15:06     ` Wan Jiabing
  0 siblings, 0 replies; 8+ messages in thread
From: Wan Jiabing @ 2022-04-26 15:06 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Alexandre Belloni, linux-mmc, linux-kernel, Ludovic Desroches,
	kael_w, Claudiu Beznea, linux-arm-kernel

[-- 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

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

* Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
  2022-04-26 15:06     ` Wan Jiabing
@ 2022-04-26 22:43       ` Ulf Hansson
  -1 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2022-04-26 22:43 UTC (permalink / raw)
  To: Wan Jiabing
  Cc: Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
	Claudiu Beznea, linux-mmc, linux-arm-kernel, linux-kernel,
	kael_w

On Tue, 26 Apr 2022 at 17:06, Wan Jiabing <wanjiabing@vivo.com> wrote:
>
> 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?

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

Kind regards
Uffe

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

* Re: [PATCH] mmc: atmel-mci: simplify if-if to if-else
@ 2022-04-26 22:43       ` Ulf Hansson
  0 siblings, 0 replies; 8+ messages in thread
From: Ulf Hansson @ 2022-04-26 22:43 UTC (permalink / raw)
  To: Wan Jiabing
  Cc: Alexandre Belloni, linux-mmc, linux-kernel, Ludovic Desroches,
	kael_w, Claudiu Beznea, linux-arm-kernel

On Tue, 26 Apr 2022 at 17:06, Wan Jiabing <wanjiabing@vivo.com> wrote:
>
> 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?

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

Kind regards
Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-04-26 22:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24  9:04 [PATCH] mmc: atmel-mci: simplify if-if to if-else Wan Jiabing
2022-04-24  9:04 ` Wan Jiabing
2022-04-26 13:53 ` Ulf Hansson
2022-04-26 13:53   ` Ulf Hansson
2022-04-26 15:06   ` Wan Jiabing
2022-04-26 15:06     ` Wan Jiabing
2022-04-26 22:43     ` Ulf Hansson
2022-04-26 22:43       ` Ulf Hansson

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.