summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-06-28 08:45:15 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-07-18 07:14:12 +0200
commit2e04cb3bf9a838afa8fc1cd86fd254db13d0f691 (patch)
treebeddf761271b36f61c89baaeabd5c7a041f2dadd /drivers
parentac71031705cedd53570b8b0a4a6b63473f7127c3 (diff)
downloadbarebox-2e04cb3bf9a838afa8fc1cd86fd254db13d0f691.tar.gz
barebox-2e04cb3bf9a838afa8fc1cd86fd254db13d0f691.tar.xz
nvmem: support deep probe
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@pengutronix.de> Link: https://lore.barebox.org/20210628064517.28636-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/nvmem/core.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 4e558e1650..54a72b71a7 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);