[PATCH 5/7] nvmem: support deep probe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux