Skip to contentSkip to conversation

ASoC: mxs-saif: Use devm_clk_get()

PATCH In review Fabio Estevam 2 participants 4 messages Apr 26, 2012

Subsystems (3)
lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 ASoC: mxs-saif: Use devm_clk_get()

Using devm_clk_get() can make the error handling path easier.

---
 sound/soc/mxs/mxs-saif.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)
sound/soc/mxs/mxs-saif.c +7 -13
index 53f4fd8..bfc1f9e 100644
@@ -650,7 +650,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
 		saif->master_id = saif->id;
 	}
 
-	saif->clk = clk_get(&pdev->dev, NULL);
+	saif->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(saif->clk)) {
 		ret = PTR_ERR(saif->clk);
 		dev_err(&pdev->dev, "Cannot get the clock: %d\n",
@@ -663,16 +663,14 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	saif->base = devm_request_and_ioremap(&pdev->dev, iores);
 	if (!saif->base) {
 		dev_err(&pdev->dev, "ioremap failed\n");
-		ret = -ENODEV;
-		goto failed_get_resource;
+		return -ENODEV;
 	}
 
 	dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
 	if (!dmares) {
-		ret = -ENODEV;
 		dev_err(&pdev->dev, "failed to get dma resource: %d\n",
 			ret);
-		goto failed_get_resource;
+		return -ENODEV;
 	}
 	saif->dma_param.chan_num = dmares->start;
 
@@ -681,7 +679,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
 		ret = saif->irq;
 		dev_err(&pdev->dev, "failed to get irq resource: %d\n",
 			ret);
-		goto failed_get_resource;
+		return saif->irq;
 	}
 
 	saif->dev = &pdev->dev;
@@ -689,15 +687,14 @@ static int mxs_saif_probe(struct platform_device *pdev)
 			       "mxs-saif", saif);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to request irq\n");
-		goto failed_get_resource;
+		return ret;
 	}
 
 	saif->dma_param.chan_irq = platform_get_irq(pdev, 1);
 	if (saif->dma_param.chan_irq < 0) {
-		ret = saif->dma_param.chan_irq;
 		dev_err(&pdev->dev, "failed to get dma irq resource: %d\n",
 			ret);
-		goto failed_get_resource;
+		return saif->dma_param.chan_irq;
 	}
 
 	platform_set_drvdata(pdev, saif);
@@ -705,7 +702,7 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	ret = snd_soc_register_dai(&pdev->dev, &mxs_saif_dai);
 	if (ret) {
 		dev_err(&pdev->dev, "register DAI failed\n");
-		goto failed_get_resource;
+		return ret;
 	}
 
 	saif->soc_platform_pdev = platform_device_alloc(
@@ -728,8 +725,6 @@ failed_pdev_add:
 	platform_device_put(saif->soc_platform_pdev);
 failed_pdev_alloc:
 	snd_soc_unregister_dai(&pdev->dev);
-failed_get_resource:
-	clk_put(saif->clk);
 
 	return ret;
 }
@@ -740,7 +735,6 @@ static int __devexit mxs_saif_remove(struct platform_device *pdev)
 
 	platform_device_unregister(saif->soc_platform_pdev);
 	snd_soc_unregister_dai(&pdev->dev);
-	clk_put(saif->clk);
 
 	return 0;
 }
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Fabio Estevam

Using devm_clk_get() can make the error handling path easier.

This is fine but devm_clk_get() is only in Russell's tree so it'll need to wait for after the merge window - can you please resend then?

author reviewer
#2 lore raw
Quoted 2 lines · Mark Brown

This is fine but devm_clk_get() is only in Russell's tree so it'll need to wait for after the merge window - can you please resend then?

devm_clk_get() is in linux-next. Isn't this ok?

#3 lore raw
Quoted 6 lines · Fabio Estevam

On Thu, Apr 26, 2012 at 6:25 AM, Mark Brown

Quoted 2 lines

This is fine but devm_clk_get() is only in Russell's tree so it'll need to wait for after the merge window - can you please resend then?

devm_clk_get() is in linux-next. Isn't this ok?

No. If I apply it to for-3.5 then for-3.5 won't build. It needs to be merged into the branch where the patch gets applied.