diff options
author | Vic Yang <victoryang@chromium.org> | 2012-07-09 11:05:58 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-09 19:50:21 -0700 |
commit | 80d92fd6dd0247c5473e139dcdc8b097642b64cd (patch) | |
tree | d715081f9c253aa60069f7ad0d9365aab3171ab7 /chip | |
parent | 95c999ad9ba3bc5a8ae170b52ce05db1427175c9 (diff) | |
download | chrome-ec-80d92fd6dd0247c5473e139dcdc8b097642b64cd.tar.gz |
Handle invalid parameter of fan duty cycle and keyboard backlight
If the 'percent' passed in is lower than 0, then set it to 0. If it is
higher than 100, set to 100.
BUG=chrome-os-partner:11052
TEST=Check with 'kblight', 'fanduty', and 'faninfo'.
Change-Id: If84ab12658bf136eaaf1adecc0522a977c94f98d
Reviewed-on: https://gerrit.chromium.org/gerrit/26904
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r-- | chip/lm4/pwm.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/chip/lm4/pwm.c b/chip/lm4/pwm.c index 5e7cb5248d..29b593034e 100644 --- a/chip/lm4/pwm.c +++ b/chip/lm4/pwm.c @@ -116,6 +116,11 @@ int pwm_get_keyboard_backlight(void) int pwm_set_keyboard_backlight(int percent) { + if (percent < 0) + percent = 0; + else if (percent > 100) + percent = 100; + LM4_FAN_FANCMD(FAN_CH_KBLIGHT) = ((percent * MAX_PWM + 50) / 100) << 16; return EC_SUCCESS; } @@ -219,6 +224,11 @@ int pwm_set_fan_duty(int percent) { int pwm; + if (percent < 0) + percent = 0; + else if (percent > 100) + percent = 100; + pwm = (MAX_PWM * percent) / 100; /* Move the fan to manual control */ |