Commit 148a5dd5 authored by Frans Klaver's avatar Frans Klaver Committed by Darren Hart

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: default avatarFrans Klaver <fransklaver@gmail.com>
Signed-off-by: default avatarDarren Hart <dvhart@linux.intel.com>
parent a5de681c
...@@ -980,18 +980,28 @@ static struct platform_driver platform_driver = { ...@@ -980,18 +980,28 @@ static struct platform_driver platform_driver = {
#define EEEPC_EC_SFB0 0xD0 #define EEEPC_EC_SFB0 0xD0
#define EEEPC_EC_FAN_CTRL (EEEPC_EC_SFB0 + 3) /* Byte containing SF25 */ #define EEEPC_EC_FAN_CTRL (EEEPC_EC_SFB0 + 3) /* Byte containing SF25 */
static inline int eeepc_pwm_to_lmsensors(int value)
{
return value * 255 / 100;
}
static inline int eeepc_lmsensors_to_pwm(int value)
{
value = clamp_val(value, 0, 255);
return value * 100 / 255;
}
static int eeepc_get_fan_pwm(void) static int eeepc_get_fan_pwm(void)
{ {
u8 value = 0; u8 value = 0;
ec_read(EEEPC_EC_FAN_PWM, &value); ec_read(EEEPC_EC_FAN_PWM, &value);
return value * 255 / 100; return eeepc_pwm_to_lmsensors(value);
} }
static void eeepc_set_fan_pwm(int value) static void eeepc_set_fan_pwm(int value)
{ {
value = clamp_val(value, 0, 255); value = eeepc_lmsensors_to_pwm(value);
value = value * 100 / 255;
ec_write(EEEPC_EC_FAN_PWM, value); ec_write(EEEPC_EC_FAN_PWM, value);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment