linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: rawnand: fix an error code in nand_setup_interface()
@ 2021-04-14  5:56 Dan Carpenter
  2021-04-16 15:00 ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2021-04-14  5:56 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Richard Weinberger, Vignesh Raghavendra, Boris Brezillon,
	Tudor Ambarus, Manivannan Sadhasivam, linux-mtd, linux-kernel,
	kernel-janitors

We should return an error code if the timing mode is not acknowledged
by the NAND chip.

Fixes: 415ae78ffb5d ("mtd: rawnand: check ONFI timings have been acked by the chip")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
From static analysis.  Not tested.

 drivers/mtd/nand/raw/nand_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index fb072c444495..d83c0503f96f 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -880,6 +880,7 @@ static int nand_setup_interface(struct nand_chip *chip, int chipnr)
 	if (tmode_param[0] != chip->best_interface_config->timings.mode) {
 		pr_warn("timing mode %d not acknowledged by the NAND chip\n",
 			chip->best_interface_config->timings.mode);
+		ret = -EINVAL;
 		goto err_reset_chip;
 	}
 
-- 
2.30.2


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

* Re: [PATCH] mtd: rawnand: fix an error code in nand_setup_interface()
  2021-04-14  5:56 [PATCH] mtd: rawnand: fix an error code in nand_setup_interface() Dan Carpenter
@ 2021-04-16 15:00 ` Miquel Raynal
  2021-04-17 10:24   ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Miquel Raynal @ 2021-04-16 15:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, Vignesh Raghavendra, Boris Brezillon,
	Tudor Ambarus, Manivannan Sadhasivam, linux-mtd, linux-kernel,
	kernel-janitors

Hi Dan,

Dan Carpenter <dan.carpenter@oracle.com> wrote on Wed, 14 Apr 2021
08:56:33 +0300:

> We should return an error code if the timing mode is not acknowledged
> by the NAND chip.

This truly is questionable (and I am not yet decided whether the answer
should be yes or no).

Returning an error here would produce the entire boot sequence to fail,
even though the NAND chip would work in mode 0.

Not returning an error would print the below warning (so the
user/developer is warned) and continue the boot with the slowest
timing interface.

Honestly I would be more in favor of letting things as they are
because I don't think this may be considered as a buggy situation, but I
am open to discussion.

> Fixes: 415ae78ffb5d ("mtd: rawnand: check ONFI timings have been acked by the chip")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> From static analysis.  Not tested.
> 
>  drivers/mtd/nand/raw/nand_base.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
> index fb072c444495..d83c0503f96f 100644
> --- a/drivers/mtd/nand/raw/nand_base.c
> +++ b/drivers/mtd/nand/raw/nand_base.c
> @@ -880,6 +880,7 @@ static int nand_setup_interface(struct nand_chip *chip, int chipnr)
>  	if (tmode_param[0] != chip->best_interface_config->timings.mode) {
>  		pr_warn("timing mode %d not acknowledged by the NAND chip\n",
>  			chip->best_interface_config->timings.mode);
> +		ret = -EINVAL;
>  		goto err_reset_chip;
>  	}
>  

Thanks,
Miquèl

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

* Re: [PATCH] mtd: rawnand: fix an error code in nand_setup_interface()
  2021-04-16 15:00 ` Miquel Raynal
@ 2021-04-17 10:24   ` Dan Carpenter
  2021-04-17 12:31     ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2021-04-17 10:24 UTC (permalink / raw)
  To: Miquel Raynal
  Cc: Richard Weinberger, Vignesh Raghavendra, Boris Brezillon,
	Tudor Ambarus, Manivannan Sadhasivam, linux-mtd, linux-kernel,
	kernel-janitors

On Fri, Apr 16, 2021 at 05:00:40PM +0200, Miquel Raynal wrote:
> Hi Dan,
> 
> Dan Carpenter <dan.carpenter@oracle.com> wrote on Wed, 14 Apr 2021
> 08:56:33 +0300:
> 
> > We should return an error code if the timing mode is not acknowledged
> > by the NAND chip.
> 
> This truly is questionable (and I am not yet decided whether the answer
> should be yes or no).
> 
> Returning an error here would produce the entire boot sequence to fail,
> even though the NAND chip would work in mode 0.
> 
> Not returning an error would print the below warning (so the
> user/developer is warned) and continue the boot with the slowest
> timing interface.
> 
> Honestly I would be more in favor of letting things as they are
> because I don't think this may be considered as a buggy situation, but I
> am open to discussion.
> 

If we decided that the original code is correct then one way to silence
the warning would be to do:

	if (tmode_param[0] != chip->best_interface_config->timings.mode) {
		pr_warn("timing mode %d not acknowledged by the NAND chip\n",
 			chip->best_interface_config->timings.mode);
		ret = 0;
		goto err_reset_chip;
	}

Setting "ret = 0;" right before the goto makes the code look more
intentional to human readers as well.

regards,
dan carpenter


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

* Re: [PATCH] mtd: rawnand: fix an error code in nand_setup_interface()
  2021-04-17 10:24   ` Dan Carpenter
@ 2021-04-17 12:31     ` Miquel Raynal
  0 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2021-04-17 12:31 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Richard Weinberger, Vignesh Raghavendra, Boris Brezillon,
	Tudor Ambarus, Manivannan Sadhasivam, linux-mtd, linux-kernel,
	kernel-janitors

Hi Dan,

Dan Carpenter <dan.carpenter@oracle.com> wrote on Sat, 17 Apr 2021
13:24:26 +0300:

> On Fri, Apr 16, 2021 at 05:00:40PM +0200, Miquel Raynal wrote:
> > Hi Dan,
> > 
> > Dan Carpenter <dan.carpenter@oracle.com> wrote on Wed, 14 Apr 2021
> > 08:56:33 +0300:
> >   
> > > We should return an error code if the timing mode is not acknowledged
> > > by the NAND chip.  
> > 
> > This truly is questionable (and I am not yet decided whether the answer
> > should be yes or no).
> > 
> > Returning an error here would produce the entire boot sequence to fail,
> > even though the NAND chip would work in mode 0.
> > 
> > Not returning an error would print the below warning (so the
> > user/developer is warned) and continue the boot with the slowest
> > timing interface.
> > 
> > Honestly I would be more in favor of letting things as they are
> > because I don't think this may be considered as a buggy situation, but I
> > am open to discussion.
> >   
> 
> If we decided that the original code is correct then one way to silence
> the warning would be to do:
> 
> 	if (tmode_param[0] != chip->best_interface_config->timings.mode) {
> 		pr_warn("timing mode %d not acknowledged by the NAND chip\n",
>  			chip->best_interface_config->timings.mode);
> 		ret = 0;
> 		goto err_reset_chip;
> 	}
> 
> Setting "ret = 0;" right before the goto makes the code look more
> intentional to human readers as well.

Absolutely right. Let's got for it then.

Cheers,
Miquèl

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

end of thread, other threads:[~2021-04-17 12:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14  5:56 [PATCH] mtd: rawnand: fix an error code in nand_setup_interface() Dan Carpenter
2021-04-16 15:00 ` Miquel Raynal
2021-04-17 10:24   ` Dan Carpenter
2021-04-17 12:31     ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).