[PATCH 2/2] nvmem: core: don't defer for a missing cell once the layout is bound
From: Manikandan Muralidharan
Date: Wed Nov 11 2026 - 07:18:20 EST
of_nvmem_cell_get() returns -EPROBE_DEFER whenever a requested cell is
not found and the nvmem device has a layout, assuming the layout has not
added its cells yet. A layout may add none, e.g. when the data the cell
describes is not programmed on the device. The layout is then bound but
the cell is never going to show up, and the consumer is deferred forever
instead of falling back.
Only defer while the layout device is not bound yet, and return -ENOENT
once it is, so that a consumer such as an Ethernet MAC can fall back to a
random address.
Signed-off-by: Manikandan Muralidharan <manikandan.m@xxxxxxxxxxxxx>
---
drivers/nvmem/core.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index be3a05150085..f34a35a04e55 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -1403,6 +1403,31 @@ static int nvmem_layout_module_get_optional(struct nvmem_device *nvmem)
return 0;
}
+/**
+ * nvmem_layout_pending() - Check whether a layout may still add cells
+ * @nvmem: nvmem device the layout belongs to
+ *
+ * A layout adds its cells from its probe. Once the layout device is bound,
+ * a cell that is still missing is never going to show up.
+ *
+ * Return: true if @nvmem has a layout that is not bound yet, false otherwise.
+ */
+static bool nvmem_layout_pending(struct nvmem_device *nvmem)
+{
+ struct device *dev;
+ bool bound;
+
+ if (!nvmem->layout)
+ return false;
+
+ dev = &nvmem->layout->dev;
+ device_lock(dev);
+ bound = device_is_bound(dev);
+ device_unlock(dev);
+
+ return !bound;
+}
+
/**
* of_nvmem_cell_get() - Get a nvmem cell from given device node and cell id
*
@@ -1486,7 +1511,7 @@ struct nvmem_cell *of_nvmem_cell_get(struct device_node *np, const char *id)
of_node_put(cell_np);
if (!cell_entry) {
nvmem_layout_module_put(nvmem);
- ret = nvmem->layout ? -EPROBE_DEFER : -ENOENT;
+ ret = nvmem_layout_pending(nvmem) ? -EPROBE_DEFER : -ENOENT;
nvmem_device_put(nvmem);
return ERR_PTR(ret);
}
--
2.43.0