diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2014-12-02 02:54:22 -0500 |
---|---|---|
committer | Michael Turquette <mturquette@linaro.org> | 2014-12-03 19:21:37 -0500 |
commit | 646cafc6aa4d6004d189de1cdc267ab562069ba9 (patch) | |
tree | 6d2f85aecfe37696c0930b1dce17722e863cc804 /drivers/clk | |
parent | 61c7cddfad266ebb86176723f9c679f25cf705fe (diff) |
clk: Change clk_ops->determine_rate to return a clk_hw as the best parent
This is in preparation for clock providers to not have to deal with struct clk.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/at91/clk-programmable.c | 4 | ||||
-rw-r--r-- | drivers/clk/bcm/clk-kona.c | 4 | ||||
-rw-r--r-- | drivers/clk/clk-composite.c | 9 | ||||
-rw-r--r-- | drivers/clk/clk.c | 17 | ||||
-rw-r--r-- | drivers/clk/hisilicon/clk-hi3620.c | 2 | ||||
-rw-r--r-- | drivers/clk/mmp/clk-mix.c | 4 | ||||
-rw-r--r-- | drivers/clk/qcom/clk-pll.c | 2 | ||||
-rw-r--r-- | drivers/clk/qcom/clk-rcg.c | 20 | ||||
-rw-r--r-- | drivers/clk/qcom/clk-rcg2.c | 28 | ||||
-rw-r--r-- | drivers/clk/sunxi/clk-factors.c | 4 | ||||
-rw-r--r-- | drivers/clk/sunxi/clk-sun6i-ar100.c | 4 |
11 files changed, 57 insertions, 41 deletions
diff --git a/drivers/clk/at91/clk-programmable.c b/drivers/clk/at91/clk-programmable.c index 62e2509f9df1..bbdb1b985c91 100644 --- a/drivers/clk/at91/clk-programmable.c +++ b/drivers/clk/at91/clk-programmable.c | |||
@@ -57,7 +57,7 @@ static unsigned long clk_programmable_recalc_rate(struct clk_hw *hw, | |||
57 | static long clk_programmable_determine_rate(struct clk_hw *hw, | 57 | static long clk_programmable_determine_rate(struct clk_hw *hw, |
58 | unsigned long rate, | 58 | unsigned long rate, |
59 | unsigned long *best_parent_rate, | 59 | unsigned long *best_parent_rate, |
60 | struct clk **best_parent_clk) | 60 | struct clk_hw **best_parent_hw) |
61 | { | 61 | { |
62 | struct clk *parent = NULL; | 62 | struct clk *parent = NULL; |
63 | long best_rate = -EINVAL; | 63 | long best_rate = -EINVAL; |
@@ -84,7 +84,7 @@ static long clk_programmable_determine_rate(struct clk_hw *hw, | |||
84 | if (best_rate < 0 || (rate - tmp_rate) < (rate - best_rate)) { | 84 | if (best_rate < 0 || (rate - tmp_rate) < (rate - best_rate)) { |
85 | best_rate = tmp_rate; | 85 | best_rate = tmp_rate; |
86 | *best_parent_rate = parent_rate; | 86 | *best_parent_rate = parent_rate; |
87 | *best_parent_clk = parent; | 87 | *best_parent_hw = __clk_get_hw(parent); |
88 | } | 88 | } |
89 | 89 | ||
90 | if (!best_rate) | 90 | if (!best_rate) |
diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index 95af2e665dd3..1c06f6f3a8c5 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c | |||
@@ -1032,7 +1032,7 @@ static long kona_peri_clk_round_rate(struct clk_hw *hw, unsigned long rate, | |||
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | 1034 | static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, |
1035 | unsigned long *best_parent_rate, struct clk **best_parent) | 1035 | unsigned long *best_parent_rate, struct clk_hw **best_parent) |
1036 | { | 1036 | { |
1037 | struct kona_clk *bcm_clk = to_kona_clk(hw); | 1037 | struct kona_clk *bcm_clk = to_kona_clk(hw); |
1038 | struct clk *clk = hw->clk; | 1038 | struct clk *clk = hw->clk; |
@@ -1075,7 +1075,7 @@ static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
1075 | if (delta < best_delta) { | 1075 | if (delta < best_delta) { |
1076 | best_delta = delta; | 1076 | best_delta = delta; |
1077 | best_rate = other_rate; | 1077 | best_rate = other_rate; |
1078 | *best_parent = parent; | 1078 | *best_parent = __clk_get_hw(parent); |
1079 | *best_parent_rate = parent_rate; | 1079 | *best_parent_rate = parent_rate; |
1080 | } | 1080 | } |
1081 | } | 1081 | } |
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index b9355daf8065..4386697236a7 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c | |||
@@ -57,7 +57,7 @@ static unsigned long clk_composite_recalc_rate(struct clk_hw *hw, | |||
57 | 57 | ||
58 | static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate, | 58 | static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate, |
59 | unsigned long *best_parent_rate, | 59 | unsigned long *best_parent_rate, |
60 | struct clk **best_parent_p) | 60 | struct clk_hw **best_parent_p) |
61 | { | 61 | { |
62 | struct clk_composite *composite = to_clk_composite(hw); | 62 | struct clk_composite *composite = to_clk_composite(hw); |
63 | const struct clk_ops *rate_ops = composite->rate_ops; | 63 | const struct clk_ops *rate_ops = composite->rate_ops; |
@@ -80,8 +80,9 @@ static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
80 | *best_parent_p = NULL; | 80 | *best_parent_p = NULL; |
81 | 81 | ||
82 | if (__clk_get_flags(hw->clk) & CLK_SET_RATE_NO_REPARENT) { | 82 | if (__clk_get_flags(hw->clk) & CLK_SET_RATE_NO_REPARENT) { |
83 | *best_parent_p = clk_get_parent(mux_hw->clk); | 83 | parent = clk_get_parent(mux_hw->clk); |
84 | *best_parent_rate = __clk_get_rate(*best_parent_p); | 84 | *best_parent_p = __clk_get_hw(parent); |
85 | *best_parent_rate = __clk_get_rate(parent); | ||
85 | 86 | ||
86 | return rate_ops->round_rate(rate_hw, rate, | 87 | return rate_ops->round_rate(rate_hw, rate, |
87 | best_parent_rate); | 88 | best_parent_rate); |
@@ -103,7 +104,7 @@ static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
103 | 104 | ||
104 | if (!rate_diff || !*best_parent_p | 105 | if (!rate_diff || !*best_parent_p |
105 | || best_rate_diff > rate_diff) { | 106 | || best_rate_diff > rate_diff) { |
106 | *best_parent_p = parent; | 107 | *best_parent_p = __clk_get_hw(parent); |
107 | *best_parent_rate = parent_rate; | 108 | *best_parent_rate = parent_rate; |
108 | best_rate_diff = rate_diff; | 109 | best_rate_diff = rate_diff; |
109 | best_rate = tmp_rate; | 110 | best_rate = tmp_rate; |
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index f549e8b1d5ed..44cdc47a6cc5 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -702,7 +702,7 @@ struct clk *__clk_lookup(const char *name) | |||
702 | */ | 702 | */ |
703 | long __clk_mux_determine_rate(struct clk_hw *hw, unsigned long rate, | 703 | long __clk_mux_determine_rate(struct clk_hw *hw, unsigned long rate, |
704 | unsigned long *best_parent_rate, | 704 | unsigned long *best_parent_rate, |
705 | struct clk **best_parent_p) | 705 | struct clk_hw **best_parent_p) |
706 | { | 706 | { |
707 | struct clk *clk = hw->clk, *parent, *best_parent = NULL; | 707 | struct clk *clk = hw->clk, *parent, *best_parent = NULL; |
708 | int i, num_parents; | 708 | int i, num_parents; |
@@ -738,7 +738,7 @@ long __clk_mux_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
738 | 738 | ||
739 | out: | 739 | out: |
740 | if (best_parent) | 740 | if (best_parent) |
741 | *best_parent_p = best_parent; | 741 | *best_parent_p = best_parent->hw; |
742 | *best_parent_rate = best; | 742 | *best_parent_rate = best; |
743 | 743 | ||
744 | return best; | 744 | return best; |
@@ -946,6 +946,7 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate) | |||
946 | { | 946 | { |
947 | unsigned long parent_rate = 0; | 947 | unsigned long parent_rate = 0; |
948 | struct clk *parent; | 948 | struct clk *parent; |
949 | struct clk_hw *parent_hw; | ||
949 | 950 | ||
950 | if (!clk) | 951 | if (!clk) |
951 | return 0; | 952 | return 0; |
@@ -954,10 +955,11 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate) | |||
954 | if (parent) | 955 | if (parent) |
955 | parent_rate = parent->rate; | 956 | parent_rate = parent->rate; |
956 | 957 | ||
957 | if (clk->ops->determine_rate) | 958 | if (clk->ops->determine_rate) { |
959 | parent_hw = parent ? parent->hw : NULL; | ||
958 | return clk->ops->determine_rate(clk->hw, rate, &parent_rate, | 960 | return clk->ops->determine_rate(clk->hw, rate, &parent_rate, |
959 | &parent); | 961 | &parent_hw); |
960 | else if (clk->ops->round_rate) | 962 | } else if (clk->ops->round_rate) |
961 | return clk->ops->round_rate(clk->hw, rate, &parent_rate); | 963 | return clk->ops->round_rate(clk->hw, rate, &parent_rate); |
962 | else if (clk->flags & CLK_SET_RATE_PARENT) | 964 | else if (clk->flags & CLK_SET_RATE_PARENT) |
963 | return __clk_round_rate(clk->parent, rate); | 965 | return __clk_round_rate(clk->parent, rate); |
@@ -1345,6 +1347,7 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) | |||
1345 | { | 1347 | { |
1346 | struct clk *top = clk; | 1348 | struct clk *top = clk; |
1347 | struct clk *old_parent, *parent; | 1349 | struct clk *old_parent, *parent; |
1350 | struct clk_hw *parent_hw; | ||
1348 | unsigned long best_parent_rate = 0; | 1351 | unsigned long best_parent_rate = 0; |
1349 | unsigned long new_rate; | 1352 | unsigned long new_rate; |
1350 | int p_index = 0; | 1353 | int p_index = 0; |
@@ -1360,9 +1363,11 @@ static struct clk *clk_calc_new_rates(struct clk *clk, unsigned long rate) | |||
1360 | 1363 | ||
1361 | /* find the closest rate and parent clk/rate */ | 1364 | /* find the closest rate and parent clk/rate */ |
1362 | if (clk->ops->determine_rate) { | 1365 | if (clk->ops->determine_rate) { |
1366 | parent_hw = parent ? parent->hw : NULL; | ||
1363 | new_rate = clk->ops->determine_rate(clk->hw, rate, | 1367 | new_rate = clk->ops->determine_rate(clk->hw, rate, |
1364 | &best_parent_rate, | 1368 | &best_parent_rate, |
1365 | &parent); | 1369 | &parent_hw); |
1370 | parent = parent_hw->clk; | ||
1366 | } else if (clk->ops->round_rate) { | 1371 | } else if (clk->ops->round_rate) { |
1367 | new_rate = clk->ops->round_rate(clk->hw, rate, | 1372 | new_rate = clk->ops->round_rate(clk->hw, rate, |
1368 | &best_parent_rate); | 1373 | &best_parent_rate); |
diff --git a/drivers/clk/hisilicon/clk-hi3620.c b/drivers/clk/hisilicon/clk-hi3620.c index 640ea3327c3e..007144f81f50 100644 --- a/drivers/clk/hisilicon/clk-hi3620.c +++ b/drivers/clk/hisilicon/clk-hi3620.c | |||
@@ -296,7 +296,7 @@ static unsigned long mmc_clk_recalc_rate(struct clk_hw *hw, | |||
296 | 296 | ||
297 | static long mmc_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | 297 | static long mmc_clk_determine_rate(struct clk_hw *hw, unsigned long rate, |
298 | unsigned long *best_parent_rate, | 298 | unsigned long *best_parent_rate, |
299 | struct clk **best_parent_p) | 299 | struct clk_hw **best_parent_p) |
300 | { | 300 | { |
301 | struct clk_mmc *mclk = to_mmc(hw); | 301 | struct clk_mmc *mclk = to_mmc(hw); |
302 | unsigned long best = 0; | 302 | unsigned long best = 0; |
diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c index b79742c47d53..48fa53c7ce5e 100644 --- a/drivers/clk/mmp/clk-mix.c +++ b/drivers/clk/mmp/clk-mix.c | |||
@@ -203,7 +203,7 @@ error: | |||
203 | 203 | ||
204 | static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, | 204 | static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, |
205 | unsigned long *best_parent_rate, | 205 | unsigned long *best_parent_rate, |
206 | struct clk **best_parent_clk) | 206 | struct clk_hw **best_parent_clk) |
207 | { | 207 | { |
208 | struct mmp_clk_mix *mix = to_clk_mix(hw); | 208 | struct mmp_clk_mix *mix = to_clk_mix(hw); |
209 | struct mmp_clk_mix_clk_table *item; | 209 | struct mmp_clk_mix_clk_table *item; |
@@ -264,7 +264,7 @@ static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
264 | 264 | ||
265 | found: | 265 | found: |
266 | *best_parent_rate = parent_rate_best; | 266 | *best_parent_rate = parent_rate_best; |
267 | *best_parent_clk = parent_best; | 267 | *best_parent_clk = __clk_get_hw(parent_best); |
268 | 268 | ||
269 | return mix_rate_best; | 269 | return mix_rate_best; |
270 | } | 270 | } |
diff --git a/drivers/clk/qcom/clk-pll.c b/drivers/clk/qcom/clk-pll.c index b823bc3b6250..60873a7f45d9 100644 --- a/drivers/clk/qcom/clk-pll.c +++ b/drivers/clk/qcom/clk-pll.c | |||
@@ -141,7 +141,7 @@ struct pll_freq_tbl *find_freq(const struct pll_freq_tbl *f, unsigned long rate) | |||
141 | 141 | ||
142 | static long | 142 | static long |
143 | clk_pll_determine_rate(struct clk_hw *hw, unsigned long rate, | 143 | clk_pll_determine_rate(struct clk_hw *hw, unsigned long rate, |
144 | unsigned long *p_rate, struct clk **p) | 144 | unsigned long *p_rate, struct clk_hw **p) |
145 | { | 145 | { |
146 | struct clk_pll *pll = to_clk_pll(hw); | 146 | struct clk_pll *pll = to_clk_pll(hw); |
147 | const struct pll_freq_tbl *f; | 147 | const struct pll_freq_tbl *f; |
diff --git a/drivers/clk/qcom/clk-rcg.c b/drivers/clk/qcom/clk-rcg.c index b6e6959e89aa..0b93972c8807 100644 --- a/drivers/clk/qcom/clk-rcg.c +++ b/drivers/clk/qcom/clk-rcg.c | |||
@@ -368,16 +368,17 @@ clk_dyn_rcg_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) | |||
368 | 368 | ||
369 | static long _freq_tbl_determine_rate(struct clk_hw *hw, | 369 | static long _freq_tbl_determine_rate(struct clk_hw *hw, |
370 | const struct freq_tbl *f, unsigned long rate, | 370 | const struct freq_tbl *f, unsigned long rate, |
371 | unsigned long *p_rate, struct clk **p) | 371 | unsigned long *p_rate, struct clk_hw **p_hw) |
372 | { | 372 | { |
373 | unsigned long clk_flags; | 373 | unsigned long clk_flags; |
374 | struct clk *p; | ||
374 | 375 | ||
375 | f = qcom_find_freq(f, rate); | 376 | f = qcom_find_freq(f, rate); |
376 | if (!f) | 377 | if (!f) |
377 | return -EINVAL; | 378 | return -EINVAL; |
378 | 379 | ||
379 | clk_flags = __clk_get_flags(hw->clk); | 380 | clk_flags = __clk_get_flags(hw->clk); |
380 | *p = clk_get_parent_by_index(hw->clk, f->src); | 381 | p = clk_get_parent_by_index(hw->clk, f->src); |
381 | if (clk_flags & CLK_SET_RATE_PARENT) { | 382 | if (clk_flags & CLK_SET_RATE_PARENT) { |
382 | rate = rate * f->pre_div; | 383 | rate = rate * f->pre_div; |
383 | if (f->n) { | 384 | if (f->n) { |
@@ -387,15 +388,16 @@ static long _freq_tbl_determine_rate(struct clk_hw *hw, | |||
387 | rate = tmp; | 388 | rate = tmp; |
388 | } | 389 | } |
389 | } else { | 390 | } else { |
390 | rate = __clk_get_rate(*p); | 391 | rate = __clk_get_rate(p); |
391 | } | 392 | } |
393 | *p_hw = __clk_get_hw(p); | ||
392 | *p_rate = rate; | 394 | *p_rate = rate; |
393 | 395 | ||
394 | return f->freq; | 396 | return f->freq; |
395 | } | 397 | } |
396 | 398 | ||
397 | static long clk_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, | 399 | static long clk_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, |
398 | unsigned long *p_rate, struct clk **p) | 400 | unsigned long *p_rate, struct clk_hw **p) |
399 | { | 401 | { |
400 | struct clk_rcg *rcg = to_clk_rcg(hw); | 402 | struct clk_rcg *rcg = to_clk_rcg(hw); |
401 | 403 | ||
@@ -403,7 +405,7 @@ static long clk_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
403 | } | 405 | } |
404 | 406 | ||
405 | static long clk_dyn_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, | 407 | static long clk_dyn_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, |
406 | unsigned long *p_rate, struct clk **p) | 408 | unsigned long *p_rate, struct clk_hw **p) |
407 | { | 409 | { |
408 | struct clk_dyn_rcg *rcg = to_clk_dyn_rcg(hw); | 410 | struct clk_dyn_rcg *rcg = to_clk_dyn_rcg(hw); |
409 | 411 | ||
@@ -411,13 +413,15 @@ static long clk_dyn_rcg_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
411 | } | 413 | } |
412 | 414 | ||
413 | static long clk_rcg_bypass_determine_rate(struct clk_hw *hw, unsigned long rate, | 415 | static long clk_rcg_bypass_determine_rate(struct clk_hw *hw, unsigned long rate, |
414 | unsigned long *p_rate, struct clk **p) | 416 | unsigned long *p_rate, struct clk_hw **p_hw) |
415 | { | 417 | { |
416 | struct clk_rcg *rcg = to_clk_rcg(hw); | 418 | struct clk_rcg *rcg = to_clk_rcg(hw); |
417 | const struct freq_tbl *f = rcg->freq_tbl; | 419 | const struct freq_tbl *f = rcg->freq_tbl; |
420 | struct clk *p; | ||
418 | 421 | ||
419 | *p = clk_get_parent_by_index(hw->clk, f->src); | 422 | p = clk_get_parent_by_index(hw->clk, f->src); |
420 | *p_rate = __clk_round_rate(*p, rate); | 423 | *p_hw = __clk_get_hw(p); |
424 | *p_rate = __clk_round_rate(p, rate); | ||
421 | 425 | ||
422 | return *p_rate; | 426 | return *p_rate; |
423 | } | 427 | } |
diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index cfa9eb4fe9ca..08b8b3729f53 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c | |||
@@ -175,16 +175,17 @@ clk_rcg2_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) | |||
175 | 175 | ||
176 | static long _freq_tbl_determine_rate(struct clk_hw *hw, | 176 | static long _freq_tbl_determine_rate(struct clk_hw *hw, |
177 | const struct freq_tbl *f, unsigned long rate, | 177 | const struct freq_tbl *f, unsigned long rate, |
178 | unsigned long *p_rate, struct clk **p) | 178 | unsigned long *p_rate, struct clk_hw **p_hw) |
179 | { | 179 | { |
180 | unsigned long clk_flags; | 180 | unsigned long clk_flags; |
181 | struct clk *p; | ||
181 | 182 | ||
182 | f = qcom_find_freq(f, rate); | 183 | f = qcom_find_freq(f, rate); |
183 | if (!f) | 184 | if (!f) |
184 | return -EINVAL; | 185 | return -EINVAL; |
185 | 186 | ||
186 | clk_flags = __clk_get_flags(hw->clk); | 187 | clk_flags = __clk_get_flags(hw->clk); |
187 | *p = clk_get_parent_by_index(hw->clk, f->src); | 188 | p = clk_get_parent_by_index(hw->clk, f->src); |
188 | if (clk_flags & CLK_SET_RATE_PARENT) { | 189 | if (clk_flags & CLK_SET_RATE_PARENT) { |
189 | if (f->pre_div) { | 190 | if (f->pre_div) { |
190 | rate /= 2; | 191 | rate /= 2; |
@@ -198,15 +199,16 @@ static long _freq_tbl_determine_rate(struct clk_hw *hw, | |||
198 | rate = tmp; | 199 | rate = tmp; |
199 | } | 200 | } |
200 | } else { | 201 | } else { |
201 | rate = __clk_get_rate(*p); | 202 | rate = __clk_get_rate(p); |
202 | } | 203 | } |
204 | *p_hw = __clk_get_hw(p); | ||
203 | *p_rate = rate; | 205 | *p_rate = rate; |
204 | 206 | ||
205 | return f->freq; | 207 | return f->freq; |
206 | } | 208 | } |
207 | 209 | ||
208 | static long clk_rcg2_determine_rate(struct clk_hw *hw, unsigned long rate, | 210 | static long clk_rcg2_determine_rate(struct clk_hw *hw, unsigned long rate, |
209 | unsigned long *p_rate, struct clk **p) | 211 | unsigned long *p_rate, struct clk_hw **p) |
210 | { | 212 | { |
211 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); | 213 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); |
212 | 214 | ||
@@ -359,7 +361,7 @@ static int clk_edp_pixel_set_rate_and_parent(struct clk_hw *hw, | |||
359 | } | 361 | } |
360 | 362 | ||
361 | static long clk_edp_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, | 363 | static long clk_edp_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, |
362 | unsigned long *p_rate, struct clk **p) | 364 | unsigned long *p_rate, struct clk_hw **p) |
363 | { | 365 | { |
364 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); | 366 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); |
365 | const struct freq_tbl *f = rcg->freq_tbl; | 367 | const struct freq_tbl *f = rcg->freq_tbl; |
@@ -371,7 +373,7 @@ static long clk_edp_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
371 | u32 hid_div; | 373 | u32 hid_div; |
372 | 374 | ||
373 | /* Force the correct parent */ | 375 | /* Force the correct parent */ |
374 | *p = clk_get_parent_by_index(hw->clk, f->src); | 376 | *p = __clk_get_hw(clk_get_parent_by_index(hw->clk, f->src)); |
375 | 377 | ||
376 | if (src_rate == 810000000) | 378 | if (src_rate == 810000000) |
377 | frac = frac_table_810m; | 379 | frac = frac_table_810m; |
@@ -410,18 +412,20 @@ const struct clk_ops clk_edp_pixel_ops = { | |||
410 | EXPORT_SYMBOL_GPL(clk_edp_pixel_ops); | 412 | EXPORT_SYMBOL_GPL(clk_edp_pixel_ops); |
411 | 413 | ||
412 | static long clk_byte_determine_rate(struct clk_hw *hw, unsigned long rate, | 414 | static long clk_byte_determine_rate(struct clk_hw *hw, unsigned long rate, |
413 | unsigned long *p_rate, struct clk **p) | 415 | unsigned long *p_rate, struct clk_hw **p_hw) |
414 | { | 416 | { |
415 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); | 417 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); |
416 | const struct freq_tbl *f = rcg->freq_tbl; | 418 | const struct freq_tbl *f = rcg->freq_tbl; |
417 | unsigned long parent_rate, div; | 419 | unsigned long parent_rate, div; |
418 | u32 mask = BIT(rcg->hid_width) - 1; | 420 | u32 mask = BIT(rcg->hid_width) - 1; |
421 | struct clk *p; | ||
419 | 422 | ||
420 | if (rate == 0) | 423 | if (rate == 0) |
421 | return -EINVAL; | 424 | return -EINVAL; |
422 | 425 | ||
423 | *p = clk_get_parent_by_index(hw->clk, f->src); | 426 | p = clk_get_parent_by_index(hw->clk, f->src); |
424 | *p_rate = parent_rate = __clk_round_rate(*p, rate); | 427 | *p_hw = __clk_get_hw(p); |
428 | *p_rate = parent_rate = __clk_round_rate(p, rate); | ||
425 | 429 | ||
426 | div = DIV_ROUND_UP((2 * parent_rate), rate) - 1; | 430 | div = DIV_ROUND_UP((2 * parent_rate), rate) - 1; |
427 | div = min_t(u32, div, mask); | 431 | div = min_t(u32, div, mask); |
@@ -472,14 +476,16 @@ static const struct frac_entry frac_table_pixel[] = { | |||
472 | }; | 476 | }; |
473 | 477 | ||
474 | static long clk_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, | 478 | static long clk_pixel_determine_rate(struct clk_hw *hw, unsigned long rate, |
475 | unsigned long *p_rate, struct clk **p) | 479 | unsigned long *p_rate, struct clk_hw **p) |
476 | { | 480 | { |
477 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); | 481 | struct clk_rcg2 *rcg = to_clk_rcg2(hw); |
478 | unsigned long request, src_rate; | 482 | unsigned long request, src_rate; |
479 | int delta = 100000; | 483 | int delta = 100000; |
480 | const struct freq_tbl *f = rcg->freq_tbl; | 484 | const struct freq_tbl *f = rcg->freq_tbl; |
481 | const struct frac_entry *frac = frac_table_pixel; | 485 | const struct frac_entry *frac = frac_table_pixel; |
482 | struct clk *parent = *p = clk_get_parent_by_index(hw->clk, f->src); | 486 | struct clk *parent = clk_get_parent_by_index(hw->clk, f->src); |
487 | |||
488 | *p = __clk_get_hw(parent); | ||
483 | 489 | ||
484 | for (; frac->num; frac++) { | 490 | for (; frac->num; frac++) { |
485 | request = (rate * frac->den) / frac->num; | 491 | request = (rate * frac->den) / frac->num; |
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c index 5521e866fa5e..62e08fb58554 100644 --- a/drivers/clk/sunxi/clk-factors.c +++ b/drivers/clk/sunxi/clk-factors.c | |||
@@ -81,7 +81,7 @@ static long clk_factors_round_rate(struct clk_hw *hw, unsigned long rate, | |||
81 | 81 | ||
82 | static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate, | 82 | static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate, |
83 | unsigned long *best_parent_rate, | 83 | unsigned long *best_parent_rate, |
84 | struct clk **best_parent_p) | 84 | struct clk_hw **best_parent_p) |
85 | { | 85 | { |
86 | struct clk *clk = hw->clk, *parent, *best_parent = NULL; | 86 | struct clk *clk = hw->clk, *parent, *best_parent = NULL; |
87 | int i, num_parents; | 87 | int i, num_parents; |
@@ -108,7 +108,7 @@ static long clk_factors_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
108 | } | 108 | } |
109 | 109 | ||
110 | if (best_parent) | 110 | if (best_parent) |
111 | *best_parent_p = best_parent; | 111 | *best_parent_p = __clk_get_hw(best_parent); |
112 | *best_parent_rate = best; | 112 | *best_parent_rate = best; |
113 | 113 | ||
114 | return best_child_rate; | 114 | return best_child_rate; |
diff --git a/drivers/clk/sunxi/clk-sun6i-ar100.c b/drivers/clk/sunxi/clk-sun6i-ar100.c index acca53290be2..3d282fb8f85c 100644 --- a/drivers/clk/sunxi/clk-sun6i-ar100.c +++ b/drivers/clk/sunxi/clk-sun6i-ar100.c | |||
@@ -46,7 +46,7 @@ static unsigned long ar100_recalc_rate(struct clk_hw *hw, | |||
46 | 46 | ||
47 | static long ar100_determine_rate(struct clk_hw *hw, unsigned long rate, | 47 | static long ar100_determine_rate(struct clk_hw *hw, unsigned long rate, |
48 | unsigned long *best_parent_rate, | 48 | unsigned long *best_parent_rate, |
49 | struct clk **best_parent_clk) | 49 | struct clk_hw **best_parent_clk) |
50 | { | 50 | { |
51 | int nparents = __clk_get_num_parents(hw->clk); | 51 | int nparents = __clk_get_num_parents(hw->clk); |
52 | long best_rate = -EINVAL; | 52 | long best_rate = -EINVAL; |
@@ -100,7 +100,7 @@ static long ar100_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
100 | 100 | ||
101 | tmp_rate = (parent_rate >> shift) / div; | 101 | tmp_rate = (parent_rate >> shift) / div; |
102 | if (!*best_parent_clk || tmp_rate > best_rate) { | 102 | if (!*best_parent_clk || tmp_rate > best_rate) { |
103 | *best_parent_clk = parent; | 103 | *best_parent_clk = __clk_get_hw(parent); |
104 | *best_parent_rate = parent_rate; | 104 | *best_parent_rate = parent_rate; |
105 | best_rate = tmp_rate; | 105 | best_rate = tmp_rate; |
106 | } | 106 | } |