mfd: sm501: Avoid implicit sign extension
authorLee Jones <lee.jones@linaro.org>
Mon, 18 Aug 2014 15:11:27 +0000 (16:11 +0100)
committerLee Jones <lee.jones@linaro.org>
Fri, 26 Sep 2014 07:15:34 +0000 (08:15 +0100)
Suspicious implicit sign extension where 'reg' (unsigned char) is
promoted in reg << clksrc to int, then sign-extended to unsigned
long. If reg << clksrc is greater than 0x7FFFFFFF, the upper bits
of the result will all be 1.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/sm501.c

index 81e6d0932bf0afa096e84387cb241c4f6e57785e..1f9233bf4c3e390029a555b2302a71375371715e 100644 (file)
@@ -514,9 +514,9 @@ unsigned long sm501_set_clock(struct device *dev,
        unsigned long mode = smc501_readl(sm->regs + SM501_POWER_MODE_CONTROL);
        unsigned long gate = smc501_readl(sm->regs + SM501_CURRENT_GATE);
        unsigned long clock = smc501_readl(sm->regs + SM501_CURRENT_CLOCK);
-       unsigned char reg;
        unsigned int pll_reg = 0;
        unsigned long sm501_freq; /* the actual frequency achieved */
+       u64 reg;
 
        struct sm501_clock to;