remoteproc: Change rproc_shutdown() to return a status
authorSuman Anna <s-anna@ti.com>
Sun, 13 Feb 2022 20:12:42 +0000 (14:12 -0600)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Fri, 11 Mar 2022 20:31:55 +0000 (14:31 -0600)
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
Documentation/staging/remoteproc.rst
drivers/remoteproc/remoteproc_cdev.c
drivers/remoteproc/remoteproc_core.c
drivers/remoteproc/remoteproc_sysfs.c
include/linux/remoteproc.h

index 9cccd3dd6a4b40a3d00b6abbe884fce65e6de530..348ee7e508acae5aa8e47934c1b4061a53576f9d 100644 (file)
@@ -49,13 +49,14 @@ might also consider using dev_archdata for this).
 
 ::
 
-  void rproc_shutdown(struct rproc *rproc)
+  int rproc_shutdown(struct rproc *rproc)
 
 Power off a remote processor (previously booted with rproc_boot()).
 In case @rproc is still being used by an additional user(s), then
 this function will just decrement the power refcount and exit,
 without really powering off the device.
 
+Returns 0 on success, and an appropriate error value otherwise.
 Every call to rproc_boot() must (eventually) be accompanied by a call
 to rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug.
 
index 4ad98b0b8caa5f3ee5e3b3a1b00afd05bbedcd73..906ff3c4dfddd712770781d551f83cc781488fee 100644 (file)
@@ -42,7 +42,7 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
                    rproc->state != RPROC_ATTACHED)
                        return -EINVAL;
 
-               rproc_shutdown(rproc);
+               ret = rproc_shutdown(rproc);
        } else if (!strncmp(cmd, "detach", len)) {
                if (rproc->state != RPROC_ATTACHED)
                        return -EINVAL;
index 69f51acf235eaf1b507aef9d355efc978e4584ca..c510125769b91e89fa557a7c55c1399e95470363 100644 (file)
@@ -2061,16 +2061,18 @@ EXPORT_SYMBOL(rproc_boot);
  *   which means that the @rproc handle stays valid even after rproc_shutdown()
  *   returns, and users can still use it with a subsequent rproc_boot(), if
  *   needed.
+ *
+ * Return: 0 on success, and an appropriate error value otherwise
  */
-void rproc_shutdown(struct rproc *rproc)
+int rproc_shutdown(struct rproc *rproc)
 {
        struct device *dev = &rproc->dev;
-       int ret;
+       int ret = 0;
 
        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 the remote proc is still needed, bail out */
@@ -2097,6 +2099,7 @@ void rproc_shutdown(struct rproc *rproc)
        rproc->table_ptr = NULL;
 out:
        mutex_unlock(&rproc->lock);
+       return ret;
 }
 EXPORT_SYMBOL(rproc_shutdown);
 
index abf0cd05d5e185235866555ff99e496826b2cbf1..51a04bc6ba7a056d3d55bcde07726b56a22866c5 100644 (file)
@@ -206,7 +206,7 @@ static ssize_t state_store(struct device *dev,
                    rproc->state != RPROC_ATTACHED)
                        return -EINVAL;
 
-               rproc_shutdown(rproc);
+               ret = rproc_shutdown(rproc);
        } else if (sysfs_streq(buf, "detach")) {
                if (rproc->state != RPROC_ATTACHED)
                        return -EINVAL;
index b2ee325e0af191ead808b468d3352e8913664b9b..7c943f0a2fc40ade313616a0230408e8954ada22 100644 (file)
@@ -671,7 +671,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);
 int rproc_set_firmware(struct rproc *rproc, const char *fw_name);
 void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);