public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Pratyush Yadav <p.yadav@ti.com>
To: <Tudor.Ambarus@microchip.com>
Cc: <michael@walle.cc>, <miquel.raynal@bootlin.com>, <richard@nod.at>,
	<vigneshr@ti.com>, <linux-mtd@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <Takahiro.Kuwano@infineon.com>
Subject: Re: [PATCH v4 03/11] mtd: spi-nor: core: Use auto-detection only once
Date: Wed, 27 Apr 2022 10:50:00 +0530	[thread overview]
Message-ID: <20220427052000.xmctvowj4kuc727d@ti.com> (raw)
In-Reply-To: <6f81d38b-5e4b-eaf7-0466-3c6fe5e84996@microchip.com>

On 21/04/22 01:41PM, Tudor.Ambarus@microchip.com wrote:
> On 4/21/22 16:16, Pratyush Yadav wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > 
> > On 21/04/22 07:18AM, Tudor.Ambarus@microchip.com wrote:
> >> Hi, Pratyush,
> >>
> >> I forgot to remove few checks, would you please remove them when applying?
> >> See below.
> >>
> >> On 4/20/22 13:34, Tudor Ambarus wrote:
> >>> In case spi_nor_match_name() returned NULL, the auto detection was
> >>> issued twice. There's no reason to try to detect the same chip twice,
> >>> do the auto detection only once.
> >>>
> >>> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> >>> Reviewed-by: Michael Walle <michael@walle.cc>
> >>> ---
> >>>  drivers/mtd/spi-nor/core.c | 13 ++++++++-----
> >>>  1 file changed, 8 insertions(+), 5 deletions(-)
> >>>
> >>> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> >>> index b9cc8bbf1f62..b55d922d46dd 100644
> >>> --- a/drivers/mtd/spi-nor/core.c
> >>> +++ b/drivers/mtd/spi-nor/core.c
> >>> @@ -2896,13 +2896,14 @@ static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
> >>>  {
> >>>     const struct flash_info *info = NULL;
> >>>
> >>> -   if (name)
> >>> +   if (name) {
> >>>             info = spi_nor_match_name(nor, name);
> >>> +           if (IS_ERR(info))
> >>> +                   return info;
> >>
> >> As Michael suggested spi_nor_match_name() returns NULL or valid entry, so this
> >> check is not necessary, let's remove them.
> >>
> >>> +   }
> >>>     /* Try to auto-detect if chip name wasn't specified or not found */
> >>>     if (!info)
> >>> -           info = spi_nor_read_id(nor);
> >>> -   if (IS_ERR_OR_NULL(info))
> >>> -           return ERR_PTR(-ENOENT);
> >>> +           return spi_nor_read_id(nor);
> >>>
> >>>     /*
> >>>      * If caller has specified name of flash model that can normally be
> >>> @@ -2994,7 +2995,9 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
> >>>             return -ENOMEM;
> >>>
> >>>     info = spi_nor_get_flash_info(nor, name);
> >>> -   if (IS_ERR(info))
> >>> +   if (!info)
> >>> +           return -ENOENT;
> >>
> >> also according to Michael, this change is not needed as spi_nor_get_flash_info() can't
> >> return NULL. Here we can keep the code as it was. Let me know if you want me to respin.
> > 
> > TBH I don't think a NULL check here hurts much since the behaviour might
> > change later, and error paths don't get exercised as often. But I have
> 
> I agree, but at the same time we're introducing checks gratuitously. Since
> Michael cared about it, it's fine that we removed it. I don't care too much
> about it.
> 
> > made both changes when applying. You can double-check at [0] if you
> > want.> 
> > [0] https://github.com/prati0100/linux-0day/commit/67d913746833ee54bf4c661040f3ef13657dffd8
> 
> looks good.
> 
> btw: I think this patch
> https://github.com/prati0100/linux-0day/commit/b45bbff85d49529f8daff83c341a292f6c6492ca
> may introduce a regression on some atmel chips. Let me try it please.

Did you get a chance to try this out? If it works fine, I would like to 
apply it.

> > 
> >>
> >>> +   else if (IS_ERR(info))
> >>>             return PTR_ERR(info);
> >>>
> >>>     nor->info = info;
> >>
> > 
> > --
> > Regards,
> > Pratyush Yadav
> > Texas Instruments Inc.
> 

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2022-04-27  5:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 10:34 [PATCH v4 00/11] mtd: spi-nor: Rework Octal DTR methods Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 01/11] mtd: spi-nor: Rename method, s/spi_nor_match_id/spi_nor_match_name Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 02/11] mtd: spi-nor: Introduce spi_nor_match_id() Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 03/11] mtd: spi-nor: core: Use auto-detection only once Tudor Ambarus
2022-04-21  7:18   ` Tudor.Ambarus
2022-04-21 13:16     ` Pratyush Yadav
2022-04-21 13:41       ` Tudor.Ambarus
2022-04-27  5:20         ` Pratyush Yadav [this message]
2022-04-27  7:13           ` Tudor.Ambarus
2022-04-20 10:34 ` [PATCH v4 04/11] mtd: spi-nor: core: Introduce method for RDID op Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 05/11] mtd: spi-nor: manufacturers: Use spi_nor_read_id() core method Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 06/11] mtd: spi-nor: core: Add helpers to read/write any register Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 07/11] mtd: spi-nor: micron-st: Rework spi_nor_micron_octal_dtr_enable() Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 08/11] mtd: spi-nor: spansion: Rework spi_nor_cypress_octal_dtr_enable() Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 09/11] mtd: spi-nor: Introduce templates for SPI NOR operations Tudor Ambarus
2022-04-20 10:34 ` [PATCH v4 10/11] mtd: spi-nor: spansion: Remove status polling on volatile registers write Tudor Ambarus
2022-04-20 20:04   ` Michael Walle
2022-04-20 10:34 ` [PATCH v4 11/11] mtd: spi-nor: micron-st: " Tudor Ambarus
2022-04-20 20:05   ` Michael Walle
2022-04-27  9:31 ` [PATCH v4 00/11] mtd: spi-nor: Rework Octal DTR methods Pratyush Yadav

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=20220427052000.xmctvowj4kuc727d@ti.com \
    --to=p.yadav@ti.com \
    --cc=Takahiro.Kuwano@infineon.com \
    --cc=Tudor.Ambarus@microchip.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=michael@walle.cc \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=vigneshr@ti.com \
    /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