Skip to contentSkip to conversation

remoteproc: imx_rproc: Improve 'imx_rproc_probe()'

PATCH In review Christophe JAILLET 2 participants 5 messages Mar 14, 2018 – Mar 18, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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.

Fixes a0ff4aa6f010 ("remoteproc: imx_rproc: add a NXP/Freescale imx_rproc driver")
---
 drivers/remoteproc/imx_rproc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_rproc.c +4 -2
index 633268e9d550..05bcbce2013a 100644
@@ -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
#2 lore raw

PATCH 2/3 remoteproc: imx_rproc: Re-use existing error handling path in 'imx_rproc_probe()'

In reply to Christophe JAILLET

Avoid 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
index 05bcbce2013a..6d02ef62a626 100644
@@ -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
#3 lore raw

PATCH 3/3 remoteproc: imx_rproc: Slightly simplify code in 'imx_rproc_probe()'

In reply to Christophe JAILLET

We 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
index 6d02ef62a626..54c07fd3f204 100644
@@ -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
#4 lore raw
In reply to Christophe JAILLET
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