]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
possible div by 0 in
authorRoel Kluin <12o3l@tiscali.nl>
Fri, 18 Jan 2008 22:24:01 +0000 (14:24 -0800)
committerTony Lindgren <tony@atomide.com>
Fri, 18 Jan 2008 22:24:01 +0000 (14:24 -0800)
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 <tony@atomide.com>
arch/arm/mach-omap2/gpmc.c

index da7409e2e7329d2526af115a31aa1fed0462cad3..a992b167a241d735b9f5d2a4596375f29d351270 100644 (file)
@@ -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)