diff options
author | James Hogan <james.hogan@imgtec.com> | 2013-01-15 11:28:05 +0100 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2013-01-18 18:44:02 +0100 |
commit | 1a3cd18475a98b9587a181b8d8ebc7f5cdedb4b0 (patch) | |
tree | db36a48d590afc10d2c2752ec2190ddb0dcaf560 /drivers/clk | |
parent | clk: prima2: enable dt-binding clkdev mapping (diff) | |
download | linux-1a3cd18475a98b9587a181b8d8ebc7f5cdedb4b0.tar.xz linux-1a3cd18475a98b9587a181b8d8ebc7f5cdedb4b0.zip |
clk-divider: fix macros
The macro is_power_of_two() in clk-divider.c was defined as !(i & ~i)
which is always true. Instead use is_power_of_2() from log2.h.
Also add brackets around the macro arguments in div_mask to avoid any
future operator precedence problems.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
[mturquette@linaro.org: use log2.h per Joe Perches; update changelog]
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk-divider.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c index a9204c69148d..68b402101170 100644 --- a/drivers/clk/clk-divider.c +++ b/drivers/clk/clk-divider.c @@ -16,6 +16,7 @@ #include <linux/io.h> #include <linux/err.h> #include <linux/string.h> +#include <linux/log2.h> /* * DOC: basic adjustable divider clock that cannot gate @@ -29,8 +30,7 @@ #define to_clk_divider(_hw) container_of(_hw, struct clk_divider, hw) -#define div_mask(d) ((1 << (d->width)) - 1) -#define is_power_of_two(i) !(i & ~i) +#define div_mask(d) ((1 << ((d)->width)) - 1) static unsigned int _get_table_maxdiv(const struct clk_div_table *table) { @@ -137,7 +137,7 @@ static bool _is_valid_table_div(const struct clk_div_table *table, static bool _is_valid_div(struct clk_divider *divider, unsigned int div) { if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) - return is_power_of_two(div); + return is_power_of_2(div); if (divider->table) return _is_valid_table_div(divider->table, div); return true; |