remoteproc: imx_rproc: Improve 'imx_rproc_probe()'
cover remoteproc: imx_rproc: Improve 'imx_rproc_probe()'
Patch 1 fixes a bug.
Patches 2 and 3 are just clean-ups.
Christophe JAILLET (3):
remoteproc: imx_rproc: Fix an error handling path in
'imx_rproc_probe()'
remoteproc: imx_rproc: Re-use existing error handling path in
'imx_rproc_probe()' remoteproc: imx_rproc: Slightly simplify code in 'imx_rproc_probe()'
drivers/remoteproc/imx_rproc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/3 remoteproc: imx_rproc: Fix an error handling path in 'imx_rproc_probe()'
If 'of_device_get_match_data()' fails, we must undo the previous 'rproc_alloc()' call.
--- drivers/remoteproc/imx_rproc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +4 -2
@@ -339,8 +339,10 @@ static int imx_rproc_probe(struct platform_device *pdev) } dcfg =of_device_get_match_data (dev); -if (!dcfg) -return -EINVAL ; +if (!dcfg) { + ret = -EINVAL ; + goto err_put_rproc; + } priv = rproc->priv; priv->rproc = rproc;
Signature · 1 line
2.14.1
PATCH 2/3 remoteproc: imx_rproc: Re-use existing error handling path in 'imx_rproc_probe()'
In reply to Christophe JAILLETAvoid some code ducplication and be more future-proof.
--- drivers/remoteproc/imx_rproc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/remoteproc/imx_rproc.c +3 -4
@@ -361,8 +361,8 @@ static int imx_rproc_probe(struct platform_device *pdev) priv->clk =devm_clk_get (dev,NULL );if (IS_ERR (priv->clk)) {dev_err (dev,"Failed to get clock\n" ); -rproc_free (rproc); -return PTR_ERR (priv->clk); + ret =PTR_ERR (priv->clk); + goto err_put_rproc; }/*
@@ -372,8 +372,7 @@ static int imx_rproc_probe(struct platform_device *pdev) ret =clk_prepare_enable (priv->clk);if (ret) {dev_err (&rproc->dev,"Failed to enable clock\n" ); -rproc_free (rproc); -return ret; + goto err_put_rproc; } ret =rproc_add (rproc);
Signature · 1 line
2.14.1
PATCH 3/3 remoteproc: imx_rproc: Slightly simplify code in 'imx_rproc_probe()'
In reply to Christophe JAILLETWe can return directly at the beginning of the function and save the 'err' label.
We can also explicitly return 0 when the probe succeed.
--- drivers/remoteproc/imx_rproc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/remoteproc/imx_rproc.c +4 -6
@@ -333,10 +333,8 @@ static int imx_rproc_probe(struct platform_device *pdev)/* set some other name then imx */ rproc =rproc_alloc (dev,"imx-rproc" , &imx_rproc_ops,NULL ,sizeof (*priv)); -if (!rproc) { - ret = -ENOMEM ; - goto err; - } +if (!rproc) +return -ENOMEM ; dcfg =of_device_get_match_data (dev);if (!dcfg) {
@@ -381,13 +379,13 @@ static int imx_rproc_probe(struct platform_device *pdev) goto err_put_clk; } -return ret; +return 0 ; err_put_clk:clk_disable_unprepare (priv->clk); err_put_rproc:rproc_free (rproc); -err: +return ret; }
Signature · 1 line
2.14.1
Quoted 3 lines · Christophe JAILLET
Patch 1 fixes a bug.
Patches 2 and 3 are just clean-ups.
All three patches applied.
Thanks,
Bjorn
Quoted 13 lines
Christophe JAILLET (3):
remoteproc:imx_rproc: Fix an error handling path in'imx_rproc_probe()' remoteproc: imx_rproc: Re-use existing error handling path in 'imx_rproc_probe()'remoteproc:
imx_rproc: Slightly simplify code in 'imx_rproc_probe()'drivers/remoteproc/imx_rproc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)Signature · 1 line
2.14.1