Skip to contentSkip to conversation

coda: Check the return value from clk_prepare_enable()

PATCH Superseded Fabio Estevam 2 participants 3 messages Jul 20, 2013 – Jul 22, 2013 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 coda: Check the return value from clk_prepare_enable()

From: Fabio Estevam <[email protected]>

clk_prepare_enable() may fail, so let's check its return value and propagate it in the case of error.

---
 drivers/media/platform/coda.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/media/platform/coda.c +8 -2
index df4ada88..dd76228 100644
@@ -1559,14 +1559,20 @@ static int coda_open(struct file *file)
 	list_add(&ctx->list, &dev->instances);
 	coda_unlock(ctx);
 
-	clk_prepare_enable(dev->clk_per);
-	clk_prepare_enable(dev->clk_ahb);
+	ret = clk_prepare_enable(dev->clk_per);
+	if (ret)
+		goto err;
+
+	ret = clk_prepare_enable(dev->clk_ahb);
+		goto err_clk_ahb;
 
 	v4l2_dbg(1, coda_debug, &dev->v4l2_dev, "Created instance %d (%p)\n",
 		 ctx->idx, ctx);
 
 	return 0;
 
+err_clk_ahb:
+	clk_disable_unprepare(dev->clk_per);
 err:
 	v4l2_fh_del(&ctx->fh);
 	v4l2_fh_exit(&ctx->fh);
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 coda: No need to check the return value of platform_get_resource()

From: Fabio Estevam <[email protected]>

When using devm_ioremap_resource(), we do not need to check the return value of platform_get_resource(), so just remove it.

---
 drivers/media/platform/coda.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/media/platform/coda.c +0 -5
index dd76228..236385f 100644
@@ -2038,11 +2038,6 @@ static int coda_probe(struct platform_device *pdev)
 
 	/* Get  memory for physical registers */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "failed to get memory region resource\n");
-		return -ENOENT;
-	}
-
 	dev->regs_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(dev->regs_base))
 		return PTR_ERR(dev->regs_base);
Signature · 1 line
1.8.1.2
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] [media] coda: No need to check the return value of platform_get_resource()

Am Samstag, den 20.07.2013, 15:48 -0300 schrieb Fabio Estevam:

Quoted 16 lines

From: Fabio Estevam <[email protected]>

When using devm_ioremap_resource(), we do not need to check the return value of platform_get_resource(), so just remove it.

---
 drivers/media/platform/coda.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/media/platform/coda.c +0 -0
index dd76228..236385f 100644
@@ -2038,11 +2038,6 @@ static int coda_probe(struct platform_device *pdev)
 

drivers/media/platform/coda.c static int coda_probe(struct platform_device *pdev) · line 2043

Quoted 10 lines
drivers/media/platform/coda.c +0 -5
 	/* Get  memory for physical registers */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res == NULL) {
-		dev_err(&pdev->dev, "failed to get memory region resource\n");
-		return -ENOENT;
-	}
-
 	dev->regs_base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(dev->regs_base))
 		return PTR_ERR(dev->regs_base);

regards
Philipp