From: Ahmad Fatoum <a.fatoum@pengutronix.de> To: barebox@lists.infradead.org Cc: Ahmad Fatoum <a.fatoum@pengutronix.de> Subject: [PATCH 5/7] nvmem: support deep probe Date: Mon, 28 Jun 2021 08:45:15 +0200 [thread overview] Message-ID: <20210628064517.28636-6-a.fatoum@pengutronix.de> (raw) In-Reply-To: <20210628064517.28636-1-a.fatoum@pengutronix.de> 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> --- 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@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2021-06-28 6:46 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-06-28 6:45 [PATCH 0/7] sandbox: turn into deep probe platform Ahmad Fatoum 2021-06-28 6:45 ` [PATCH 1/7] sandbox: power: set $global.system.reset=POR on poweroff Ahmad Fatoum 2021-06-28 6:45 ` [PATCH 2/7] sandbox: fix probe order dependency between watchdog and power Ahmad Fatoum 2021-06-28 6:45 ` [PATCH 3/7] of: partition: implement of_partition_ensure_probed Ahmad Fatoum 2021-06-28 6:45 ` [PATCH 4/7] state: support deep probe Ahmad Fatoum 2021-06-28 6:45 ` Ahmad Fatoum [this message] 2021-06-28 6:45 ` [PATCH 6/7] sandbox: turn into deep probe platform Ahmad Fatoum 2021-06-28 6:45 ` [PATCH 7/7] Revert "sandbox: hostfile: move initcall to earlier postcore level" Ahmad Fatoum 2021-07-18 5:14 ` [PATCH 0/7] sandbox: turn into deep probe platform Sascha Hauer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210628064517.28636-6-a.fatoum@pengutronix.de \ --to=a.fatoum@pengutronix.de \ --cc=barebox@lists.infradead.org \ --subject='Re: [PATCH 5/7] nvmem: support deep probe' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox