Skip to content

Commit c13b780

Browse files
sumanannaandersson
authored andcommitted
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
1 parent 8d9be5c commit c13b780

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

Documentation/staging/remoteproc.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ might also consider using dev_archdata for this).
4949

5050
::
5151

52-
void rproc_shutdown(struct rproc *rproc)
52+
int rproc_shutdown(struct rproc *rproc)
5353

5454
Power off a remote processor (previously booted with rproc_boot()).
5555
In case @rproc is still being used by an additional user(s), then
5656
this function will just decrement the power refcount and exit,
5757
without really powering off the device.
5858

59+
Returns 0 on success, and an appropriate error value otherwise.
5960
Every call to rproc_boot() must (eventually) be accompanied by a call
6061
to rproc_shutdown(). Calling rproc_shutdown() redundantly is a bug.
6162

drivers/remoteproc/remoteproc_cdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_
4242
rproc->state != RPROC_ATTACHED)
4343
return -EINVAL;
4444

45-
rproc_shutdown(rproc);
45+
ret = rproc_shutdown(rproc);
4646
} else if (!strncmp(cmd, "detach", len)) {
4747
if (rproc->state != RPROC_ATTACHED)
4848
return -EINVAL;

drivers/remoteproc/remoteproc_core.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,16 +2061,18 @@ EXPORT_SYMBOL(rproc_boot);
20612061
* which means that the @rproc handle stays valid even after rproc_shutdown()
20622062
* returns, and users can still use it with a subsequent rproc_boot(), if
20632063
* needed.
2064+
*
2065+
* Return: 0 on success, and an appropriate error value otherwise
20642066
*/
2065-
void rproc_shutdown(struct rproc *rproc)
2067+
int rproc_shutdown(struct rproc *rproc)
20662068
{
20672069
struct device *dev = &rproc->dev;
2068-
int ret;
2070+
int ret = 0;
20692071

20702072
ret = mutex_lock_interruptible(&rproc->lock);
20712073
if (ret) {
20722074
dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
2073-
return;
2075+
return ret;
20742076
}
20752077

20762078
/* if the remote proc is still needed, bail out */
@@ -2097,6 +2099,7 @@ void rproc_shutdown(struct rproc *rproc)
20972099
rproc->table_ptr = NULL;
20982100
out:
20992101
mutex_unlock(&rproc->lock);
2102+
return ret;
21002103
}
21012104
EXPORT_SYMBOL(rproc_shutdown);
21022105

drivers/remoteproc/remoteproc_sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static ssize_t state_store(struct device *dev,
206206
rproc->state != RPROC_ATTACHED)
207207
return -EINVAL;
208208

209-
rproc_shutdown(rproc);
209+
ret = rproc_shutdown(rproc);
210210
} else if (sysfs_streq(buf, "detach")) {
211211
if (rproc->state != RPROC_ATTACHED)
212212
return -EINVAL;

include/linux/remoteproc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len,
671671
u32 da, const char *name, ...);
672672

673673
int rproc_boot(struct rproc *rproc);
674-
void rproc_shutdown(struct rproc *rproc);
674+
int rproc_shutdown(struct rproc *rproc);
675675
int rproc_detach(struct rproc *rproc);
676676
int rproc_set_firmware(struct rproc *rproc, const char *fw_name);
677677
void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);

0 commit comments

Comments
 (0)