[PATCH v4 4/6] clk: ti: divider: switch to GENMASK()

From: Andy Shevchenko
Date: Thu Jul 09 2015 - 12:44:23 EST


Convert the code to use GENMASK() helper instead of div_mask() macro.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
---
drivers/clk/ti/divider.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c
index ff5f117..dfe485e 100644
--- a/drivers/clk/ti/divider.c
+++ b/drivers/clk/ti/divider.c
@@ -28,8 +28,6 @@

#define to_clk_divider(_hw) container_of(_hw, struct clk_divider, hw)

-#define div_mask(d) ((1 << ((d)->width)) - 1)
-
static unsigned int _get_table_maxdiv(const struct clk_div_table *table)
{
unsigned int maxdiv = 0;
@@ -44,12 +42,12 @@ static unsigned int _get_table_maxdiv(const struct clk_div_table *table)
static unsigned int _get_maxdiv(struct clk_divider *divider)
{
if (divider->flags & CLK_DIVIDER_ONE_BASED)
- return div_mask(divider);
+ return GENMASK(divider->width - 1, 0);
if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
- return 1 << div_mask(divider);
+ return 1 << GENMASK(divider->width - 1, 0);
if (divider->table)
return _get_table_maxdiv(divider->table);
- return div_mask(divider) + 1;
+ return BIT(divider->width);
}

static unsigned int _get_table_div(const struct clk_div_table *table,
@@ -103,7 +101,7 @@ static unsigned long ti_clk_divider_recalc_rate(struct clk_hw *hw,
unsigned int div, val;

val = ti_clk_ll_ops->clk_readl(divider->reg) >> divider->shift;
- val &= div_mask(divider);
+ val &= GENMASK(divider->width - 1, 0);

div = _get_div(divider, val);
if (!div) {
@@ -225,17 +223,17 @@ static int ti_clk_divider_set_rate(struct clk_hw *hw, unsigned long rate,
div = DIV_ROUND_UP(parent_rate, rate);
value = _get_val(divider, div);

- if (value > div_mask(divider))
- value = div_mask(divider);
+ if (value > GENMASK(divider->width - 1, 0))
+ value = GENMASK(divider->width - 1, 0);

if (divider->lock)
spin_lock_irqsave(divider->lock, flags);

if (divider->flags & CLK_DIVIDER_HIWORD_MASK) {
- val = div_mask(divider) << (divider->shift + 16);
+ val = GENMASK(divider->width - 1, 0) << (divider->shift + 16);
} else {
val = ti_clk_ll_ops->clk_readl(divider->reg);
- val &= ~(div_mask(divider) << divider->shift);
+ val &= ~(GENMASK(divider->width - 1, 0) << divider->shift);
}
val |= value << divider->shift;
ti_clk_ll_ops->clk_writel(val, divider->reg);
--
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/