Skip to content

Commit

Permalink
clk: composite: allow fixed rates & fixed dividers
Browse files Browse the repository at this point in the history
The composite clock assumes that any clock implementing the .recalc_rate
callback will also implement .round_rate and .set_rate.  This is not
always true; the basic fixed-rate clock will only implement .recalc_rate
and a fixed-divider clock may choose to implement .recalc_rate and
.round_rate but not .set_rate.

Fix this by conditionally registering .round_rate and .set_rate
callbacks based on the rate_ops passed in to clk_composite_register.

Signed-off-by: Mike Turquette <[email protected]>
Cc: Prashant Gaikwad <[email protected]>
Tested-by: Emilio López <[email protected]>
Cc: Gregory CLEMENT <[email protected]>
  • Loading branch information
Mike Turquette committed Apr 12, 2013
1 parent d3a1c7b commit f363e21
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/clk/clk-composite.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,26 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
}

if (rate_hw && rate_ops) {
if (!rate_ops->recalc_rate || !rate_ops->round_rate ||
!rate_ops->set_rate) {
if (!rate_ops->recalc_rate) {
clk = ERR_PTR(-EINVAL);
goto err;
}

/* .round_rate is a prerequisite for .set_rate */
if (rate_ops->round_rate) {
clk_composite_ops->round_rate = clk_composite_round_rate;
if (rate_ops->set_rate) {
clk_composite_ops->set_rate = clk_composite_set_rate;
}
} else {
WARN(rate_ops->set_rate,
"%s: missing round_rate op is required\n",
__func__);
}

composite->rate_hw = rate_hw;
composite->rate_ops = rate_ops;
clk_composite_ops->recalc_rate = clk_composite_recalc_rate;
clk_composite_ops->round_rate = clk_composite_round_rate;
clk_composite_ops->set_rate = clk_composite_set_rate;
}

if (gate_hw && gate_ops) {
Expand Down

0 comments on commit f363e21

Please sign in to comment.