Re: [PATCH v2 6/20] clk: sunxi-ng: mux: Change pre-divider application function prototype

2017-05-03 Thread Chen-Yu Tsai
On Wed, May 3, 2017 at 7:59 PM, Maxime Ripard
 wrote:
> The current function name is a bit confusing, and doesn't really allow to
> create an explicit function to reverse the operation.
>
> We also for now change the parent rate through a pointer, while we don't
> return anything.
>
> In order to be less confusing, and easier to use for downstream users,
> change the function name to something hopefully clearer, and return the
> adjusted rate instead of changing the pointer.
>
> Signed-off-by: Maxime Ripard 

Acked-by: Chen-Yu Tsai 


Re: [PATCH v2 6/20] clk: sunxi-ng: mux: Change pre-divider application function prototype

2017-05-03 Thread Chen-Yu Tsai
On Wed, May 3, 2017 at 7:59 PM, Maxime Ripard
 wrote:
> The current function name is a bit confusing, and doesn't really allow to
> create an explicit function to reverse the operation.
>
> We also for now change the parent rate through a pointer, while we don't
> return anything.
>
> In order to be less confusing, and easier to use for downstream users,
> change the function name to something hopefully clearer, and return the
> adjusted rate instead of changing the pointer.
>
> Signed-off-by: Maxime Ripard 

Acked-by: Chen-Yu Tsai 


[PATCH v2 6/20] clk: sunxi-ng: mux: Change pre-divider application function prototype

2017-05-03 Thread Maxime Ripard
The current function name is a bit confusing, and doesn't really allow to
create an explicit function to reverse the operation.

We also for now change the parent rate through a pointer, while we don't
return anything.

In order to be less confusing, and easier to use for downstream users,
change the function name to something hopefully clearer, and return the
adjusted rate instead of changing the pointer.

Signed-off-by: Maxime Ripard 
---
 drivers/clk/sunxi-ng/ccu_div.c  |  8 
 drivers/clk/sunxi-ng/ccu_mp.c   |  8 
 drivers/clk/sunxi-ng/ccu_mult.c |  8 
 drivers/clk/sunxi-ng/ccu_mux.c  | 29 -
 drivers/clk/sunxi-ng/ccu_mux.h  |  8 
 5 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
index 419463375bc1..c0e5c10d0091 100644
--- a/drivers/clk/sunxi-ng/ccu_div.c
+++ b/drivers/clk/sunxi-ng/ccu_div.c
@@ -59,8 +59,8 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
val = reg >> cd->div.shift;
val &= (1 << cd->div.width) - 1;
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
return divider_recalc_rate(hw, parent_rate, val, cd->div.table,
   cd->div.flags);
@@ -83,8 +83,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long 
rate,
unsigned long val;
u32 reg;
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width,
  cd->div.flags);
diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
index de02e6c386d8..b917ad7a386c 100644
--- a/drivers/clk/sunxi-ng/ccu_mp.c
+++ b/drivers/clk/sunxi-ng/ccu_mp.c
@@ -87,8 +87,8 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw,
u32 reg;
 
/* Adjust parent_rate according to pre-dividers */
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux,
-   -1, _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
reg = readl(cmp->common.base + cmp->common.reg);
 
@@ -123,8 +123,8 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long 
rate,
u32 reg;
 
/* Adjust parent_rate according to pre-dividers */
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux,
-   -1, _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
max_m = cmp->m.max ?: 1 << cmp->m.width;
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
diff --git a/drivers/clk/sunxi-ng/ccu_mult.c b/drivers/clk/sunxi-ng/ccu_mult.c
index 6ee7ba0738fb..20d0300867f2 100644
--- a/drivers/clk/sunxi-ng/ccu_mult.c
+++ b/drivers/clk/sunxi-ng/ccu_mult.c
@@ -88,8 +88,8 @@ static unsigned long ccu_mult_recalc_rate(struct clk_hw *hw,
val = reg >> cm->mult.shift;
val &= (1 << cm->mult.width) - 1;
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
return parent_rate * (val + cm->mult.offset);
 }
@@ -116,8 +116,8 @@ static int ccu_mult_set_rate(struct clk_hw *hw, unsigned 
long rate,
else
ccu_frac_helper_disable(>common, >frac);
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
_cm.min = cm->mult.min;
 
diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c
index 3eb23d4e6534..c33210972581 100644
--- a/drivers/clk/sunxi-ng/ccu_mux.c
+++ b/drivers/clk/sunxi-ng/ccu_mux.c
@@ -56,13 +56,12 @@ static u16 ccu_mux_get_prediv(struct ccu_common *common,
return prediv;
 }
 
-void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
-struct ccu_mux_internal *cm,
-int parent_index,
-unsigned long *parent_rate)
+unsigned long ccu_mux_helper_apply_prediv(struct ccu_common *common,
+ 

[PATCH v2 6/20] clk: sunxi-ng: mux: Change pre-divider application function prototype

2017-05-03 Thread Maxime Ripard
The current function name is a bit confusing, and doesn't really allow to
create an explicit function to reverse the operation.

We also for now change the parent rate through a pointer, while we don't
return anything.

In order to be less confusing, and easier to use for downstream users,
change the function name to something hopefully clearer, and return the
adjusted rate instead of changing the pointer.

Signed-off-by: Maxime Ripard 
---
 drivers/clk/sunxi-ng/ccu_div.c  |  8 
 drivers/clk/sunxi-ng/ccu_mp.c   |  8 
 drivers/clk/sunxi-ng/ccu_mult.c |  8 
 drivers/clk/sunxi-ng/ccu_mux.c  | 29 -
 drivers/clk/sunxi-ng/ccu_mux.h  |  8 
 5 files changed, 28 insertions(+), 33 deletions(-)

diff --git a/drivers/clk/sunxi-ng/ccu_div.c b/drivers/clk/sunxi-ng/ccu_div.c
index 419463375bc1..c0e5c10d0091 100644
--- a/drivers/clk/sunxi-ng/ccu_div.c
+++ b/drivers/clk/sunxi-ng/ccu_div.c
@@ -59,8 +59,8 @@ static unsigned long ccu_div_recalc_rate(struct clk_hw *hw,
val = reg >> cd->div.shift;
val &= (1 << cd->div.width) - 1;
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
return divider_recalc_rate(hw, parent_rate, val, cd->div.table,
   cd->div.flags);
@@ -83,8 +83,8 @@ static int ccu_div_set_rate(struct clk_hw *hw, unsigned long 
rate,
unsigned long val;
u32 reg;
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width,
  cd->div.flags);
diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c
index de02e6c386d8..b917ad7a386c 100644
--- a/drivers/clk/sunxi-ng/ccu_mp.c
+++ b/drivers/clk/sunxi-ng/ccu_mp.c
@@ -87,8 +87,8 @@ static unsigned long ccu_mp_recalc_rate(struct clk_hw *hw,
u32 reg;
 
/* Adjust parent_rate according to pre-dividers */
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux,
-   -1, _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
reg = readl(cmp->common.base + cmp->common.reg);
 
@@ -123,8 +123,8 @@ static int ccu_mp_set_rate(struct clk_hw *hw, unsigned long 
rate,
u32 reg;
 
/* Adjust parent_rate according to pre-dividers */
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux,
-   -1, _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
max_m = cmp->m.max ?: 1 << cmp->m.width;
max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
diff --git a/drivers/clk/sunxi-ng/ccu_mult.c b/drivers/clk/sunxi-ng/ccu_mult.c
index 6ee7ba0738fb..20d0300867f2 100644
--- a/drivers/clk/sunxi-ng/ccu_mult.c
+++ b/drivers/clk/sunxi-ng/ccu_mult.c
@@ -88,8 +88,8 @@ static unsigned long ccu_mult_recalc_rate(struct clk_hw *hw,
val = reg >> cm->mult.shift;
val &= (1 << cm->mult.width) - 1;
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
return parent_rate * (val + cm->mult.offset);
 }
@@ -116,8 +116,8 @@ static int ccu_mult_set_rate(struct clk_hw *hw, unsigned 
long rate,
else
ccu_frac_helper_disable(>common, >frac);
 
-   ccu_mux_helper_adjust_parent_for_prediv(>common, >mux, -1,
-   _rate);
+   parent_rate = ccu_mux_helper_apply_prediv(>common, >mux, -1,
+ parent_rate);
 
_cm.min = cm->mult.min;
 
diff --git a/drivers/clk/sunxi-ng/ccu_mux.c b/drivers/clk/sunxi-ng/ccu_mux.c
index 3eb23d4e6534..c33210972581 100644
--- a/drivers/clk/sunxi-ng/ccu_mux.c
+++ b/drivers/clk/sunxi-ng/ccu_mux.c
@@ -56,13 +56,12 @@ static u16 ccu_mux_get_prediv(struct ccu_common *common,
return prediv;
 }
 
-void ccu_mux_helper_adjust_parent_for_prediv(struct ccu_common *common,
-struct ccu_mux_internal *cm,
-int parent_index,
-unsigned long *parent_rate)
+unsigned long ccu_mux_helper_apply_prediv(struct ccu_common *common,
+