Skip to content

Commit

Permalink
remoteproc: Do not update the rproc state if rproc->ops fails
Browse files Browse the repository at this point in the history
* When rproc->ops fails, the state of rproc should not be updated.

Signed-off-by: Zongcheng Han <[email protected]>
  • Loading branch information
mengtanhzc authored and arnopo committed Jul 8, 2024
1 parent b5aaf51 commit c468328
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/remoteproc/remoteproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ int remoteproc_config(struct remoteproc *rproc, void *data)
ret = rproc->ops->config(rproc, data);
else
ret = 0;
rproc->state = RPROC_READY;

if (!ret)
rproc->state = RPROC_READY;
} else {
ret = -RPROC_EINVAL;
}
Expand All @@ -238,8 +240,10 @@ int remoteproc_start(struct remoteproc *rproc)
if (rproc) {
metal_mutex_acquire(&rproc->lock);
if (rproc->state == RPROC_READY) {
ret = rproc->ops->start(rproc);
rproc->state = RPROC_RUNNING;
if (rproc->ops->start)
ret = rproc->ops->start(rproc);
if (!ret)
rproc->state = RPROC_RUNNING;
} else {
ret = -RPROC_EINVAL;
}
Expand All @@ -258,8 +262,10 @@ int remoteproc_stop(struct remoteproc *rproc)
rproc->state != RPROC_OFFLINE) {
if (rproc->ops->stop)
ret = rproc->ops->stop(rproc);
rproc->state = RPROC_STOPPED;
rproc->bitmap = 0;
if (!ret) {
rproc->state = RPROC_STOPPED;
rproc->bitmap = 0;
}
} else {
ret = 0;
}
Expand Down

0 comments on commit c468328

Please sign in to comment.