[PATCH v3 07/14] remoteproc: Introducting new start and stop functions

From: Mathieu Poirier
Date: Fri Apr 24 2020 - 16:02:13 EST


Add new functions to replace direct calling of rproc->ops->start() and
rproc->ops->stop(). That way different behaviour can be played out
when booting a remote processor or synchronising with it.

Signed-off-by: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
---
drivers/remoteproc/remoteproc_core.c | 6 +++---
drivers/remoteproc/remoteproc_internal.h | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 9de0e2b7ca2b..ef88d3e84bfb 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1339,7 +1339,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)
}

/* power up the remote processor */
- ret = rproc->ops->start(rproc);
+ ret = rproc_start_device(rproc);
if (ret) {
dev_err(dev, "can't start rproc %s: %d\n", rproc->name, ret);
goto unprepare_subdevices;
@@ -1360,7 +1360,7 @@ static int rproc_start(struct rproc *rproc, const struct firmware *fw)
return 0;

stop_rproc:
- rproc->ops->stop(rproc);
+ rproc_stop_device(rproc);
unprepare_subdevices:
rproc_unprepare_subdevices(rproc);
reset_table_ptr:
@@ -1493,7 +1493,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
rproc->table_ptr = rproc->cached_table;

/* power off the remote processor */
- ret = rproc->ops->stop(rproc);
+ ret = rproc_stop_device(rproc);
if (ret) {
dev_err(dev, "can't stop rproc: %d\n", ret);
return ret;
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index 47b500e40dd9..dda7044c4b3e 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -125,6 +125,22 @@ struct resource_table *rproc_find_loaded_rsc_table(struct rproc *rproc,
return NULL;
}

+static inline int rproc_start_device(struct rproc *rproc)
+{
+ if (rproc->ops && rproc->ops->start)
+ return rproc->ops->start(rproc);
+
+ return 0;
+}
+
+static inline int rproc_stop_device(struct rproc *rproc)
+{
+ if (rproc->ops && rproc->ops->stop)
+ return rproc->ops->stop(rproc);
+
+ return 0;
+}
+
static inline
bool rproc_u64_fit_in_size_t(u64 val)
{
--
2.20.1