From be55672841631d539a723f141422f06b3dca145b Mon Sep 17 00:00:00 2001 From: Arnaud Pouliquen Date: Thu, 16 Apr 2020 18:13:17 +0200 Subject: [PATCH] remoteproc: Add rproc_get_by_node helper Allow to retrieve the rproc structure from a rproc platform child declared in the device tree. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 16 ++++++++-------- include/linux/remoteproc.h | 7 ++++++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 18dd750240aa9d..607e276790a729 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2085,10 +2085,10 @@ int rproc_detach(struct rproc *rproc) EXPORT_SYMBOL(rproc_detach); /** - * rproc_get_by_phandle() - find a remote processor by phandle - * @phandle: phandle to the rproc + * rproc_get_by_node() - find a remote processor by device node + * @np: device tree node * - * Finds an rproc handle using the remote processor's phandle, and then + * Finds an rproc handle using the remote processor's node, and then * return a handle to the rproc. * * This function increments the remote processor's refcount, so always @@ -2097,15 +2097,15 @@ EXPORT_SYMBOL(rproc_detach); * Return: rproc handle on success, and NULL on failure */ #ifdef CONFIG_OF -struct rproc *rproc_get_by_phandle(phandle phandle) +struct rproc *rproc_get_by_node(struct device_node *np) { struct rproc *rproc = NULL, *r; - struct device_node *np; - np = of_find_node_by_phandle(phandle); if (!np) return NULL; + of_node_get(np); + rcu_read_lock(); list_for_each_entry_rcu(r, &rproc_list, node) { if (r->dev.parent && r->dev.parent->of_node == np) { @@ -2127,12 +2127,12 @@ struct rproc *rproc_get_by_phandle(phandle phandle) return rproc; } #else -struct rproc *rproc_get_by_phandle(phandle phandle) +struct rproc *rproc_get_by_node(struct device_node *np) { return NULL; } #endif -EXPORT_SYMBOL(rproc_get_by_phandle); +EXPORT_SYMBOL(rproc_get_by_node); /** * rproc_set_firmware() - assign a new firmware diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 1abf56ad02dacc..0290e8696de274 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -638,9 +638,14 @@ struct rproc_vdev { u32 index; }; -struct rproc *rproc_get_by_phandle(phandle phandle); +struct rproc *rproc_get_by_node(struct device_node *np); struct rproc *rproc_get_by_child(struct device *dev); +static inline struct rproc *rproc_get_by_phandle(phandle phandle) +{ + return rproc_get_by_node(of_find_node_by_phandle(phandle)); +} + struct rproc *rproc_alloc(struct device *dev, const char *name, const struct rproc_ops *ops, const char *firmware, int len);