This prevents potential division by zero errors
if GPMC fck turns out to be zero due to faulty clock
data.

Use resource managed clk_get() API.

Signed-off-by: Roger Quadros <[email protected]>
Signed-off-by: Sekhar Nori <[email protected]>
---
 arch/arm/mach-omap2/gpmc.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
index 437fb6f..104bc2c 100644
--- a/arch/arm/mach-omap2/gpmc.c
+++ b/arch/arm/mach-omap2/gpmc.c
@@ -204,11 +204,6 @@ static unsigned long gpmc_get_fclk_period(void)
 {
        unsigned long rate = clk_get_rate(gpmc_l3_clk);
 
-       if (rate == 0) {
-               printk(KERN_WARNING "gpmc_l3_clk not enabled\n");
-               return 0;
-       }
-
        rate /= 1000;
        rate = 1000000000 / rate;       /* In picoseconds */
 
@@ -1692,13 +1687,18 @@ static int gpmc_probe(struct platform_device *pdev)
        else
                gpmc_irq = res->start;
 
-       gpmc_l3_clk = clk_get(&pdev->dev, "fck");
+       gpmc_l3_clk = devm_clk_get(&pdev->dev, "fck");
        if (IS_ERR(gpmc_l3_clk)) {
-               dev_err(&pdev->dev, "error: clk_get\n");
+               dev_err(&pdev->dev, "Failed to get GPMC fck\n");
                gpmc_irq = 0;
                return PTR_ERR(gpmc_l3_clk);
        }
 
+       if (!clk_get_rate(gpmc_l3_clk)) {
+               dev_err(&pdev->dev, "Invalid GPMC fck clock rate\n");
+               return -EINVAL;
+       }
+
        pm_runtime_enable(&pdev->dev);
        pm_runtime_get_sync(&pdev->dev);
 
@@ -1741,7 +1741,6 @@ static int gpmc_probe(struct platform_device *pdev)
        rc = gpmc_probe_dt(pdev);
        if (rc < 0) {
                pm_runtime_put_sync(&pdev->dev);
-               clk_put(gpmc_l3_clk);
                dev_err(gpmc_dev, "failed to probe DT parameters\n");
                return rc;
        }
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to