Skip to content

Commit

Permalink
remoteproc: Add rproc_get_by_node helper
Browse files Browse the repository at this point in the history
Allow to retrieve the rproc structure from a rproc platform
child declared in the device tree.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
  • Loading branch information
arnopo committed Sep 23, 2022
1 parent bea1cbf commit be55672
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 8 additions & 8 deletions drivers/remoteproc/remoteproc_core.c
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion include/linux/remoteproc.h
Expand Up @@ -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);
Expand Down

0 comments on commit be55672

Please sign in to comment.