public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
@ 2024-08-09 12:15 Marcus Folkesson
  2024-08-09 12:25 ` Alexander Dahl
  2024-08-30  6:59 ` Marcus Folkesson
  0 siblings, 2 replies; 8+ messages in thread
From: Marcus Folkesson @ 2024-08-09 12:15 UTC (permalink / raw)
  To: u-boot
  Cc: Marcus Folkesson, Alexander Dahl, Dario Binacchi, Eugen Hristev,
	Igor Prusov, Michael Trimarchi, Sean Anderson, Tom Rini

The condition 'ret' is always true as it is never set to other than
-EIO.

Remove 'ret' and the condition for copy.

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
---

 drivers/mtd/nand/raw/atmel/nand-controller.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
index ee4ec6da58..00d7e177b9 100644
--- a/drivers/mtd/nand/raw/atmel/nand-controller.c
+++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
@@ -568,12 +568,9 @@ static void atmel_nfc_copy_to_sram(struct nand_chip *chip, const u8 *buf,
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	struct atmel_nand *nand = to_atmel_nand(chip);
 	struct atmel_hsmc_nand_controller *nc;
-	int ret = -EIO;
 
 	nc = to_hsmc_nand_controller(nand->controller);
-
-	if (ret)
-		memcpy_toio(nc->sram.virt, buf, mtd->writesize);
+	memcpy_toio(nc->sram.virt, buf, mtd->writesize);
 
 	if (oob_required)
 		memcpy_toio(nc->sram.virt + mtd->writesize, chip->oob_poi,
@@ -586,12 +583,9 @@ static void atmel_nfc_copy_from_sram(struct nand_chip *chip, u8 *buf,
 	struct mtd_info *mtd = nand_to_mtd(chip);
 	struct atmel_nand *nand = to_atmel_nand(chip);
 	struct atmel_hsmc_nand_controller *nc;
-	int ret = -EIO;
 
 	nc = to_hsmc_nand_controller(nand->controller);
-
-	if (ret)
-		memcpy_fromio(buf, nc->sram.virt, mtd->writesize);
+	memcpy_fromio(buf, nc->sram.virt, mtd->writesize);
 
 	if (oob_required)
 		memcpy_fromio(chip->oob_poi, nc->sram.virt + mtd->writesize,
-- 
2.45.1


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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-08-09 12:15 [PATCH] mtd: nand: raw: atmel: remove unnecessary return value Marcus Folkesson
@ 2024-08-09 12:25 ` Alexander Dahl
  2024-08-09 12:36   ` Michael Nazzareno Trimarchi
  2024-08-09 13:05   ` Marcus Folkesson
  2024-08-30  6:59 ` Marcus Folkesson
  1 sibling, 2 replies; 8+ messages in thread
From: Alexander Dahl @ 2024-08-09 12:25 UTC (permalink / raw)
  To: Marcus Folkesson
  Cc: u-boot, Alexander Dahl, Dario Binacchi, Eugen Hristev,
	Igor Prusov, Michael Trimarchi, Sean Anderson, Tom Rini

Hello Marcus,

Am Fri, Aug 09, 2024 at 02:15:43PM +0200 schrieb Marcus Folkesson:
> The condition 'ret' is always true as it is never set to other than
> -EIO.

Technically, you're right.

I quickly compared with the same driver in Linux.  That has some
additional lines for DMA transfers which probably got removed when
porting the driver.

Does the code before your patch throw compiler warnings?  If not, I
would keep it as is.  The compiler will probably optimize it away
anyway, and it would make future ports from Linux easier.

Greets
Alex

> 
> Remove 'ret' and the condition for copy.
> 
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---
> 
>  drivers/mtd/nand/raw/atmel/nand-controller.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
> index ee4ec6da58..00d7e177b9 100644
> --- a/drivers/mtd/nand/raw/atmel/nand-controller.c
> +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
> @@ -568,12 +568,9 @@ static void atmel_nfc_copy_to_sram(struct nand_chip *chip, const u8 *buf,
>  	struct mtd_info *mtd = nand_to_mtd(chip);
>  	struct atmel_nand *nand = to_atmel_nand(chip);
>  	struct atmel_hsmc_nand_controller *nc;
> -	int ret = -EIO;
>  
>  	nc = to_hsmc_nand_controller(nand->controller);
> -
> -	if (ret)
> -		memcpy_toio(nc->sram.virt, buf, mtd->writesize);
> +	memcpy_toio(nc->sram.virt, buf, mtd->writesize);
>  
>  	if (oob_required)
>  		memcpy_toio(nc->sram.virt + mtd->writesize, chip->oob_poi,
> @@ -586,12 +583,9 @@ static void atmel_nfc_copy_from_sram(struct nand_chip *chip, u8 *buf,
>  	struct mtd_info *mtd = nand_to_mtd(chip);
>  	struct atmel_nand *nand = to_atmel_nand(chip);
>  	struct atmel_hsmc_nand_controller *nc;
> -	int ret = -EIO;
>  
>  	nc = to_hsmc_nand_controller(nand->controller);
> -
> -	if (ret)
> -		memcpy_fromio(buf, nc->sram.virt, mtd->writesize);
> +	memcpy_fromio(buf, nc->sram.virt, mtd->writesize);
>  
>  	if (oob_required)
>  		memcpy_fromio(chip->oob_poi, nc->sram.virt + mtd->writesize,
> -- 
> 2.45.1
> 

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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-08-09 12:25 ` Alexander Dahl
@ 2024-08-09 12:36   ` Michael Nazzareno Trimarchi
  2024-08-09 13:05   ` Marcus Folkesson
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Nazzareno Trimarchi @ 2024-08-09 12:36 UTC (permalink / raw)
  To: Marcus Folkesson, u-boot, Dario Binacchi, Eugen Hristev,
	Igor Prusov, Michael Trimarchi, Sean Anderson, Tom Rini
  Cc: Alexander Dahl

Hi all

On Fri, Aug 9, 2024 at 2:25 PM Alexander Dahl <ada@thorsis.com> wrote:
>
> Hello Marcus,
>
> Am Fri, Aug 09, 2024 at 02:15:43PM +0200 schrieb Marcus Folkesson:
> > The condition 'ret' is always true as it is never set to other than
> > -EIO.
>
> Technically, you're right.
>
> I quickly compared with the same driver in Linux.  That has some
> additional lines for DMA transfers which probably got removed when
> porting the driver.
>
> Does the code before your patch throw compiler warnings?  If not, I
> would keep it as is.  The compiler will probably optimize it away
> anyway, and it would make future ports from Linux easier.
>

I suggest to comment it because it will happen to other people to send a similar
patch

Michael

> Greets
> Alex
>
> >
> > Remove 'ret' and the condition for copy.
> >
> > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > ---
> >
> >  drivers/mtd/nand/raw/atmel/nand-controller.c | 10 ++--------
> >  1 file changed, 2 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/raw/atmel/nand-controller.c b/drivers/mtd/nand/raw/atmel/nand-controller.c
> > index ee4ec6da58..00d7e177b9 100644
> > --- a/drivers/mtd/nand/raw/atmel/nand-controller.c
> > +++ b/drivers/mtd/nand/raw/atmel/nand-controller.c
> > @@ -568,12 +568,9 @@ static void atmel_nfc_copy_to_sram(struct nand_chip *chip, const u8 *buf,
> >       struct mtd_info *mtd = nand_to_mtd(chip);
> >       struct atmel_nand *nand = to_atmel_nand(chip);
> >       struct atmel_hsmc_nand_controller *nc;
> > -     int ret = -EIO;
> >
> >       nc = to_hsmc_nand_controller(nand->controller);
> > -
> > -     if (ret)
> > -             memcpy_toio(nc->sram.virt, buf, mtd->writesize);
> > +     memcpy_toio(nc->sram.virt, buf, mtd->writesize);
> >
> >       if (oob_required)
> >               memcpy_toio(nc->sram.virt + mtd->writesize, chip->oob_poi,
> > @@ -586,12 +583,9 @@ static void atmel_nfc_copy_from_sram(struct nand_chip *chip, u8 *buf,
> >       struct mtd_info *mtd = nand_to_mtd(chip);
> >       struct atmel_nand *nand = to_atmel_nand(chip);
> >       struct atmel_hsmc_nand_controller *nc;
> > -     int ret = -EIO;
> >
> >       nc = to_hsmc_nand_controller(nand->controller);
> > -
> > -     if (ret)
> > -             memcpy_fromio(buf, nc->sram.virt, mtd->writesize);
> > +     memcpy_fromio(buf, nc->sram.virt, mtd->writesize);
> >
> >       if (oob_required)
> >               memcpy_fromio(chip->oob_poi, nc->sram.virt + mtd->writesize,
> > --
> > 2.45.1
> >



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-08-09 12:25 ` Alexander Dahl
  2024-08-09 12:36   ` Michael Nazzareno Trimarchi
@ 2024-08-09 13:05   ` Marcus Folkesson
  1 sibling, 0 replies; 8+ messages in thread
From: Marcus Folkesson @ 2024-08-09 13:05 UTC (permalink / raw)
  To: Alexander Dahl
  Cc: u-boot, Dario Binacchi, Eugen Hristev, Igor Prusov,
	Michael Trimarchi, Sean Anderson, Tom Rini

[-- Attachment #1: Type: text/plain, Size: 1231 bytes --]

Hello Alexander,

Thanks for fast response!

On Fri, Aug 09, 2024 at 02:25:04PM +0200, Alexander Dahl wrote:
> Hello Marcus,
> 
> Am Fri, Aug 09, 2024 at 02:15:43PM +0200 schrieb Marcus Folkesson:
> > The condition 'ret' is always true as it is never set to other than
> > -EIO.
> 
> Technically, you're right.
> 
> I quickly compared with the same driver in Linux.  That has some
> additional lines for DMA transfers which probably got removed when
> porting the driver.

Yes, I thought is was something like that.
> 
> Does the code before your patch throw compiler warnings?  If not, I

Not the compiler, but vim-ale (lint engine) is yelling loudly at me.

> would keep it as is.  The compiler will probably optimize it away
> anyway, and it would make future ports from Linux easier.

I understand your reasoning but not sure I agree.

I don't think it significantly complicates any porting and the code becomes cleaner.

I also think that the porting become less error-prone because it becomes a 
conscious choice to introduce and use ret if needed.

That is what I think, but I don't really have a very strong opinion about it.

> 
> Greets
> Alex
> 

Best regards,
Marcus Folkesson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-08-09 12:15 [PATCH] mtd: nand: raw: atmel: remove unnecessary return value Marcus Folkesson
  2024-08-09 12:25 ` Alexander Dahl
@ 2024-08-30  6:59 ` Marcus Folkesson
  2024-08-30  7:05   ` Michael Nazzareno Trimarchi
  1 sibling, 1 reply; 8+ messages in thread
From: Marcus Folkesson @ 2024-08-30  6:59 UTC (permalink / raw)
  To: u-boot
  Cc: Alexander Dahl, Dario Binacchi, Eugen Hristev, Igor Prusov,
	Michael Trimarchi, Sean Anderson, Tom Rini

[-- Attachment #1: Type: text/plain, Size: 329 bytes --]

On Fri, Aug 09, 2024 at 02:15:43PM +0200, Marcus Folkesson wrote:
> The condition 'ret' is always true as it is never set to other than
> -EIO.
> 
> Remove 'ret' and the condition for copy.
> 
> Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> ---

Any more thoughts on this?

Thanks,
Marcus Folkesson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-08-30  6:59 ` Marcus Folkesson
@ 2024-08-30  7:05   ` Michael Nazzareno Trimarchi
  2024-12-10  7:08     ` Marcus Folkesson
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Nazzareno Trimarchi @ 2024-08-30  7:05 UTC (permalink / raw)
  To: Marcus Folkesson
  Cc: u-boot, Alexander Dahl, Dario Binacchi, Eugen Hristev,
	Igor Prusov, Sean Anderson, Tom Rini

Hi Marcus

On Fri, Aug 30, 2024 at 8:59 AM Marcus Folkesson
<marcus.folkesson@gmail.com> wrote:
>
> On Fri, Aug 09, 2024 at 02:15:43PM +0200, Marcus Folkesson wrote:
> > The condition 'ret' is always true as it is never set to other than
> > -EIO.
> >
> > Remove 'ret' and the condition for copy.
> >
> > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > ---
>
> Any more thoughts on this?

Reviewed-by: Michael Trimarchi <micheal@amarulasolutions.com>

It will be included in the next pull request.

Michael

>
> Thanks,
> Marcus Folkesson



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-08-30  7:05   ` Michael Nazzareno Trimarchi
@ 2024-12-10  7:08     ` Marcus Folkesson
  2024-12-10  7:12       ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 8+ messages in thread
From: Marcus Folkesson @ 2024-12-10  7:08 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi
  Cc: u-boot, Alexander Dahl, Dario Binacchi, Eugen Hristev,
	Igor Prusov, Sean Anderson, Tom Rini

[-- Attachment #1: Type: text/plain, Size: 749 bytes --]

Hello Michael,

On Fri, Aug 30, 2024 at 09:05:27AM +0200, Michael Nazzareno Trimarchi wrote:
> Hi Marcus
> 
> On Fri, Aug 30, 2024 at 8:59 AM Marcus Folkesson
> <marcus.folkesson@gmail.com> wrote:
> >
> > On Fri, Aug 09, 2024 at 02:15:43PM +0200, Marcus Folkesson wrote:
> > > The condition 'ret' is always true as it is never set to other than
> > > -EIO.
> > >
> > > Remove 'ret' and the condition for copy.
> > >
> > > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > > ---
> >
> > Any more thoughts on this?
> 
> Reviewed-by: Michael Trimarchi <micheal@amarulasolutions.com>
> 
> It will be included in the next pull request.

Not sure it got included?

> 
> Michael
> 

Thanks,
Marcus Folkesson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] mtd: nand: raw: atmel: remove unnecessary return value
  2024-12-10  7:08     ` Marcus Folkesson
@ 2024-12-10  7:12       ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Nazzareno Trimarchi @ 2024-12-10  7:12 UTC (permalink / raw)
  To: Marcus Folkesson
  Cc: U-Boot-Denx, Alexander Dahl, Dario Binacchi, Eugen Hristev,
	Igor Prusov, Sean Anderson, Tom Rini

Hi

Il mar 10 dic 2024, 08:08 Marcus Folkesson <marcus.folkesson@gmail.com> ha
scritto:

> Hello Michael,
>
> On Fri, Aug 30, 2024 at 09:05:27AM +0200, Michael Nazzareno Trimarchi
> wrote:
> > Hi Marcus
> >
> > On Fri, Aug 30, 2024 at 8:59 AM Marcus Folkesson
> > <marcus.folkesson@gmail.com> wrote:
> > >
> > > On Fri, Aug 09, 2024 at 02:15:43PM +0200, Marcus Folkesson wrote:
> > > > The condition 'ret' is always true as it is never set to other than
> > > > -EIO.
> > > >
> > > > Remove 'ret' and the condition for copy.
> > > >
> > > > Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
> > > > ---
> > >
> > > Any more thoughts on this?
> >
> > Reviewed-by: Michael Trimarchi <micheal@amarulasolutions.com>
> >
> > It will be included in the next pull request.
>
> Not sure it got included?
>

I will pick today.

Michael

>
> >
> > Michael
> >
>
> Thanks,
> Marcus Folkesson
>

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

end of thread, other threads:[~2024-12-10 12:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-09 12:15 [PATCH] mtd: nand: raw: atmel: remove unnecessary return value Marcus Folkesson
2024-08-09 12:25 ` Alexander Dahl
2024-08-09 12:36   ` Michael Nazzareno Trimarchi
2024-08-09 13:05   ` Marcus Folkesson
2024-08-30  6:59 ` Marcus Folkesson
2024-08-30  7:05   ` Michael Nazzareno Trimarchi
2024-12-10  7:08     ` Marcus Folkesson
2024-12-10  7:12       ` Michael Nazzareno Trimarchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox