[PATCH 5/7] nvmem: support deep probe
Ahmad Fatoum
a.fatoum at pengutronix.de
Sun Jun 27 23:45:15 PDT 2021
With deep probe, drivers referencing nvmem-cells should make sure their
providing nvmem device is already probed. The nvmem cell already takes
care to find out the device node providing the cell. The real provider
that should be probed is then either:
- If the node is in a nvmem-cells partition, the provider is the
parent node (skipping a possible fixed-partitions node in-between)
- Otherwise, the provider is the parent node of the cell
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/nvmem/core.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 980304a8078b..6af30fc5bae7 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -246,13 +246,26 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
}
EXPORT_SYMBOL_GPL(nvmem_register);
+static int of_nvmem_device_ensure_probed(struct device_node *np)
+{
+ if (of_device_is_compatible(np, "nvmem-cells"))
+ return of_partition_ensure_probed(np);
+
+ return of_device_ensure_probed(np);
+}
+
static struct nvmem_device *__nvmem_device_get(struct device_node *np,
struct nvmem_cell **cellp,
const char *cell_id)
{
struct nvmem_device *nvmem = NULL;
+ int ret;
if (np) {
+ ret = of_nvmem_device_ensure_probed(np);
+ if (ret)
+ return ERR_PTR(ret);
+
nvmem = of_nvmem_find(np);
if (!nvmem)
return ERR_PTR(-EPROBE_DEFER);
--
2.30.2
More information about the barebox
mailing list