Skip to content

Commit

Permalink
clk: sunxi: factors: fix off-by-one masks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Emilio López authored and Maxime Ripard committed Nov 10, 2013
1 parent 107f319 commit c518e84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/clk/sunxi/clk-factors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit c518e84

Please sign in to comment.