Commit 8bf9be56 authored by Roger Quadros's avatar Roger Quadros

ARM: OMAP2+: gpmc: Sanity check GPMC fck on probe

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: default avatarRoger Quadros <rogerq@ti.com>
Signed-off-by: default avatarSekhar Nori <nsekhar@ti.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
parent 4cf27d2e
...@@ -204,11 +204,6 @@ static unsigned long gpmc_get_fclk_period(void) ...@@ -204,11 +204,6 @@ static unsigned long gpmc_get_fclk_period(void)
{ {
unsigned long rate = clk_get_rate(gpmc_l3_clk); 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 /= 1000;
rate = 1000000000 / rate; /* In picoseconds */ rate = 1000000000 / rate; /* In picoseconds */
...@@ -1692,13 +1687,18 @@ static int gpmc_probe(struct platform_device *pdev) ...@@ -1692,13 +1687,18 @@ static int gpmc_probe(struct platform_device *pdev)
else else
gpmc_irq = res->start; 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)) { 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; gpmc_irq = 0;
return PTR_ERR(gpmc_l3_clk); 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_enable(&pdev->dev);
pm_runtime_get_sync(&pdev->dev); pm_runtime_get_sync(&pdev->dev);
...@@ -1741,7 +1741,6 @@ static int gpmc_probe(struct platform_device *pdev) ...@@ -1741,7 +1741,6 @@ static int gpmc_probe(struct platform_device *pdev)
rc = gpmc_probe_dt(pdev); rc = gpmc_probe_dt(pdev);
if (rc < 0) { if (rc < 0) {
pm_runtime_put_sync(&pdev->dev); pm_runtime_put_sync(&pdev->dev);
clk_put(gpmc_l3_clk);
dev_err(gpmc_dev, "failed to probe DT parameters\n"); dev_err(gpmc_dev, "failed to probe DT parameters\n");
return rc; return rc;
} }
......
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