Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796110809; b=1yH5CloNLO1UBAnXnGbyubnyxFgLNVsK57gcamN6XnxyNfglDP4WAScCU9xjuXNB0Dvp GeSvSKFI8C8Wk7Z1HSPFGuhmJK+UHi7INBIvzt8ebvoQxCRJwE83c+uKD2b2zzZ6dVA2C hDuwl748/0m22XdcPAz9seYTMxvoGi3PeVYGgGSdNjJNiXWAzhXBK5jAF+5/Ff3odYZuc ZvcWJBq8sKxjqTLh7ljawNQNmvV/A9AsNHfLWcX1oSfVPzuHAzhU0FSB+YvIz+BEhzKxy 8yxvBred5zQlD5vzyzdCVfrWcGfFEk02ts1rWXroc/a5WK3kt6bTjdwz5xOL2sj+fAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796110809; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=OsrMpR2KaDJOsHKhQSqhceBnvF9FM/Qpaf6kRALjUIU=; b=jCPxEerheeb5rEiwiC9wvpJVd8FxnUOr03F/0zpI/EcjjvoxdPQAEPXfvCeWqgK8FIAp uC4hj4j8hIFj9b0DPcpqLnU6mVNJoR0nNzDMPNlktq+YDFdJhlpE/3TcSkWZnNFpUpDu1 XyLL0cUPYCWL1791muFeQ8Q9uBdjl6oH/b1VojiW522NLkxZQRy+4H8yil4k9pNnvySk2 6IiqM0jt/dFyS8PfDMhlPJFnpa4jASZmp2mAJOOC/4zRw/6f/zRktN7CSvEfV+BUorSV2 tFKiCxuSoV1G/9hcJgPXHhRn1YM0MDC2S+8+JgSlFrsjSZN+bRQnRU3fiPKZfo6fxDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UWcT8pS2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 937DF606A32A for ; Tue, 1 Dec 2026 07:40:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=UWcT8pS2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B03AD1F000C1; Tue, 1 Dec 2026 07:40:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796110809; bh=OsrMpR2KaDJOsHKhQSqhceBnvF9FM/Qpaf6kRALjUIU=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=UWcT8pS2T0u4IlEXni4szueNY/hKvg+xLy2UAk5U3hIzrheWcD8bRAepP2ps5M+pc IwaBR56WLYxS/mcs5PtegL8Tl5rRgGls1RyD6CObKKhy50+01nSWvz1BBs8s4kWW1l hnfIZgqE1bMYuHa2hPDIgTFUDV4bGAWybMx/15LfQy+rGL4XQzdvGg8JeSxfxrLOkE y6SNJWauTJ2FNqufRReL66WUMFXealp/woTvBhxn1svsvDzkaQOioCZ6HaYh+swshD 70LzoiIedGlP+TUr7qe7eQujp1MOGbdYZC7rH5rmsNEMmZAOpRK5841YJnWCSCzM0s fgqpDfS6qcNbQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v11 4/8] mtd: spi-nor: sfdp: expose the SFDP as a read-only NVMEM device Reply-To: sashiko-reviews@lists.linux.dev To: "Manikandan Muralidharan" , 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 In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 07:40:07 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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_no= r *nor) > } > } > =20 > +static int spi_nor_sfdp_reg_read(void *priv, unsigned int offset, > + void *val, size_t bytes) > +{ > + struct spi_nor *nor =3D priv; > + struct sfdp *sfdp =3D nor->sfdp; > + size_t sfdp_size =3D sfdp->num_dwords * sizeof(*sfdp->dwords); > + > + if (offset >=3D 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 d= evice > + * rooted at the flash's SFDP child node (compatible "jedec,sfdp"), if a= ny. > + * This lets generic (fixed-layout) or vendor (nvmem-layout) cells refer= ence > + * 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 =3D nor->dev; > + struct nvmem_config config =3D { }; > + struct nvmem_device *nvmem; > + struct device_node *np; > + > + if (!nor->sfdp) > + return 0; > + > + np =3D of_get_compatible_child(spi_nor_get_flash_node(nor), "jedec,sfdp= "); > + > + config.dev =3D dev; > + config.of_node =3D 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 =3D of_node_get(config->of_node); else nvmem->dev.of_node =3D 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 (setti= ng 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 =3D !np would prevent nvmem_register() from falli= ng back to config.dev->of_node when no "jedec,sfdp" child node is present. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796023049.gi= t.manikandan.m@microchip.com?part=3D4