diff options
author | Roger Quadros <rogerq@ti.com> | 2014-09-01 08:18:56 -0400 |
---|---|---|
committer | Roger Quadros <rogerq@ti.com> | 2014-10-30 11:21:55 -0400 |
commit | 8bf9be566ed5790003402eb1060184956788b410 (patch) | |
tree | 894db40e327dfb0b8026ca673920f403bd686958 /arch/arm | |
parent | 4cf27d2ec716fddacd02169af9a26a43ea52875e (diff) |
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')
-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) | |||
204 | { | 204 | { |
205 | unsigned long rate = clk_get_rate(gpmc_l3_clk); | 205 | unsigned long rate = clk_get_rate(gpmc_l3_clk); |
206 | 206 | ||
207 | if (rate == 0) { | ||
208 | printk(KERN_WARNING "gpmc_l3_clk not enabled\n"); | ||
209 | return 0; | ||
210 | } | ||
211 | |||
212 | rate /= 1000; | 207 | rate /= 1000; |
213 | rate = 1000000000 / rate; /* In picoseconds */ | 208 | rate = 1000000000 / rate; /* In picoseconds */ |
214 | 209 | ||
@@ -1692,13 +1687,18 @@ static int gpmc_probe(struct platform_device *pdev) | |||
1692 | else | 1687 | else |
1693 | gpmc_irq = res->start; | 1688 | gpmc_irq = res->start; |
1694 | 1689 | ||
1695 | gpmc_l3_clk = clk_get(&pdev->dev, "fck"); | 1690 | gpmc_l3_clk = devm_clk_get(&pdev->dev, "fck"); |
1696 | if (IS_ERR(gpmc_l3_clk)) { | 1691 | if (IS_ERR(gpmc_l3_clk)) { |
1697 | dev_err(&pdev->dev, "error: clk_get\n"); | 1692 | dev_err(&pdev->dev, "Failed to get GPMC fck\n"); |
1698 | gpmc_irq = 0; | 1693 | gpmc_irq = 0; |
1699 | return PTR_ERR(gpmc_l3_clk); | 1694 | return PTR_ERR(gpmc_l3_clk); |
1700 | } | 1695 | } |
1701 | 1696 | ||
1697 | if (!clk_get_rate(gpmc_l3_clk)) { | ||
1698 | dev_err(&pdev->dev, "Invalid GPMC fck clock rate\n"); | ||
1699 | return -EINVAL; | ||
1700 | } | ||
1701 | |||
1702 | pm_runtime_enable(&pdev->dev); | 1702 | pm_runtime_enable(&pdev->dev); |
1703 | pm_runtime_get_sync(&pdev->dev); | 1703 | pm_runtime_get_sync(&pdev->dev); |
1704 | 1704 | ||
@@ -1741,7 +1741,6 @@ static int gpmc_probe(struct platform_device *pdev) | |||
1741 | rc = gpmc_probe_dt(pdev); | 1741 | rc = gpmc_probe_dt(pdev); |
1742 | if (rc < 0) { | 1742 | if (rc < 0) { |
1743 | pm_runtime_put_sync(&pdev->dev); | 1743 | pm_runtime_put_sync(&pdev->dev); |
1744 | clk_put(gpmc_l3_clk); | ||
1745 | dev_err(gpmc_dev, "failed to probe DT parameters\n"); | 1744 | dev_err(gpmc_dev, "failed to probe DT parameters\n"); |
1746 | return rc; | 1745 | return rc; |
1747 | } | 1746 | } |