diff options
author | Roger Quadros <rogerq@ti.com> | 2014-09-01 14:18:56 +0200 |
---|---|---|
committer | Roger Quadros <rogerq@ti.com> | 2014-10-30 16:21:55 +0100 |
commit | 8bf9be566ed5790003402eb1060184956788b410 (patch) | |
tree | 894db40e327dfb0b8026ca673920f403bd686958 /arch/arm/mach-omap2/gpmc.c | |
parent | ARM: OMAP2+: gpmc: Keep Chip Select disabled while configuring it (diff) | |
download | linux-8bf9be566ed5790003402eb1060184956788b410.tar.xz linux-8bf9be566ed5790003402eb1060184956788b410.zip |
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: Roger Quadros <rogerq@ti.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/gpmc.c')
-rw-r--r-- | arch/arm/mach-omap2/gpmc.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 437fb6f6df52..104bc2c50987 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; } |