diff options
author | Mike Turquette <mturquette@linaro.org> | 2014-07-03 03:58:14 +0400 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-07-13 23:17:05 +0400 |
commit | 5a994e151f7c54a5fdeb07fe2fed4ed64b9321b8 (patch) | |
tree | 59575205b146557cf837264c80dfbdb9a7978fc7 /drivers | |
parent | 0c02cf2f1c2ffd75221b43bacb4f02a0e52e014b (diff) | |
download | linux-5a994e151f7c54a5fdeb07fe2fed4ed64b9321b8.tar.xz |
clk: composite: improve rate_hw sanity check logic
The function pointer population and sanity checking logic got a bit ugly
with the advent of the .determine_rate callback. Clean it up.
Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/clk/clk-composite.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index faf7c32fe351..b9355daf8065 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -226,21 +226,27 @@ struct clk *clk_register_composite(struct device *dev, const char *name, clk = ERR_PTR(-EINVAL); goto err; } + clk_composite_ops->recalc_rate = clk_composite_recalc_rate; - /* .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; - } + if (rate_ops->determine_rate) + clk_composite_ops->determine_rate = + clk_composite_determine_rate; + else if (rate_ops->round_rate) + clk_composite_ops->round_rate = + clk_composite_round_rate; + + /* .set_rate requires either .round_rate or .determine_rate */ + if (rate_ops->set_rate) { + if (rate_ops->determine_rate || rate_ops->round_rate) + clk_composite_ops->set_rate = + clk_composite_set_rate; + else + WARN(1, "%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; - if (rate_ops->determine_rate || - (rate_ops->round_rate && clk_composite_ops->set_parent)) - clk_composite_ops->determine_rate = clk_composite_determine_rate; } if (gate_hw && gate_ops) { |