]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
clk: sunxi: factors: fix off-by-one masks
authorEmilio López <emilio@elopez.com.ar>
Sat, 21 Sep 2013 01:03:10 +0000 (22:03 -0300)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Sun, 10 Nov 2013 10:39:46 +0000 (11:39 +0100)
The previous code would generate one bit too long masks, and was
needlessly complicated. This patch replaces it by simpler code that can
generate the masks correctly.

Signed-off-by: Emilio López <emilio@elopez.com.ar>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
drivers/clk/sunxi/clk-factors.c

index 88523f91d9b703cc57b1272421fed39430b6f7a6..5687ac9bd85a8ffb087fbd022292a856828ac497 100644 (file)
@@ -40,7 +40,7 @@ struct clk_factors {
 
 #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
 
-#define SETMASK(len, pos)              (((-1U) >> (31-len))  << (pos))
+#define SETMASK(len, pos)              (((1U << (len)) - 1) << (pos))
 #define CLRMASK(len, pos)              (~(SETMASK(len, pos)))
 #define FACTOR_GET(bit, len, reg)      (((reg) & SETMASK(len, bit)) >> (bit))