From ce3d08691cb4d0d1751ac00a4a072cdac38c79c5 Mon Sep 17 00:00:00 2001 From: Roel Kluin <12o3l@tiscali.nl> Date: Fri, 18 Jan 2008 14:24:01 -0800 Subject: [PATCH] possible div by 0 in clk_get_rate may return 0, prevent division by 0 and unobfuscate Signed-off-by: Roel Kluin <12o3l@tiscali.nl> Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/gpmc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index da7409e2e73..a992b167a24 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -94,8 +94,17 @@ u32 gpmc_cs_read_reg(int cs, int idx) /* TODO: Add support for gpmc_fck to clock framework and use it */ unsigned long gpmc_get_fclk_period(void) { - /* In picoseconds */ - return 1000000000 / ((clk_get_rate(gpmc_l3_clk)) / 1000); + unsigned long rate = clk_get_rate(gpmc_l3_clk); + + if (rate == 0) { + printk(KERN_WARNING "gpmc_l3_clk no enabled\n"); + return 0; + } + + rate /= 1000; + rate = 1000000000 / rate; /* In picoseconds */ + + return rate; } unsigned int gpmc_ns_to_ticks(unsigned int time_ns) -- 2.41.1