Skip to content

Commit

Permalink
remoteproc: Introduce rproc handle accessor for children
Browse files Browse the repository at this point in the history
In certain circumstances rpmsg devices needs to acquire a handle to the
ancestor remoteproc instance, e.g. to invoke rproc_report_crash() when a
fatal error is detected. Introduce an interface that walks the device
tree in search for a remoteproc instance and return this.

Tested-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
  • Loading branch information
Bjorn Andersson committed Sep 1, 2017
1 parent 4fec0a5 commit 7c89717
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
rproc->dev.parent = dev;
rproc->dev.type = &rproc_type;
rproc->dev.class = &rproc_class;
rproc->dev.driver_data = rproc;

/* Assign a unique device index and name */
rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
Expand Down Expand Up @@ -1569,6 +1570,23 @@ void rproc_remove_subdev(struct rproc *rproc, struct rproc_subdev *subdev)
}
EXPORT_SYMBOL(rproc_remove_subdev);

/**
* rproc_get_by_child() - acquire rproc handle of @dev's ancestor
* @dev: child device to find ancestor of
*
* Returns the ancestor rproc instance, or NULL if not found.
*/
struct rproc *rproc_get_by_child(struct device *dev)
{
for (dev = dev->parent; dev; dev = dev->parent) {
if (dev->type == &rproc_type)
return dev->driver_data;
}

return NULL;
}
EXPORT_SYMBOL(rproc_get_by_child);

/**
* rproc_report_crash() - rproc crash reporter function
* @rproc: remote processor
Expand Down
2 changes: 2 additions & 0 deletions include/linux/remoteproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ struct rproc_vdev {
};

struct rproc *rproc_get_by_phandle(phandle phandle);
struct rproc *rproc_get_by_child(struct device *dev);

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 7c89717

Please sign in to comment.