summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
34e7dc6)
The LM85 and compatible chips only support 8 arbitrary PWM frequencies.
The algorithm to pick one of them based on the user input is not
optimum. Improve it to always pick the closest supported frequency.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Herbert Poetzl <herbert@13thfloor.at>
- if (freq >= lm85_freq_map[7])
- return 7;
+ /* Find the closest match */
- if (freq <= lm85_freq_map[i])
+ if (freq <= (lm85_freq_map[i] + lm85_freq_map[i + 1]) / 2)