diff options
author | Ludovic Desroches <ludovic.desroches@microchip.com> | 2017-11-17 14:50:21 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-11-29 22:30:50 -0500 |
commit | eb1ed2b19befecdfeddb394e6174bb2198f2a49b (patch) | |
tree | 58560355cd9e0e35c69b1fb7f3f1d0df7d9361f9 /drivers/clk/at91 | |
parent | 9e0eb01239a3d6d191ed62e9261232f792c42cdf (diff) | |
download | u-boot-eb1ed2b19befecdfeddb394e6174bb2198f2a49b.zip u-boot-eb1ed2b19befecdfeddb394e6174bb2198f2a49b.tar.gz u-boot-eb1ed2b19befecdfeddb394e6174bb2198f2a49b.tar.bz2 |
clk: at91: clk-generated: select absolute closest rate
To get the same behavior as the Linux driver, instead of selecting
the closest inferior rate, select the closest inferior or superior
rate
Signed-off-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Wenyou Yang <wenyou.yang@microchip.com>
Diffstat (limited to 'drivers/clk/at91')
-rw-r--r-- | drivers/clk/at91/clk-generated.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/clk/at91/clk-generated.c b/drivers/clk/at91/clk-generated.c index 8c9a3cb..461b5b2 100644 --- a/drivers/clk/at91/clk-generated.c +++ b/drivers/clk/at91/clk-generated.c @@ -98,9 +98,7 @@ static ulong generic_clk_set_rate(struct clk *clk, ulong rate) for (div = 1; div < GENERATED_MAX_DIV + 2; div++) { tmp_rate = DIV_ROUND_CLOSEST(parent_rate, div); - if (rate < tmp_rate) - continue; - tmp_diff = rate - tmp_rate; + tmp_diff = abs(rate - tmp_rate); if (best_diff < 0 || best_diff > tmp_diff) { best_rate = tmp_rate; |