[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <DB6PR0402MB2760A4407DD4588947A0AD5E88020@DB6PR0402MB2760.eurprd04.prod.outlook.com>
Date: Thu, 15 Oct 2020 02:21:38 +0000
From: Peng Fan <peng.fan@....com>
To: Mathieu Poirier <mathieu.poirier@...aro.org>,
"bjorn.andersson@...aro.org" <bjorn.andersson@...aro.org>,
"ohad@...ery.com" <ohad@...ery.com>
CC: "linux-remoteproc@...r.kernel.org" <linux-remoteproc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH 09/13] remoteproc: Add return value to function
rproc_shutdown()
> Subject: [PATCH 09/13] remoteproc: Add return value to function
> rproc_shutdown()
>
> Add a return value to function rproc_shutdown() in order to properly deal with
> error conditions that may occur.
>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
> ---
> drivers/remoteproc/remoteproc_core.c | 13 +++++++++----
> include/linux/remoteproc.h | 2 +-
> 2 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/remoteproc/remoteproc_core.c
> b/drivers/remoteproc/remoteproc_core.c
> index c4b80ce6f22d..c6c6aba66098 100644
> --- a/drivers/remoteproc/remoteproc_core.c
> +++ b/drivers/remoteproc/remoteproc_core.c
> @@ -1846,7 +1846,7 @@ EXPORT_SYMBOL(rproc_boot);
> * returns, and users can still use it with a subsequent rproc_boot(), if
> * needed.
> */
> -void rproc_shutdown(struct rproc *rproc)
> +int rproc_shutdown(struct rproc *rproc)
> {
> struct device *dev = &rproc->dev;
> int ret;
> @@ -1854,15 +1854,19 @@ void rproc_shutdown(struct rproc *rproc)
> ret = mutex_lock_interruptible(&rproc->lock);
> if (ret) {
> dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
> - return;
> + return ret;
> }
>
> - if (rproc->state != RPROC_RUNNING)
> + if (rproc->state != RPROC_RUNNING) {
> + ret = -EPERM;
> goto out;
> + }
>
> /* if the remote proc is still needed, bail out */
> - if (!atomic_dec_and_test(&rproc->power))
> + if (!atomic_dec_and_test(&rproc->power)) {
> + ret = -EBUSY;
> goto out;
> + }
>
> ret = rproc_stop(rproc, false);
> if (ret) {
> @@ -1884,6 +1888,7 @@ void rproc_shutdown(struct rproc *rproc)
> rproc->table_ptr = NULL;
> out:
> mutex_unlock(&rproc->lock);
> + return ret;
> }
> EXPORT_SYMBOL(rproc_shutdown);
>
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index
> 6250491ee851..40eccfbc1357 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -655,7 +655,7 @@ rproc_of_resm_mem_entry_init(struct device *dev,
> u32 of_resm_idx, size_t len,
> u32 da, const char *name, ...);
>
> int rproc_boot(struct rproc *rproc);
> -void rproc_shutdown(struct rproc *rproc);
> +int rproc_shutdown(struct rproc *rproc);
> int rproc_detach(struct rproc *rproc);
> void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
> int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t
> size);
> --
Reviewed-by: Peng Fan <peng.fan@....com>
Powered by blists - more mailing lists