[PATCH] clk: divider: export clk_div_mask() helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit e6d3cc7b1fac3d7f1313faf8ac9b23830113e3ec Linux upstream.

  clk: divider: export clk_div_mask() helper

  Export clk_div_mask() in clk-provider header so every clock providers
  derived from the generic clock divider may share the definition instead
  of redefining it.

  Signed-off-by: Jerome Brunet <jbrunet@xxxxxxxxxxxx>
  Signed-off-by: Michael Turquette <mturquette@xxxxxxxxxxxx>
  Signed-off-by: Stephen Boyd <sboyd@xxxxxxxxxx>

Signed-off-by: Marcin Niestroj <m.niestroj@xxxxxxxxxxxxxxxx>
---
 drivers/clk/clk-divider.c | 16 +++++++---------
 include/linux/clk.h       |  2 ++
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 566e6a5d0..78b415317 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -22,8 +22,6 @@
 #include <linux/log2.h>
 #include <asm-generic/div64.h>
 
-#define div_mask(width)	((1 << (width)) - 1)
-
 static unsigned int _get_table_maxdiv(const struct clk_div_table *table)
 {
 	unsigned int maxdiv = 0;
@@ -39,12 +37,12 @@ static unsigned int _get_maxdiv(const struct clk_div_table *table, u8 width,
 				unsigned long flags)
 {
 	if (flags & CLK_DIVIDER_ONE_BASED)
-		return div_mask(width);
+		return clk_div_mask(width);
 	if (flags & CLK_DIVIDER_POWER_OF_TWO)
-		return 1 << div_mask(width);
+		return 1 << clk_div_mask(width);
 	if (table)
 		return _get_table_maxdiv(table);
-	return div_mask(width) + 1;
+	return clk_div_mask(width) + 1;
 }
 
 static unsigned int _get_table_div(const struct clk_div_table *table,
@@ -111,7 +109,7 @@ static unsigned long clk_divider_recalc_rate(struct clk *clk,
 	unsigned int val;
 
 	val = readl(divider->reg) >> divider->shift;
-	val &= div_mask(divider->width);
+	val &= clk_div_mask(divider->width);
 
 	return divider_recalc_rate(clk, parent_rate, val, divider->table,
 				   divider->flags, divider->width);
@@ -270,7 +268,7 @@ int divider_get_val(unsigned long rate, unsigned long parent_rate,
 
 	value = _get_val(table, div, flags);
 
-	return min_t(unsigned int, value, div_mask(width));
+	return min_t(unsigned int, value, clk_div_mask(width));
 }
 
 static int clk_divider_set_rate(struct clk *clk, unsigned long rate,
@@ -296,11 +294,11 @@ static int clk_divider_set_rate(struct clk *clk, unsigned long rate,
 				divider->width, divider->flags);
 
 	val = readl(divider->reg);
-	val &= ~(div_mask(divider->width) << divider->shift);
+	val &= ~(clk_div_mask(divider->width) << divider->shift);
 	val |= value << divider->shift;
 
 	if (clk->flags & CLK_DIVIDER_HIWORD_MASK)
-		val |= div_mask(divider->width) << (divider->shift + 16);
+		val |= clk_div_mask(divider->width) << (divider->shift + 16);
 
 	writel(val, divider->reg);
 
diff --git a/include/linux/clk.h b/include/linux/clk.h
index ed78ffe46..c3aeea80d 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -340,6 +340,8 @@ struct clk_divider {
 	int table_size;
 };
 
+#define clk_div_mask(width)	((1 << (width)) - 1)
+
 #define CLK_DIVIDER_POWER_OF_TWO	(1 << 1)
 #define CLK_DIVIDER_HIWORD_MASK		(1 << 3)
 #define CLK_DIVIDER_READ_ONLY		(1 << 5)
-- 
2.21.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux