[<prev] [next>] [day] [month] [year] [list]
Message-Id: <7bfcac1de9426c3e512a61922bca4239f8b520b5.1496922334.git.arvind.yadav.cs@gmail.com>
Date: Thu, 8 Jun 2017 17:17:49 +0530
From: Arvind Yadav <arvind.yadav.cs@...il.com>
To: a.zummo@...ertech.it, alexandre.belloni@...e-electrons.com
Cc: rtc-linux@...glegroups.com, linux-kernel@...r.kernel.org
Subject: [PATCH] rtc: omap: Handle return value of clk_prepare_enable.
- clk_prepare_enable() can fail here and we must check its return value.
- Add missing clk_disable_unprepare(), if omap_rtc_probe is not successful.
Signed-off-by: Arvind Yadav <arvind.yadav.cs@...il.com>
---
drivers/rtc/rtc-omap.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 13f7cd1..83b876d 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -705,13 +705,19 @@ static int omap_rtc_probe(struct platform_device *pdev)
else
rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
- if (!IS_ERR(rtc->clk))
- clk_prepare_enable(rtc->clk);
+ if (IS_ERR(rtc->clk))
+ return PTR_ERR(rtc->clk);
+
+ ret = clk_prepare_enable(rtc->clk);
+ if (ret)
+ return ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
rtc->base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(rtc->base))
- return PTR_ERR(rtc->base);
+ if (IS_ERR(rtc->base)) {
+ ret = PTR_ERR(rtc->base);
+ goto err_clk;
+ }
platform_set_drvdata(pdev, rtc);
@@ -830,7 +836,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
rtc->pctldev = pinctrl_register(&rtc_pinctrl_desc, &pdev->dev, rtc);
if (IS_ERR(rtc->pctldev)) {
dev_err(&pdev->dev, "Couldn't register pinctrl driver\n");
- return PTR_ERR(rtc->pctldev);
+ ret = PTR_ERR(rtc->pctldev);
+ goto err;
}
return 0;
@@ -841,6 +848,8 @@ static int omap_rtc_probe(struct platform_device *pdev)
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
+err_clk:
+ clk_disable_unprepare(rtc->clk);
return ret;
}
--
1.9.1
Powered by blists - more mailing lists