[PATCH v3 5/6] hwmon: pwm-fan: Move PWM enable into separate function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows reusage in other code paths.

Signed-off-by: Alexander Stein <alexander.stein@xxxxxxxxxxxxxxx>
---
 drivers/hwmon/pwm-fan.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c
index 21bfd0e931ba..9ebe958cc908 100644
--- a/drivers/hwmon/pwm-fan.c
+++ b/drivers/hwmon/pwm-fan.c
@@ -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;
-- 
2.25.1




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux