diff options
author | Troy Kisky <troy.kisky@boundarydevices.com> | 2017-11-02 21:58:13 -0400 |
---|---|---|
committer | Alexandre Belloni <alexandre.belloni@free-electrons.com> | 2017-11-08 01:52:23 -0500 |
commit | c8384bb04261b9d32fe7402a6068ddaf38913b23 (patch) | |
tree | 3d587883486b42b4b82847b806d0b9cf87748d4e | |
parent | de6042d2fa8afe22b76e3c68fd6e9584c9415a3b (diff) |
rtc: m41t80: fix m41t80_sqw_round_rate return value
Previously it was returning the best of
32768, 8192, 1024, 64, 2, 0
Now, best of
32768, 8192, 4096, 2048, 1024, 512, 256, 128,
64, 32, 16, 8, 4, 2, 1, 0
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 8f5843169dc2..42fc735a5446 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -468,18 +468,13 @@ static unsigned long m41t80_sqw_recalc_rate(struct clk_hw *hw, | |||
468 | static long m41t80_sqw_round_rate(struct clk_hw *hw, unsigned long rate, | 468 | static long m41t80_sqw_round_rate(struct clk_hw *hw, unsigned long rate, |
469 | unsigned long *prate) | 469 | unsigned long *prate) |
470 | { | 470 | { |
471 | int i, freq = M41T80_SQW_MAX_FREQ; | 471 | if (rate >= M41T80_SQW_MAX_FREQ) |
472 | 472 | return M41T80_SQW_MAX_FREQ; | |
473 | if (freq <= rate) | 473 | if (rate >= M41T80_SQW_MAX_FREQ / 4) |
474 | return freq; | 474 | return M41T80_SQW_MAX_FREQ / 4; |
475 | 475 | if (!rate) | |
476 | for (i = 2; i <= ilog2(M41T80_SQW_MAX_FREQ); i++) { | 476 | return 0; |
477 | freq /= 1 << i; | 477 | return 1 << ilog2(rate); |
478 | if (freq <= rate) | ||
479 | return freq; | ||
480 | } | ||
481 | |||
482 | return 0; | ||
483 | } | 478 | } |
484 | 479 | ||
485 | static int m41t80_sqw_set_rate(struct clk_hw *hw, unsigned long rate, | 480 | static int m41t80_sqw_set_rate(struct clk_hw *hw, unsigned long rate, |