@@ -84,9 +84,17 @@ static void sample_timer(struct timer_list *t)
mod_timer(&ctx->rpm_timer, jiffies + HZ);
}
-static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
+static int pwm_fan_enable_pwm(struct pwm_fan_ctx *ctx)
{
struct pwm_state state;
+
+ pwm_get_state(ctx->pwm, &state);
+ state.enabled = true;
+ return pwm_apply_state(ctx->pwm, &state);
+}
+
+static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
+{
int ret;
if (ctx->enabled)
@@ -98,9 +106,7 @@ static int pwm_fan_power_on(struct pwm_fan_ctx *ctx)
return ret;
}
- pwm_get_state(ctx->pwm, &state);
- state.enabled = true;
- ret = pwm_apply_state(ctx->pwm, &state);
+ ret = pwm_fan_enable_pwm(ctx);
if (ret) {
dev_err(ctx->dev, "failed to enable PWM\n");
goto disable_regulator;
This allows reusage in other code paths. Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> --- drivers/hwmon/pwm-fan.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)