From: sashiko-bot@kernel.org
To: "Manikandan Muralidharan" <manikandan.m@microchip.com>,
pratyush@kernel.org, mwalle@kernel.org,
takahiro.kuwano@infineon.com, miquel.raynal@bootlin.com,
richard@nod.at, vigneshr@ti.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, srini@kernel.org,
nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
claudiu.beznea@tuxon.dev, linux@armlinux.org.uk,
richardcochran@gmail.com, arnd@arndb.de, linusw@kernel.org,
aaro.koskinen@iki.fi, enelsonmoore@gmail.com,
pengpeng@iscas.ac.cn, mathieu.dubois-briand@bootlin.com,
gregkh@linuxfoundation.org, michael@walle.cc,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v11 4/8] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
Date: Tue, 01 Dec 2026 07:40:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-242787@kernel.org> (raw)
In-Reply-To: <e0845e36812abd68ce04e3fb65019ed532040198.1796023049.git.manikandan.m@microchip.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mtd: spi-nor: sfdp: fallback to flash of_node when jedec,sfdp
node is absent
--
commit 8a3fe39489a26fec0038013ef138f50151c5023f
Author: Manikandan Muralidharan <manikandan.m@microchip.com>
mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
This commit exposes the cached SFDP data of a SPI NOR flash as a read-only
NVMEM device rooted at the flash's "jedec,sfdp" child node.
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index a04d22d2e2e1c..99584ee0ecb32 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
[ ... ]
> @@ -2816,6 +2817,73 @@ static void spi_nor_init_fixup_flags(struct spi_nor *nor)
> }
> }
>
> +static int spi_nor_sfdp_reg_read(void *priv, unsigned int offset,
> + void *val, size_t bytes)
> +{
> + struct spi_nor *nor = priv;
> + struct sfdp *sfdp = nor->sfdp;
> + size_t sfdp_size = sfdp->num_dwords * sizeof(*sfdp->dwords);
> +
> + if (offset >= sfdp_size || bytes > sfdp_size - offset)
> + return -EINVAL;
> +
> + /* The cached SFDP is kept in on-flash (little-endian) byte order. */
> + memcpy(val, (u8 *)sfdp->dwords + offset, bytes);
> +
> + return 0;
> +}
> +
> +/**
> + * spi_nor_register_sfdp_nvmem() - expose the SFDP as a read-only NVMEM device
> + * @nor: pointer to a 'struct spi_nor'
> + *
> + * Expose the whole SFDP, in on-flash byte order, as a read-only NVMEM device
> + * rooted at the flash's SFDP child node (compatible "jedec,sfdp"), if any.
> + * This lets generic (fixed-layout) or vendor (nvmem-layout) cells reference
> + * any SFDP data.
> + *
> + * Return: 0 on success or if there is nothing to do, -errno otherwise.
> + */
> +static int spi_nor_register_sfdp_nvmem(struct spi_nor *nor)
> +{
> + struct device *dev = nor->dev;
> + struct nvmem_config config = { };
> + struct nvmem_device *nvmem;
> + struct device_node *np;
> +
> + if (!nor->sfdp)
> + return 0;
> +
> + np = of_get_compatible_child(spi_nor_get_flash_node(nor), "jedec,sfdp");
> +
> + config.dev = dev;
> + config.of_node = np;
[Severity: High]
When the flash DT node has no "jedec,sfdp" child node, np is NULL, and does
nvmem_register() then fall back to binding the SFDP NVMEM device to
config.dev->of_node?
drivers/nvmem/core.c:nvmem_register() {
...
if (config->of_node)
nvmem->dev.of_node = of_node_get(config->of_node);
else
nvmem->dev.of_node = of_node_get(config->dev->of_node);
...
}
Because spi_nor_register_sfdp_nvmem() runs during spi_nor_scan() before
mtd_device_register() calls mtd_otp_nvmem_add() and mtd_nvmem_add(), the
SFDP NVMEM device claims the flash DT node first. Any nvmem-layout child of
the flash node is populated on the SFDP device instead of mtd->nvmem (setting
OF_POPULATED_BUS so mtd_nvmem_add() skips it), and of_nvmem_cell_get() or
of_nvmem_device_get() lookups targeting the flash node match the SFDP device
first on nvmem_bus_type instead of the flash MTD or OTP NVMEM devices.
Setting config.no_of_node = !np would prevent nvmem_register() from falling
back to config.dev->of_node when no "jedec,sfdp" child node is present.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796023049.git.manikandan.m@microchip.com?part=4
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Manikandan Muralidharan" <manikandan.m@microchip.com>,
pratyush@kernel.org, mwalle@kernel.org,
takahiro.kuwano@infineon.com, miquel.raynal@bootlin.com,
richard@nod.at, vigneshr@ti.com, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org, srini@kernel.org,
nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com,
claudiu.beznea@tuxon.dev, linux@armlinux.org.uk,
richardcochran@gmail.com, arnd@arndb.de, linusw@kernel.org,
aaro.koskinen@iki.fi, enelsonmoore@gmail.com,
pengpeng@iscas.ac.cn, mathieu.dubois-briand@bootlin.com,
gregkh@linuxfoundation.org, michael@walle.cc,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v11 4/8] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
Date: Tue, 01 Dec 2026 07:40:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-242787@kernel.org> (raw)
In-Reply-To: <e0845e36812abd68ce04e3fb65019ed532040198.1796023049.git.manikandan.m@microchip.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] mtd: spi-nor: sfdp: fallback to flash of_node when jedec,sfdp
node is absent
--
commit 8a3fe39489a26fec0038013ef138f50151c5023f
Author: Manikandan Muralidharan <manikandan.m@microchip.com>
mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device
This commit exposes the cached SFDP data of a SPI NOR flash as a read-only
NVMEM device rooted at the flash's "jedec,sfdp" child node.
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index a04d22d2e2e1c..99584ee0ecb32 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
[ ... ]
> @@ -2816,6 +2817,73 @@ static void spi_nor_init_fixup_flags(struct spi_nor *nor)
> }
> }
>
> +static int spi_nor_sfdp_reg_read(void *priv, unsigned int offset,
> + void *val, size_t bytes)
> +{
> + struct spi_nor *nor = priv;
> + struct sfdp *sfdp = nor->sfdp;
> + size_t sfdp_size = sfdp->num_dwords * sizeof(*sfdp->dwords);
> +
> + if (offset >= sfdp_size || bytes > sfdp_size - offset)
> + return -EINVAL;
> +
> + /* The cached SFDP is kept in on-flash (little-endian) byte order. */
> + memcpy(val, (u8 *)sfdp->dwords + offset, bytes);
> +
> + return 0;
> +}
> +
> +/**
> + * spi_nor_register_sfdp_nvmem() - expose the SFDP as a read-only NVMEM device
> + * @nor: pointer to a 'struct spi_nor'
> + *
> + * Expose the whole SFDP, in on-flash byte order, as a read-only NVMEM device
> + * rooted at the flash's SFDP child node (compatible "jedec,sfdp"), if any.
> + * This lets generic (fixed-layout) or vendor (nvmem-layout) cells reference
> + * any SFDP data.
> + *
> + * Return: 0 on success or if there is nothing to do, -errno otherwise.
> + */
> +static int spi_nor_register_sfdp_nvmem(struct spi_nor *nor)
> +{
> + struct device *dev = nor->dev;
> + struct nvmem_config config = { };
> + struct nvmem_device *nvmem;
> + struct device_node *np;
> +
> + if (!nor->sfdp)
> + return 0;
> +
> + np = of_get_compatible_child(spi_nor_get_flash_node(nor), "jedec,sfdp");
> +
> + config.dev = dev;
> + config.of_node = np;
[Severity: High]
When the flash DT node has no "jedec,sfdp" child node, np is NULL, and does
nvmem_register() then fall back to binding the SFDP NVMEM device to
config.dev->of_node?
drivers/nvmem/core.c:nvmem_register() {
...
if (config->of_node)
nvmem->dev.of_node = of_node_get(config->of_node);
else
nvmem->dev.of_node = of_node_get(config->dev->of_node);
...
}
Because spi_nor_register_sfdp_nvmem() runs during spi_nor_scan() before
mtd_device_register() calls mtd_otp_nvmem_add() and mtd_nvmem_add(), the
SFDP NVMEM device claims the flash DT node first. Any nvmem-layout child of
the flash node is populated on the SFDP device instead of mtd->nvmem (setting
OF_POPULATED_BUS so mtd_nvmem_add() skips it), and of_nvmem_cell_get() or
of_nvmem_device_get() lookups targeting the flash node match the SFDP device
first on nvmem_bus_type instead of the flash MTD or OTP NVMEM devices.
Setting config.no_of_node = !np would prevent nvmem_register() from falling
back to config.dev->of_node when no "jedec,sfdp" child node is present.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796023049.git.manikandan.m@microchip.com?part=4
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2026-12-01 7:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 7:37 [PATCH v11 0/8] Read MAC address from SST vendor specific SFDP region Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-11-30 7:37 ` [PATCH v11 1/8] dt-bindings: mtd: jedec,spi-nor: allow the SFDP to be exposed via NVMEM Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-11-30 7:37 ` [PATCH v11 2/8] dt-bindings: nvmem: layouts: add Microchip/SST SFDP EUI layout Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-11-30 7:37 ` [PATCH v11 3/8] nvmem: core: take a reference on dev.of_node in nvmem_register() Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-11-30 7:37 ` [PATCH v11 4/8] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-12-01 7:40 ` sashiko-bot [this message]
2026-12-01 7:40 ` sashiko-bot
2026-11-30 7:37 ` [PATCH v11 5/8] nvmem: layouts: add Microchip/SST SFDP EUI layout driver Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-12-01 7:40 ` sashiko-bot
2026-12-01 7:40 ` sashiko-bot
2026-11-30 7:37 ` [PATCH v11 6/8] ARM: dts: microchip: sama5d27_wlsom1: use fixed-partitions for QSPI flash Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-11-30 7:37 ` [PATCH v11 7/8] ARM: dts: microchip: sama5d27_wlsom1: read MAC address from QSPI SFDP Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
2026-11-30 7:37 ` [PATCH v11 8/8] ARM: configs: sama5: enable Microchip/SST SFDP EUI NVMEM layout Manikandan Muralidharan
2026-11-30 7:37 ` Manikandan Muralidharan
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=sashiko-outbox-242787@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aaro.koskinen@iki.fi \
--cc=alexandre.belloni@bootlin.com \
--cc=arnd@arndb.de \
--cc=claudiu.beznea@tuxon.dev \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=enelsonmoore@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=manikandan.m@microchip.com \
--cc=mathieu.dubois-briand@bootlin.com \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=nicolas.ferre@microchip.com \
--cc=pengpeng@iscas.ac.cn \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=richardcochran@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=srini@kernel.org \
--cc=takahiro.kuwano@infineon.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 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.