Commit 3ddad1ae authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: tegra-cec: fix messy probe() cleanup

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: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 6981d6e5
......@@ -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));
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment