Linux Documentation
 help / color / mirror / Atom feed
From: <Takahiro.Kuwano@infineon.com>
To: <miquel.raynal@bootlin.com>, <pratyush@kernel.org>,
	<mwalle@kernel.org>, <richard@nod.at>, <vigneshr@ti.com>,
	<nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
	<claudiu.beznea@tuxon.dev>, <corbet@lwn.net>,
	<skhan@linuxfoundation.org>
Cc: <STLin2@winbond.com>, <hsinyi@chromium.org>,
	<thomas.petazzoni@bootlin.com>, <linux-mtd@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-doc@vger.kernel.org>
Subject: RE: [PATCH v3 05/23] mtd: spi-nor: Create the concept of fixup table with match function
Date: Thu, 20 Aug 2026 05:56:28 +0000	[thread overview]
Message-ID: <8309659bd3a24f37aeef01a8d75844d5@infineon.com> (raw)
In-Reply-To: <20260813-winbond-v7-1-spi-nor-rv-addition-v3-5-b637cf120d5c@bootlin.com>

> Manufacturer ID tables increase and fixup() hooks proliferate. Having
> one possible structure per chip was fine until the fixups started being
> more and more common and needed, to some extend due to ID reuses. Mixing
> fixups and chips becomes hard and requires extra helpers to sort which
> ones are needed for a given chip, which every time this happens requires
> a lot of rework.
> 
> Replace the two-level fixup association (a manufacturer wide hook and a
> per flash_info hook) with a per-manufacturer list of fixups that can be
> looked up by flash ID and/or match function.
> 
> The match logic works as follows:
> - If there is an ID, it must match
> - If there is a match function, it must match (cumulative)
> - If there is no identifier (no ID nor any match function), it's a
>   catch-all entry typically used for flagging manufacturer fixups.
> 
> Suggested-by: Michael Walle <mwalle@kernel.org>
> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>

[...]

> diff --git a/drivers/mtd/spi-nor/spansion.c b/drivers/mtd/spi-nor/spansion.c
> index ca2703a5a338..f3862eb1a23a 100644
> --- a/drivers/mtd/spi-nor/spansion.c
> +++ b/drivers/mtd/spi-nor/spansion.c
> @@ -905,7 +905,6 @@ static const struct flash_info spansion_nor_parts[] = {
>                 .sector_size = SZ_256K,
>                 .no_sfdp_flags = SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
>                 .mfr_flags = USE_CLSR,
> -               .fixups = &s25fs_s_nor_fixups,
>         }, {
>                 .id = SNOR_ID(0x01, 0x20, 0x18, 0x03, 0x00),
>                 .name = "s25sl12800",
> @@ -941,7 +940,6 @@ static const struct flash_info spansion_nor_parts[] = {
>                 .size = SZ_16M,
>                 .no_sfdp_flags = SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ,
>                 .mfr_flags = USE_CLSR,
> -               .fixups = &s25fs_s_nor_fixups,
>         }, {
>                 .id = SNOR_ID(0x01, 0x20, 0x18, 0x4d, 0x01),
>                 .name = "s25fl129p1",
> @@ -1001,76 +999,61 @@ static const struct flash_info spansion_nor_parts[] = {
>                 .id = SNOR_ID(0x34, 0x2a, 0x1a, 0x0f, 0x03, 0x90),
>                 .name = "s25hl512t",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25hx_t_fixups
>         }, {
>                 .id = SNOR_ID(0x34, 0x2a, 0x1b, 0x0f, 0x03, 0x90),
>                 .name = "s25hl01gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25hx_t_fixups
>         }, {
>                 .id = SNOR_ID(0x34, 0x2a, 0x1c, 0x0f, 0x00, 0x90),
>                 .name = "s25hl02gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25hx_t_fixups
>         }, {
>                 .id = SNOR_ID(0x34, 0x2b, 0x19, 0x0f, 0x08, 0x90),
>                 .name = "s25fs256t",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25fs256t_fixups
>         }, {
>                 .id = SNOR_ID(0x34, 0x2b, 0x1a, 0x0f, 0x03, 0x90),
>                 .name = "s25hs512t",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25hx_t_fixups
>         }, {
>                 .id = SNOR_ID(0x34, 0x2b, 0x1b, 0x0f, 0x03, 0x90),
>                 .name = "s25hs01gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25hx_t_fixups
>         }, {
>                 .id = SNOR_ID(0x34, 0x2b, 0x1c, 0x0f, 0x00, 0x90),
>                 .name = "s25hs02gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s25hx_t_fixups
>         }, {
>                 /* S28HL256T */
>                 .id = SNOR_ID(0x34, 0x5a, 0x19),
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0x34, 0x5a, 0x1a),
>                 .name = "s28hl512t",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0x34, 0x5a, 0x1b),
>                 .name = "s28hl01gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 /* S28HL02GT */
>                 .id = SNOR_ID(0x34, 0x5a, 0x1c),
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0x34, 0x5b, 0x19),
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0x34, 0x5b, 0x1a),
>                 .name = "s28hs512t",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0x34, 0x5b, 0x1b),
>                 .name = "s28hs01gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0x34, 0x5b, 0x1c),
>                 .name = "s28hs02gt",
>                 .mfr_flags = USE_CLPEF,
> -               .fixups = &s28hx_t_fixups,
>         }, {
>                 .id = SNOR_ID(0xef, 0x40, 0x13),
>                 .name = "s25fl004k",
> @@ -1170,9 +1153,31 @@ static const struct spi_nor_fixups spansion_nor_fixups = {
>         .late_init = spansion_nor_late_init,
>  };
> 
> +static const struct spi_nor_fixup spansion_fixups[] = {
> +       { .fixups = &spansion_nor_fixups },
> +       { .id = SNOR_ID(0x01, 0x02, 0x20, 0x4d, 0x00, 0x81), .fixups = &s25fs_s_nor_fixups },
> +       { .id = SNOR_ID(0x01, 0x20, 0x18, 0x4d, 0x01, 0x81), .fixups = &s25fs_s_nor_fixups },
> +       { .id = SNOR_ID(0x34, 0x2a, 0x1a, 0x0f, 0x03, 0x90), .fixups = &s25hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x2a, 0x1b, 0x0f, 0x03, 0x90), .fixups = &s25hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x2a, 0x1c, 0x0f, 0x00, 0x90), .fixups = &s25hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x2b, 0x19, 0x0f, 0x08, 0x90), .fixups = &s25fs256t_fixups },
> +       { .id = SNOR_ID(0x34, 0x2b, 0x1a, 0x0f, 0x03, 0x90), .fixups = &s25hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x2b, 0x1b, 0x0f, 0x03, 0x90), .fixups = &s25hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x2b, 0x1c, 0x0f, 0x00, 0x90), .fixups = &s25hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5a, 0x19), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5a, 0x1a), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5a, 0x1b), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5a, 0x1c), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5b, 0x19), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5b, 0x1a), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5b, 0x1b), .fixups = &s28hx_t_fixups },
> +       { .id = SNOR_ID(0x34, 0x5b, 0x1c), .fixups = &s28hx_t_fixups },
> +};
> +
>  const struct spi_nor_manufacturer spi_nor_spansion = {
>         .name = "spansion",
>         .parts = spansion_nor_parts,
>         .nparts = ARRAY_SIZE(spansion_nor_parts),
> -       .fixups = &spansion_nor_fixups,
> +       .fixups = spansion_fixups,
> +       .nfixups = ARRAY_SIZE(spansion_fixups),
>  };

With S25FS512S, S25HL512T, and S28HS512T,
Tested-by: Takahiro Kuwano <takahiro.kuwano@infineon.com>


  parent reply	other threads:[~2026-08-20  5:57 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13 15:19 [PATCH v3 00/23] mtd: spi-nor: QE handling cleanup + fixup reworks + Winbond RV chips addition Miquel Raynal
2026-08-13 15:19 ` [PATCH v3 01/23] mtd: spi-nor: Rename BFPT_DWORD15_QER_SR2_BIT1_BUGGY Miquel Raynal
2026-08-14  7:30   ` Michael Walle
2026-08-20  5:50   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 02/23] mtd: spi-nor: Create a structure containing the flash opcodes Miquel Raynal
2026-08-14  7:31   ` Michael Walle
2026-08-20  5:52   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 03/23] mtd: spi-nor: Refactor Read Status/Write Status support Miquel Raynal
2026-08-14 12:25   ` Michael Walle
2026-08-13 15:19 ` [PATCH v3 04/23] mtd: spi-nor: Add support for the new JESD216 rev F QER field Miquel Raynal
2026-08-14 12:26   ` Michael Walle
2026-08-20  5:53   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 05/23] mtd: spi-nor: Create the concept of fixup table with match function Miquel Raynal
2026-08-14  9:40   ` Michael Walle
2026-08-20  5:56   ` Takahiro.Kuwano [this message]
2026-08-13 15:19 ` [PATCH v3 06/23] mtd: spi-nor: Create an indirection on the part name Miquel Raynal
2026-08-14  9:41   ` Michael Walle
2026-08-20  5:57   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 07/23] mtd: spi-nor: Move the SFDP header structure to a C header Miquel Raynal
2026-08-14  9:41   ` Michael Walle
2026-08-20  5:57   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 08/23] mtd: spi-nor: winbond: Prepare introduction of W25QxxRV-Q/N parts Miquel Raynal
2026-08-14  9:46   ` Michael Walle
2026-08-20  5:58   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 09/23] mtd: spi-nor: winbond: Add support for W25Q32RV-Q/N Miquel Raynal
2026-08-14  9:46   ` Michael Walle
2026-08-20  6:03   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 10/23] mtd: spi-nor: winbond: Add support for W25Q64RV-Q/N Miquel Raynal
2026-08-14  9:46   ` Michael Walle
2026-08-20  6:03   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 11/23] mtd: spi-nor: winbond: Add support for W25Q12RV-Q/N Miquel Raynal
2026-08-14  9:47   ` Michael Walle
2026-08-20  6:04   ` Takahiro.Kuwano
2026-08-20  7:32   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 12/23] mtd: spi-nor: winbond: Add support for W25Q51RV-Q/N Miquel Raynal
2026-08-14  9:47   ` Michael Walle
2026-08-20  6:04   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 13/23] mtd: spi-nor: winbond: Add support for W25Q01RV-Q/N Miquel Raynal
2026-08-14  9:47   ` Michael Walle
2026-08-20  6:15   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 14/23] mtd: spi-nor: winbond: Add support for W25Q02RV-Q/N Miquel Raynal
2026-08-14  9:48   ` Michael Walle
2026-08-20  6:17   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 15/23] mtd: spi-nor: winbond: Prepare introduction of W25QxxRV-M parts Miquel Raynal
2026-08-14  9:50   ` Michael Walle
2026-08-20  6:18   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 16/23] mtd: spi-nor: winbond: Add support for W25Q32RV-M Miquel Raynal
2026-08-14  9:50   ` Michael Walle
2026-08-20  6:19   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 17/23] mtd: spi-nor: winbond: Add support for W25Q64RV-M Miquel Raynal
2026-08-14  9:51   ` Michael Walle
2026-08-20  6:21   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 18/23] mtd: spi-nor: winbond: Add support for W25Q12RV-M Miquel Raynal
2026-08-14  9:51   ` Michael Walle
2026-08-20  6:44   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 19/23] mtd: spi-nor: winbond: Add support for W25Q51RV-M Miquel Raynal
2026-08-14  9:52   ` Michael Walle
2026-08-20  6:48   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 20/23] mtd: spi-nor: winbond: Add support for W25Q01RV-M Miquel Raynal
2026-08-14  9:52   ` Michael Walle
2026-08-20  6:50   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 21/23] mtd: spi-nor: winbond: Add support for W25Q02RV-M Miquel Raynal
2026-08-14  9:52   ` Michael Walle
2026-08-20  6:52   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 22/23] mtd: spi-nor: winbond: Add support for W25Q51RV-Q/N/M Miquel Raynal
2026-08-14  9:53   ` Michael Walle
2026-08-20  7:42   ` Takahiro.Kuwano
2026-08-13 15:19 ` [PATCH v3 23/23] mtd: spi-nor: debugfs: Expose SR opcodes and QE mask Miquel Raynal
2026-08-20  7:03   ` Takahiro.Kuwano

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=8309659bd3a24f37aeef01a8d75844d5@infineon.com \
    --to=takahiro.kuwano@infineon.com \
    --cc=STLin2@winbond.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=corbet@lwn.net \
    --cc=hsinyi@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=skhan@linuxfoundation.org \
    --cc=thomas.petazzoni@bootlin.com \
    --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