Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (pwm-fan) Update the duty cycle inorder to control the pwm-fan

pwm_config() must be called with a duty cycle of 0 prior to calling
pwm_disable() to ensure that the pwm signal is set to low.

Reported-by: Markus Reichl <m.reichl@fivetechno.de>
Tested-by: Markus Reichl <m.reichl@fivetechno.de>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
Reviewed-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Anand Moon and committed by
Guenter Roeck
f354169e f83a9cb6

+3 -6
+3 -6
drivers/hwmon/pwm-fan.c
··· 47 47 if (ctx->pwm_value == pwm) 48 48 goto exit_set_pwm_err; 49 49 50 - if (pwm == 0) { 51 - pwm_disable(ctx->pwm); 52 - goto exit_set_pwm; 53 - } 54 - 55 50 duty = DIV_ROUND_UP(pwm * (ctx->pwm->period - 1), MAX_PWM); 56 51 ret = pwm_config(ctx->pwm, duty, ctx->pwm->period); 57 52 if (ret) 58 53 goto exit_set_pwm_err; 54 + 55 + if (pwm == 0) 56 + pwm_disable(ctx->pwm); 59 57 60 58 if (ctx->pwm_value == 0) { 61 59 ret = pwm_enable(ctx->pwm); ··· 61 63 goto exit_set_pwm_err; 62 64 } 63 65 64 - exit_set_pwm: 65 66 ctx->pwm_value = pwm; 66 67 exit_set_pwm_err: 67 68 mutex_unlock(&ctx->lock);