All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvmem: u-boot-env: support specifying the env storage size
@ 2025-07-30 13:17 Shiji Yang
  2025-07-30 13:17 ` [PATCH 2/2] dt-bindings: nvmem: add env-size property for u-boot env layout Shiji Yang
  0 siblings, 1 reply; 5+ messages in thread
From: Shiji Yang @ 2025-07-30 13:17 UTC (permalink / raw)
  To: devicetree, linux-kernel
  Cc: Rafał Miłecki, Srinivas Kandagatla, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, Shiji Yang

In the current code, we always assume that the env storage size is
the same as the mtd partition size. U-boot supports customizing the
size of the environment area. If its size is different from the MTD
partition size. This will result in CRC32 verification error. This
patch will introduce a new property env-size to give users a chance
to configure the correct env storage size.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
---
 drivers/nvmem/u-boot-env.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/u-boot-env.c b/drivers/nvmem/u-boot-env.c
index ced414fc9..ac9858010 100644
--- a/drivers/nvmem/u-boot-env.c
+++ b/drivers/nvmem/u-boot-env.c
@@ -52,6 +52,7 @@ static int u_boot_env_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct device_node *np = dev->of_node;
 	struct u_boot_env *priv;
+	u32 env_size;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -68,7 +69,12 @@ static int u_boot_env_probe(struct platform_device *pdev)
 
 	config.dev = dev;
 	config.priv = priv;
-	config.size = priv->mtd->size;
+
+	if (!of_property_read_u32(np, "env-size", &env_size) &&
+	    env_size <= priv->mtd->size)
+		config.size = env_size;
+	else
+		config.size = priv->mtd->size;
 
 	priv->nvmem = devm_nvmem_register(dev, &config);
 	if (IS_ERR(priv->nvmem))
-- 
2.50.0


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

end of thread, other threads:[~2025-07-31  8:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-30 13:17 [PATCH 1/2] nvmem: u-boot-env: support specifying the env storage size Shiji Yang
2025-07-30 13:17 ` [PATCH 2/2] dt-bindings: nvmem: add env-size property for u-boot env layout Shiji Yang
2025-07-30 13:20   ` Krzysztof Kozlowski
2025-07-30 23:52   ` Rob Herring
2025-07-31  8:33     ` Alexander Dahl

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.