Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

remoteproc: Change rproc_shutdown() to return a status

The rproc_shutdown() function is currently not returning any
error code, and any failures within rproc_stop() are not passed
back to the users. Change the signature to return a success value
back to the callers.

The remoteproc sysfs and cdev interfaces are also updated to
return back this status to userspace.

Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220213201246.25952-2-s-anna@ti.com

authored by

Suman Anna and committed by
Bjorn Andersson
c13b780c 8d9be5c6

+11 -7
+2 -1
Documentation/staging/remoteproc.rst
··· 49 49 50 50 :: 51 51 52 - void rproc_shutdown(struct rproc *rproc) 52 + int rproc_shutdown(struct rproc *rproc) 53 53 54 54 Power off a remote processor (previously booted with rproc_boot()). 55 55 In case @rproc is still being used by an additional user(s), then 56 56 this function will just decrement the power refcount and exit, 57 57 without really powering off the device. 58 58 59 + Returns 0 on success, and an appropriate error value otherwise. 59 60 Every call to rproc_boot() must (eventually) be accompanied by a call 60 61 to rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug. 61 62
+1 -1
drivers/remoteproc/remoteproc_cdev.c
··· 42 42 rproc->state != RPROC_ATTACHED) 43 43 return -EINVAL; 44 44 45 - rproc_shutdown(rproc); 45 + ret = rproc_shutdown(rproc); 46 46 } else if (!strncmp(cmd, "detach", len)) { 47 47 if (rproc->state != RPROC_ATTACHED) 48 48 return -EINVAL;
+6 -3
drivers/remoteproc/remoteproc_core.c
··· 2061 2061 * which means that the @rproc handle stays valid even after rproc_shutdown() 2062 2062 * returns, and users can still use it with a subsequent rproc_boot(), if 2063 2063 * needed. 2064 + * 2065 + * Return: 0 on success, and an appropriate error value otherwise 2064 2066 */ 2065 - void rproc_shutdown(struct rproc *rproc) 2067 + int rproc_shutdown(struct rproc *rproc) 2066 2068 { 2067 2069 struct device *dev = &rproc->dev; 2068 - int ret; 2070 + int ret = 0; 2069 2071 2070 2072 ret = mutex_lock_interruptible(&rproc->lock); 2071 2073 if (ret) { 2072 2074 dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); 2073 - return; 2075 + return ret; 2074 2076 } 2075 2077 2076 2078 /* if the remote proc is still needed, bail out */ ··· 2099 2097 rproc->table_ptr = NULL; 2100 2098 out: 2101 2099 mutex_unlock(&rproc->lock); 2100 + return ret; 2102 2101 } 2103 2102 EXPORT_SYMBOL(rproc_shutdown); 2104 2103
+1 -1
drivers/remoteproc/remoteproc_sysfs.c
··· 206 206 rproc->state != RPROC_ATTACHED) 207 207 return -EINVAL; 208 208 209 - rproc_shutdown(rproc); 209 + ret = rproc_shutdown(rproc); 210 210 } else if (sysfs_streq(buf, "detach")) { 211 211 if (rproc->state != RPROC_ATTACHED) 212 212 return -EINVAL;
+1 -1
include/linux/remoteproc.h
··· 671 671 u32 da, const char *name, ...); 672 672 673 673 int rproc_boot(struct rproc *rproc); 674 - void rproc_shutdown(struct rproc *rproc); 674 + int rproc_shutdown(struct rproc *rproc); 675 675 int rproc_detach(struct rproc *rproc); 676 676 int rproc_set_firmware(struct rproc *rproc, const char *fw_name); 677 677 void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);