diff options
author | Frans Klaver <fransklaver@gmail.com> | 2014-10-22 15:12:42 -0400 |
---|---|---|
committer | Darren Hart <dvhart@linux.intel.com> | 2014-11-19 12:07:08 -0500 |
commit | 148a5dd5ccc25581b44a38079128f49e47353713 (patch) | |
tree | 7ec112b7ade095e09a0eb402c58be91f0d72a4d4 /drivers/platform | |
parent | a5de681c0cf7350fa13ccd67f1a118f1651cc2d5 (diff) |
eeepc-laptop: document fan_pwm conversions
eeepc_get_fan_pwm and eeepc_set_fan_pwm convert the PWM value read from
the fan to a range lmsensors understands. Unfortunately this is only
clear if you are familiar with how lmsensors handles duty cycles.
Introduce two conversion functions that document the goal of these
conversions.
Signed-off-by: Frans Klaver <fransklaver@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/eeepc-laptop.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index c1758ec3c61b..e87c1346e1d4 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -980,18 +980,28 @@ static struct platform_driver platform_driver = { | |||
980 | #define EEEPC_EC_SFB0 0xD0 | 980 | #define EEEPC_EC_SFB0 0xD0 |
981 | #define EEEPC_EC_FAN_CTRL (EEEPC_EC_SFB0 + 3) /* Byte containing SF25 */ | 981 | #define EEEPC_EC_FAN_CTRL (EEEPC_EC_SFB0 + 3) /* Byte containing SF25 */ |
982 | 982 | ||
983 | static inline int eeepc_pwm_to_lmsensors(int value) | ||
984 | { | ||
985 | return value * 255 / 100; | ||
986 | } | ||
987 | |||
988 | static inline int eeepc_lmsensors_to_pwm(int value) | ||
989 | { | ||
990 | value = clamp_val(value, 0, 255); | ||
991 | return value * 100 / 255; | ||
992 | } | ||
993 | |||
983 | static int eeepc_get_fan_pwm(void) | 994 | static int eeepc_get_fan_pwm(void) |
984 | { | 995 | { |
985 | u8 value = 0; | 996 | u8 value = 0; |
986 | 997 | ||
987 | ec_read(EEEPC_EC_FAN_PWM, &value); | 998 | ec_read(EEEPC_EC_FAN_PWM, &value); |
988 | return value * 255 / 100; | 999 | return eeepc_pwm_to_lmsensors(value); |
989 | } | 1000 | } |
990 | 1001 | ||
991 | static void eeepc_set_fan_pwm(int value) | 1002 | static void eeepc_set_fan_pwm(int value) |
992 | { | 1003 | { |
993 | value = clamp_val(value, 0, 255); | 1004 | value = eeepc_lmsensors_to_pwm(value); |
994 | value = value * 100 / 255; | ||
995 | ec_write(EEEPC_EC_FAN_PWM, value); | 1005 | ec_write(EEEPC_EC_FAN_PWM, value); |
996 | } | 1006 | } |
997 | 1007 | ||