Skip to content

Commit 2b6c9b0

Browse files
mripardbebarino
authored andcommitted
ASoC: tlv320aic32x4: div: Switch to determine_rate
The tlv320aic32x4 divider clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Jaroslav Kysela <[email protected]> Cc: Liam Girdwood <[email protected]> Cc: Mark Brown <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: [email protected] Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 25d43ec commit 2b6c9b0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

sound/soc/codecs/tlv320aic32x4-clk.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,16 +332,17 @@ static int clk_aic32x4_div_set_rate(struct clk_hw *hw, unsigned long rate,
332332
AIC32X4_DIV_MASK, divisor);
333333
}
334334

335-
static long clk_aic32x4_div_round_rate(struct clk_hw *hw, unsigned long rate,
336-
unsigned long *parent_rate)
335+
static int clk_aic32x4_div_determine_rate(struct clk_hw *hw,
336+
struct clk_rate_request *req)
337337
{
338338
unsigned long divisor;
339339

340-
divisor = DIV_ROUND_UP(*parent_rate, rate);
340+
divisor = DIV_ROUND_UP(req->best_parent_rate, req->rate);
341341
if (divisor > 128)
342342
return -EINVAL;
343343

344-
return DIV_ROUND_UP(*parent_rate, divisor);
344+
req->rate = DIV_ROUND_UP(req->best_parent_rate, divisor);
345+
return 0;
345346
}
346347

347348
static unsigned long clk_aic32x4_div_recalc_rate(struct clk_hw *hw,
@@ -360,7 +361,7 @@ static const struct clk_ops aic32x4_div_ops = {
360361
.prepare = clk_aic32x4_div_prepare,
361362
.unprepare = clk_aic32x4_div_unprepare,
362363
.set_rate = clk_aic32x4_div_set_rate,
363-
.round_rate = clk_aic32x4_div_round_rate,
364+
.determine_rate = clk_aic32x4_div_determine_rate,
364365
.recalc_rate = clk_aic32x4_div_recalc_rate,
365366
};
366367

@@ -388,7 +389,7 @@ static const struct clk_ops aic32x4_bdiv_ops = {
388389
.set_parent = clk_aic32x4_bdiv_set_parent,
389390
.get_parent = clk_aic32x4_bdiv_get_parent,
390391
.set_rate = clk_aic32x4_div_set_rate,
391-
.round_rate = clk_aic32x4_div_round_rate,
392+
.determine_rate = clk_aic32x4_div_determine_rate,
392393
.recalc_rate = clk_aic32x4_div_recalc_rate,
393394
};
394395

0 commit comments

Comments
 (0)