diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-10-17 17:51:13 +0200 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-10-17 17:51:13 +0200 |
commit | 86010c982db2030aad2c31f178b208964f5f6806 (patch) | |
tree | 8bc829108fd362654f950dd9b3e98667c7831c6c | |
parent | 34e7dc6ca4a663a1bb0a0a4e118426849dccd72d (diff) |
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>
-rw-r--r-- | drivers/hwmon/lm85.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/hwmon/lm85.c b/drivers/hwmon/lm85.c index 6b676df3547..c323c2b8980 100644 --- a/drivers/hwmon/lm85.c +++ b/drivers/hwmon/lm85.c @@ -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; } |