4dba06437580be3f3ddfa1b84ebd2ebcb8135139
[openwrt.git] / target / linux / sunxi / patches-3.12 / 100-2-fix-off-by-one-masks.patch
1 From 04609953e11377c0705b0aba5c25ebdcbb9e4aa7 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <emilio@elopez.com.ar>
3 Date: Thu, 5 Sep 2013 19:47:20 -0300
4 Subject: [PATCH] clk: sunxi: factors: fix off-by-one masks
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 The previous code would generate one bit too long masks, and was
10 needlessly complicated. This patch replaces it by simpler code that can
11 generate the masks correctly.
12
13 Signed-off-by: Emilio López <emilio@elopez.com.ar>
14 ---
15  drivers/clk/sunxi/clk-factors.c | 2 +-
16  1 file changed, 1 insertion(+), 1 deletion(-)
17
18 diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
19 index 88523f9..5687ac9 100644
20 --- a/drivers/clk/sunxi/clk-factors.c
21 +++ b/drivers/clk/sunxi/clk-factors.c
22 @@ -40,7 +40,7 @@ struct clk_factors {
23  
24  #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
25  
26 -#define SETMASK(len, pos)              (((-1U) >> (31-len))  << (pos))
27 +#define SETMASK(len, pos)              (((1U << (len)) - 1) << (pos))
28  #define CLRMASK(len, pos)              (~(SETMASK(len, pos)))
29  #define FACTOR_GET(bit, len, reg)      (((reg) & SETMASK(len, bit)) >> (bit))
30  
31 -- 
32 1.8.5.1
33