On Wed, Nov 19, 2025 at 12:21:57PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <[email protected]>
>
> Replace goto-based error handling with early return pattern in
> imx_dsp_rproc_{start,stop}() functions, and simplify if-else logic.
>
> No functional changes, only code structure improvements for better
> maintainability.
>
> Signed-off-by: Peng Fan <[email protected]>

Reviewed-by: Frank Li <[email protected]>

> ---
>  drivers/remoteproc/imx_dsp_rproc.c | 39 
> ++++++++++++++++++--------------------
>  1 file changed, 18 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c 
> b/drivers/remoteproc/imx_dsp_rproc.c
> index 
> 6237e8db2eff759c2b7fcce5fb4a44e4ebaec8cf..1a1438823e7fc0a65ba15142abdd97e59692801c
>  100644
> --- a/drivers/remoteproc/imx_dsp_rproc.c
> +++ b/drivers/remoteproc/imx_dsp_rproc.c
> @@ -376,20 +376,19 @@ static int imx_dsp_rproc_start(struct rproc *rproc)
>       struct device *dev = rproc->dev.parent;
>       int ret;
>
> -     if (dcfg->ops && dcfg->ops->start) {
> -             ret = dcfg->ops->start(rproc);
> -             goto start_ret;
> -     }
> -
> -     return -EOPNOTSUPP;
> +     if (!dcfg->ops || !dcfg->ops->start)
> +             return -EOPNOTSUPP;
>
> -start_ret:
> -     if (ret)
> +     ret = dcfg->ops->start(rproc);
> +     if (ret) {
>               dev_err(dev, "Failed to enable remote core!\n");
> -     else if (priv->flags & WAIT_FW_READY)
> +             return ret;
> +     }
> +
> +     if (priv->flags & WAIT_FW_READY)
>               return imx_dsp_rproc_ready(rproc);
>
> -     return ret;
> +     return 0;
>  }
>
>  static int imx_dsp_rproc_mmio_stop(struct rproc *rproc)
> @@ -431,20 +430,18 @@ static int imx_dsp_rproc_stop(struct rproc *rproc)
>               return 0;
>       }
>
> -     if (dcfg->ops && dcfg->ops->stop) {
> -             ret = dcfg->ops->stop(rproc);
> -             goto stop_ret;
> -     }
> -
> -     return -EOPNOTSUPP;
> +     if (!dcfg->ops || !dcfg->ops->stop)
> +             return -EOPNOTSUPP;
>
> -stop_ret:
> -     if (ret)
> +     ret = dcfg->ops->stop(rproc);
> +     if (ret) {
>               dev_err(dev, "Failed to stop remote core\n");
> -     else
> -             priv->flags &= ~REMOTE_IS_READY;
> +             return ret;
> +     }
>
> -     return ret;
> +     priv->flags &= ~REMOTE_IS_READY;
> +
> +     return 0;
>  }
>
>  /**
>
> --
> 2.37.1
>

Reply via email to