[PATCH] tegra-cec: fix messy probe() cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The probe() cleanup code ('goto foo_error') was very messy. It appears
that this code wasn't updated when I switched to the devm_ functions
in an earlier version.

Update the code to use 'return error' where it can and do proper cleanup
where it needs to.

Note that the original code wasn't buggy, it was just messy.

Signed-off-by: Hans Verkuil <hans.verkuil@xxxxxxxxx>
---
Since I already posted the pull request for this driver and since this is
just a cleanup I decided to do this as a separate patch on top of the pull
request code rather than merging this in the pull request.
---
 drivers/media/platform/tegra-cec/tegra_cec.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/tegra-cec/tegra_cec.c b/drivers/media/platform/tegra-cec/tegra_cec.c
index b53743f555e8..807c94c70049 100644
--- a/drivers/media/platform/tegra-cec/tegra_cec.c
+++ b/drivers/media/platform/tegra-cec/tegra_cec.c
@@ -356,40 +356,34 @@ static int tegra_cec_probe(struct platform_device *pdev)
 	if (!res) {
 		dev_err(&pdev->dev,
 			"Unable to allocate resources for device\n");
-		ret = -EBUSY;
-		goto cec_error;
+		return -EBUSY;
 	}

 	if (!devm_request_mem_region(&pdev->dev, res->start, resource_size(res),
 		pdev->name)) {
 		dev_err(&pdev->dev,
 			"Unable to request mem region for device\n");
-		ret = -EBUSY;
-		goto cec_error;
+		return -EBUSY;
 	}

 	cec->tegra_cec_irq = platform_get_irq(pdev, 0);

-	if (cec->tegra_cec_irq <= 0) {
-		ret = -EBUSY;
-		goto cec_error;
-	}
+	if (cec->tegra_cec_irq <= 0)
+		return -EBUSY;

 	cec->cec_base = devm_ioremap_nocache(&pdev->dev, res->start,
-		resource_size(res));
+					     resource_size(res));

 	if (!cec->cec_base) {
 		dev_err(&pdev->dev, "Unable to grab IOs for device\n");
-		ret = -EBUSY;
-		goto cec_error;
+		return -EBUSY;
 	}

 	cec->clk = devm_clk_get(&pdev->dev, "cec");

 	if (IS_ERR_OR_NULL(cec->clk)) {
 		dev_err(&pdev->dev, "Can't get clock for CEC\n");
-		ret = -ENOENT;
-		goto clk_error;
+		return -ENOENT;
 	}

 	clk_prepare_enable(cec->clk);
@@ -406,13 +400,13 @@ static int tegra_cec_probe(struct platform_device *pdev)
 	if (ret) {
 		dev_err(&pdev->dev,
 			"Unable to request interrupt for device\n");
-		goto cec_error;
+		goto clk_error;
 	}

 	cec->notifier = cec_notifier_get(&hdmi_dev->dev);
 	if (!cec->notifier) {
 		ret = -ENOMEM;
-		goto cec_error;
+		goto clk_error;
 	}

 	cec->adap = cec_allocate_adapter(&tegra_cec_ops, cec, TEGRA_CEC_NAME,
@@ -437,8 +431,8 @@ static int tegra_cec_probe(struct platform_device *pdev)
 	if (cec->notifier)
 		cec_notifier_put(cec->notifier);
 	cec_delete_adapter(cec->adap);
-	clk_disable_unprepare(cec->clk);
 clk_error:
+	clk_disable_unprepare(cec->clk);
 	return ret;
 }

-- 
2.14.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux