clk: sunxi-ng: mux: Change pre-divider application function prototype
authorMaxime Ripard <maxime.ripard@free-electrons.com>
Wed, 17 May 2017 07:40:35 +0000 (09:40 +0200)
committerMaxime Ripard <maxime.ripard@free-electrons.com>
Wed, 7 Jun 2017 13:32:13 +0000 (15:32 +0200)
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 <maxime.ripard@free-electrons.com>
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
drivers/clk/sunxi-ng/ccu_div.c
drivers/clk/sunxi-ng/ccu_mp.c
drivers/clk/sunxi-ng/ccu_mult.c
drivers/clk/sunxi-ng/ccu_mux.c
drivers/clk/sunxi-ng/ccu_mux.h

index 419463375bc1b9a0b9a9ac55ab55c2d6adc3b8a5..c0e5c10d00910325558203f66f288d1f352ec4ef 100644 (file)
@@ -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(&cd->common, &cd->mux, -1,
-                                               &parent_rate);
+       parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->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(&cd->common, &cd->mux, -1,
-                                               &parent_rate);
+       parent_rate = ccu_mux_helper_apply_prediv(&cd->common, &cd->mux, -1,
+                                                 parent_rate);
 
        val = divider_get_val(rate, parent_rate, cd->div.table, cd->div.width,
                              cd->div.flags);
index de02e6c386d81bdaad40d58f0101d2e249caefe9..b917ad7a386c0eddbb34b3b6c06bd3a0d452a851 100644 (file)
@@ -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(&cmp->common, &cmp->mux,
-                                               -1, &parent_rate);
+       parent_rate = ccu_mux_helper_apply_prediv(&cmp->common, &cmp->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(&cmp->common, &cmp->mux,
-                                               -1, &parent_rate);
+       parent_rate = ccu_mux_helper_apply_prediv(&cmp->common, &cmp->mux, -1,
+                                                 parent_rate);
 
        max_m = cmp->m.max ?: 1 << cmp->m.width;
        max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1);
index 6ee7ba0738fb9b3aeded325b7e44875546266c02..20d0300867f29afbc15448b9224b7070c7808e11 100644 (file)
@@ -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(&cm->common, &cm->mux, -1,
-                                               &parent_rate);
+       parent_rate = ccu_mux_helper_apply_prediv(&cm->common, &cm->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(&cm->common, &cm->frac);
 
-       ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1,
-                                               &parent_rate);
+       parent_rate = ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
+                                                 parent_rate);
 
        _cm.min = cm->mult.min;
 
index 3eb23d4e65344dca15133158b686464f046932d2..c332109725814989986ffe54d630f60645611cc7 100644 (file)
@@ -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,
+                                         struct ccu_mux_internal *cm,
+                                         int parent_index,
+                                         unsigned long parent_rate)
 {
-       *parent_rate = *parent_rate / ccu_mux_get_prediv(common, cm,
-                                                        parent_index);
+       return parent_rate / ccu_mux_get_prediv(common, cm, parent_index);
 }
 
 int ccu_mux_helper_determine_rate(struct ccu_common *common,
@@ -84,10 +83,8 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
 
                best_parent = clk_hw_get_parent(hw);
                best_parent_rate = clk_hw_get_rate(best_parent);
-
-               adj_parent_rate = best_parent_rate;
-               ccu_mux_helper_adjust_parent_for_prediv(common, cm, -1,
-                                                       &adj_parent_rate);
+               adj_parent_rate = ccu_mux_helper_apply_prediv(common, cm, -1,
+                                                             best_parent_rate);
 
                best_rate = round(cm, best_parent, &adj_parent_rate,
                                  req->rate, data);
@@ -103,9 +100,9 @@ int ccu_mux_helper_determine_rate(struct ccu_common *common,
                if (!parent)
                        continue;
 
-               adj_parent_rate = parent_rate = clk_hw_get_rate(parent);
-               ccu_mux_helper_adjust_parent_for_prediv(common, cm, i,
-                                                       &adj_parent_rate);
+               parent_rate = clk_hw_get_rate(parent);
+               adj_parent_rate = ccu_mux_helper_apply_prediv(common, cm, i,
+                                                             parent_rate);
 
                tmp_rate = round(cm, parent, &adj_parent_rate, req->rate, data);
                if (tmp_rate == req->rate) {
@@ -215,10 +212,8 @@ static unsigned long ccu_mux_recalc_rate(struct clk_hw *hw,
 {
        struct ccu_mux *cm = hw_to_ccu_mux(hw);
 
-       ccu_mux_helper_adjust_parent_for_prediv(&cm->common, &cm->mux, -1,
-                                               &parent_rate);
-
-       return parent_rate;
+       return ccu_mux_helper_apply_prediv(&cm->common, &cm->mux, -1,
+                                          parent_rate);
 }
 
 const struct clk_ops ccu_mux_ops = {
index 4be56eee2bfd195ceeafbde95bd4bbf1a7e9ed9c..dba12c76cf54643bf81949478f2f3c48541db1fa 100644 (file)
@@ -78,10 +78,10 @@ static inline struct ccu_mux *hw_to_ccu_mux(struct clk_hw *hw)
 
 extern const struct clk_ops ccu_mux_ops;
 
-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,
+                                         struct ccu_mux_internal *cm,
+                                         int parent_index,
+                                         unsigned long parent_rate);
 int ccu_mux_helper_determine_rate(struct ccu_common *common,
                                  struct ccu_mux_internal *cm,
                                  struct clk_rate_request *req,