diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-08-28 07:34:53 +0200 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-09-02 00:49:13 +0200 |
commit | 7c89717f82bd305e3102963485f3da160d11bcf6 (patch) | |
tree | 616279dd2fb1c43108e69644439d1e8f2216db6e /drivers/remoteproc | |
parent | remoteproc: qcom: Make ssr_notifiers local (diff) | |
download | linux-7c89717f82bd305e3102963485f3da160d11bcf6.tar.xz linux-7c89717f82bd305e3102963485f3da160d11bcf6.zip |
remoteproc: Introduce rproc handle accessor for children
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>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r-- | drivers/remoteproc/remoteproc_core.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 8072df1f0f94..eab14b414bf0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -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); @@ -1570,6 +1571,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 * @type: crash type |