Skip to content

Commit 0429415

Browse files
Florin Leotescugroeck
authored andcommitted
hwmon: (emc2305) Set initial PWM minimum value during probe based on thermal state
Prevent the PWM value from being set to minimum when thermal zone temperature exceeds any trip point during driver probe. Otherwise, the PWM fan speed will remains at minimum speed and not respond to temperature changes. Signed-off-by: Florin Leotescu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]>
1 parent ef8b1b4 commit 0429415

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/hwmon/emc2305.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ static int emc2305_set_single_tz(struct device *dev, struct device_node *fan_nod
317317
dev_err(dev, "Failed to register cooling device %s\n", emc2305_fan_name[idx]);
318318
return PTR_ERR(data->cdev_data[cdev_idx].cdev);
319319
}
320+
321+
if (data->cdev_data[cdev_idx].cur_state > 0)
322+
/* Update pwm when temperature is above trips */
323+
pwm = EMC2305_PWM_STATE2DUTY(data->cdev_data[cdev_idx].cur_state,
324+
data->max_state, EMC2305_FAN_MAX);
325+
320326
/* Set minimal PWM speed. */
321327
if (data->pwm_separate) {
322328
ret = emc2305_set_pwm(dev, pwm, cdev_idx);
@@ -330,10 +336,10 @@ static int emc2305_set_single_tz(struct device *dev, struct device_node *fan_nod
330336
}
331337
}
332338
data->cdev_data[cdev_idx].cur_state =
333-
EMC2305_PWM_DUTY2STATE(data->pwm_min[cdev_idx], data->max_state,
339+
EMC2305_PWM_DUTY2STATE(pwm, data->max_state,
334340
EMC2305_FAN_MAX);
335341
data->cdev_data[cdev_idx].last_hwmon_state =
336-
EMC2305_PWM_DUTY2STATE(data->pwm_min[cdev_idx], data->max_state,
342+
EMC2305_PWM_DUTY2STATE(pwm, data->max_state,
337343
EMC2305_FAN_MAX);
338344
return 0;
339345
}

0 commit comments

Comments
 (0)