arm: allwinner: clk: Fix nm_recalc
When comparing best frequencies use the absolute value. If we do not do that we end up choosing an always lower value than the best one if the exact freq cannot be met. MFC after: 2 weeks
This commit is contained in:
parent
0eb97cca9f
commit
34f71e304e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=345711
@ -155,7 +155,7 @@ aw_clk_nm_find_best(struct aw_clk_nm_sc *sc, uint64_t fparent, uint64_t *fout,
|
||||
for (m = min_m; m <= max_m; ) {
|
||||
for (n = min_m; n <= max_n; ) {
|
||||
cur = fparent / n / m;
|
||||
if ((*fout - cur) < (*fout - best)) {
|
||||
if (abs(*fout - cur) < abs(*fout - best)) {
|
||||
best = cur;
|
||||
*factor_n = n;
|
||||
*factor_m = m;
|
||||
|
Loading…
Reference in New Issue
Block a user