]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
MIPS: TXx9: Fix possible overflow in clock calculations
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>
Thu, 2 Apr 2009 16:01:21 +0000 (01:01 +0900)
committerRalf Baechle <ralf@linux-mips.org>
Thu, 14 May 2009 12:50:27 +0000 (13:50 +0100)
Addition of -fwrapv option in 2.6.29 discloses possible overflow with
signed arithmetics.  For example, result of "a * 6 / 12" (int a =
400000000) is 200000000 without -fwrapv but -157913941 with -fwrapv.

Change some variable to unsigned to avoid such overflows.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/txx9/generic/setup_tx4927.c
arch/mips/txx9/generic/setup_tx4938.c
arch/mips/txx9/generic/setup_tx4939.c

index 914e93c62639616690fda1c5cfd02d3b254ae877..1093549df1a8f07a78d80ac58842402a432791a1 100644 (file)
@@ -88,7 +88,7 @@ void __init tx4927_setup(void)
 {
        int i;
        __u32 divmode;
-       int cpuclk = 0;
+       unsigned int cpuclk = 0;
        u64 ccfg;
 
        txx9_reg_res_init(TX4927_REV_PCODE(), TX4927_REG_BASE,
index f0844f891f0bf11ca2ea9869f96ba590417eff71..3925219b89730f266bce5f3a151e18952d6a0772 100644 (file)
@@ -93,7 +93,7 @@ void __init tx4938_setup(void)
 {
        int i;
        __u32 divmode;
-       int cpuclk = 0;
+       unsigned int cpuclk = 0;
        u64 ccfg;
 
        txx9_reg_res_init(TX4938_REV_PCODE(), TX4938_REG_BASE,
index 7a25b573e9b07ff45bde162e5e7326e8d0ee528c..c2bf150c883898a1c126d8c8c37be404c87ff2fb 100644 (file)
@@ -114,7 +114,7 @@ void __init tx4939_setup(void)
        int i;
        __u32 divmode;
        __u64 pcfg;
-       int cpuclk = 0;
+       unsigned int cpuclk = 0;
 
        txx9_reg_res_init(TX4939_REV_PCODE(), TX4939_REG_BASE,
                          TX4939_REG_SIZE);