Skip to content

Commit d8a9774

Browse files
committed
clk: ti: fapll: convert from round_rate() to determine_rate()
The round_rate() clk ops is deprecated, so migrate this driver from round_rate() to determine_rate() using the Coccinelle semantic patch on the cover letter of this series. Tested-by: Anddreas Kemnade <andreas@kemnade.info> # OMAP3 GTA04, OMAP4 Panda Reviewed-by: Kevin Hilman <khilman@baylibre.com> Tested-by: Kevin Hilman <khilman@baylibre.com> Signed-off-by: Brian Masney <bmasney@redhat.com>
1 parent 48f8fb4 commit d8a9774

1 file changed

Lines changed: 27 additions & 21 deletions

File tree

drivers/clk/ti/fapll.c

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,27 @@ static int ti_fapll_set_div_mult(unsigned long rate,
214214
return 0;
215215
}
216216

217-
static long ti_fapll_round_rate(struct clk_hw *hw, unsigned long rate,
218-
unsigned long *parent_rate)
217+
static int ti_fapll_determine_rate(struct clk_hw *hw,
218+
struct clk_rate_request *req)
219219
{
220220
u32 pre_div_p, mult_n;
221221
int error;
222222

223-
if (!rate)
223+
if (!req->rate)
224224
return -EINVAL;
225225

226-
error = ti_fapll_set_div_mult(rate, *parent_rate,
226+
error = ti_fapll_set_div_mult(req->rate, req->best_parent_rate,
227227
&pre_div_p, &mult_n);
228-
if (error)
229-
return error;
228+
if (error) {
229+
req->rate = error;
230230

231-
rate = *parent_rate / pre_div_p;
232-
rate *= mult_n;
231+
return 0;
232+
}
233233

234-
return rate;
234+
req->rate = req->best_parent_rate / pre_div_p;
235+
req->rate *= mult_n;
236+
237+
return 0;
235238
}
236239

237240
static int ti_fapll_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -268,7 +271,7 @@ static const struct clk_ops ti_fapll_ops = {
268271
.is_enabled = ti_fapll_is_enabled,
269272
.recalc_rate = ti_fapll_recalc_rate,
270273
.get_parent = ti_fapll_get_parent,
271-
.round_rate = ti_fapll_round_rate,
274+
.determine_rate = ti_fapll_determine_rate,
272275
.set_rate = ti_fapll_set_rate,
273276
};
274277

@@ -399,38 +402,41 @@ static u32 ti_fapll_synth_set_frac_rate(struct fapll_synth *synth,
399402
return post_div_m;
400403
}
401404

402-
static long ti_fapll_synth_round_rate(struct clk_hw *hw, unsigned long rate,
403-
unsigned long *parent_rate)
405+
static int ti_fapll_synth_determine_rate(struct clk_hw *hw,
406+
struct clk_rate_request *req)
404407
{
405408
struct fapll_synth *synth = to_synth(hw);
406409
struct fapll_data *fd = synth->fd;
407410
unsigned long r;
408411

409-
if (ti_fapll_clock_is_bypass(fd) || !synth->div || !rate)
412+
if (ti_fapll_clock_is_bypass(fd) || !synth->div || !req->rate)
410413
return -EINVAL;
411414

412415
/* Only post divider m available with no fractional divider? */
413416
if (!synth->freq) {
414417
unsigned long frac_rate;
415418
u32 synth_post_div_m;
416419

417-
frac_rate = ti_fapll_synth_get_frac_rate(hw, *parent_rate);
418-
synth_post_div_m = DIV_ROUND_UP(frac_rate, rate);
420+
frac_rate = ti_fapll_synth_get_frac_rate(hw,
421+
req->best_parent_rate);
422+
synth_post_div_m = DIV_ROUND_UP(frac_rate, req->rate);
419423
r = DIV_ROUND_UP(frac_rate, synth_post_div_m);
420424
goto out;
421425
}
422426

423-
r = *parent_rate * SYNTH_PHASE_K;
424-
if (rate > r)
427+
r = req->best_parent_rate * SYNTH_PHASE_K;
428+
if (req->rate > r)
425429
goto out;
426430

427431
r = DIV_ROUND_UP_ULL(r, SYNTH_MAX_INT_DIV * SYNTH_MAX_DIV_M);
428-
if (rate < r)
432+
if (req->rate < r)
429433
goto out;
430434

431-
r = rate;
435+
r = req->rate;
432436
out:
433-
return r;
437+
req->rate = r;
438+
439+
return 0;
434440
}
435441

436442
static int ti_fapll_synth_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -477,7 +483,7 @@ static const struct clk_ops ti_fapll_synt_ops = {
477483
.disable = ti_fapll_synth_disable,
478484
.is_enabled = ti_fapll_synth_is_enabled,
479485
.recalc_rate = ti_fapll_synth_recalc_rate,
480-
.round_rate = ti_fapll_synth_round_rate,
486+
.determine_rate = ti_fapll_synth_determine_rate,
481487
.set_rate = ti_fapll_synth_set_rate,
482488
};
483489

0 commit comments

Comments
 (0)