Commit 7c89717f82bd305e3102963485f3da160d11bcf6

Authored by Bjorn Andersson
1 parent 4fec0a5a19

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>

Showing 2 changed files with 20 additions and 0 deletions Side-by-side Diff

drivers/remoteproc/remoteproc_core.c
... ... @@ -1431,6 +1431,7 @@
1431 1431 rproc->dev.parent = dev;
1432 1432 rproc->dev.type = &rproc_type;
1433 1433 rproc->dev.class = &rproc_class;
  1434 + rproc->dev.driver_data = rproc;
1434 1435  
1435 1436 /* Assign a unique device index and name */
1436 1437 rproc->index = ida_simple_get(&rproc_dev_index, 0, 0, GFP_KERNEL);
... ... @@ -1568,6 +1569,23 @@
1568 1569 list_del(&subdev->node);
1569 1570 }
1570 1571 EXPORT_SYMBOL(rproc_remove_subdev);
  1572 +
  1573 +/**
  1574 + * rproc_get_by_child() - acquire rproc handle of @dev's ancestor
  1575 + * @dev: child device to find ancestor of
  1576 + *
  1577 + * Returns the ancestor rproc instance, or NULL if not found.
  1578 + */
  1579 +struct rproc *rproc_get_by_child(struct device *dev)
  1580 +{
  1581 + for (dev = dev->parent; dev; dev = dev->parent) {
  1582 + if (dev->type == &rproc_type)
  1583 + return dev->driver_data;
  1584 + }
  1585 +
  1586 + return NULL;
  1587 +}
  1588 +EXPORT_SYMBOL(rproc_get_by_child);
1571 1589  
1572 1590 /**
1573 1591 * rproc_report_crash() - rproc crash reporter function
include/linux/remoteproc.h
... ... @@ -510,6 +510,8 @@
510 510 };
511 511  
512 512 struct rproc *rproc_get_by_phandle(phandle phandle);
  513 +struct rproc *rproc_get_by_child(struct device *dev);
  514 +
513 515 struct rproc *rproc_alloc(struct device *dev, const char *name,
514 516 const struct rproc_ops *ops,
515 517 const char *firmware, int len);