mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 16:54:20 +08:00
hwmon: (lm85) Select the closest PWM frequency
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>
This commit is contained in:
parent
34e7dc6ca4
commit
86010c982d
@ -199,10 +199,9 @@ static int FREQ_TO_REG(int freq)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (freq >= lm85_freq_map[7])
|
||||
return 7;
|
||||
/* Find the closest match */
|
||||
for (i = 0; i < 7; ++i)
|
||||
if (freq <= lm85_freq_map[i])
|
||||
if (freq <= (lm85_freq_map[i] + lm85_freq_map[i + 1]) / 2)
|
||||
break;
|
||||
return i;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user