f6d7a13d610d6a5f831b0a0662b899758de2b56b
[openwrt/openwrt.git] / target / linux / sunxi / patches-3.13 / 101-fix-off-by-one-masks.patch
1 From b3cb099f8b0cbe56fcfbb4fb9c7cce48afff41f0 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= <emilio@elopez.com.ar>
3 Date: Fri, 20 Sep 2013 22:03:10 -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 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
15 ---
16 drivers/clk/sunxi/clk-factors.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19 --- a/drivers/clk/sunxi/clk-factors.c
20 +++ b/drivers/clk/sunxi/clk-factors.c
21 @@ -40,7 +40,7 @@ struct clk_factors {
22
23 #define to_clk_factors(_hw) container_of(_hw, struct clk_factors, hw)
24
25 -#define SETMASK(len, pos) (((-1U) >> (31-len)) << (pos))
26 +#define SETMASK(len, pos) (((1U << (len)) - 1) << (pos))
27 #define CLRMASK(len, pos) (~(SETMASK(len, pos)))
28 #define FACTOR_GET(bit, len, reg) (((reg) & SETMASK(len, bit)) >> (bit))
29