Re: [PATCH 2/2] hwmon: (emc2305) fix pwm never being able to set lower

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

 



On 12/5/22 09:36, Xingjiang Qiao wrote:
There are fields 'last_hwmon_state' and 'last_thermal_state' in the
structure 'emc2305_cdev_data', which respectively store the cooling state
set by the 'hwmon' and 'thermal' subsystem, and the driver author hopes
that if the state set by 'hwmon' is lower than the value set by 'thermal',
the driver will just save it without actually setting the pwm. Currently,
the 'last_thermal_state' also be updated by 'hwmon', which will cause the
cooling state to never be set to a lower value. This patch fixes that.

Signed-off-by: Xingjiang Qiao <nanpuyue@xxxxxxxxx>
---
  drivers/hwmon/emc2305.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/hwmon/emc2305.c b/drivers/hwmon/emc2305.c
index 4df84065cbfb..f51760f8aa85 100644
--- a/drivers/hwmon/emc2305.c
+++ b/drivers/hwmon/emc2305.c
@@ -398,11 +398,9 @@ emc2305_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, int ch
  				 * Update PWM only in case requested state is not less than the
  				 * last thermal state.
  				 */
-				if (data->cdev_data[cdev_idx].last_hwmon_state >=
+				if (data->cdev_data[cdev_idx].last_hwmon_state <
  				    data->cdev_data[cdev_idx].last_thermal_state)
-					return emc2305_set_cur_state(data->cdev_data[cdev_idx].cdev,
-							data->cdev_data[cdev_idx].last_hwmon_state);
-				return 0;
+					return 0;
  			}
  			return emc2305_set_pwm(dev, val, channel);

This would bypass the thermal code, leaving the thermal subsystem unaware
of the current state. I am not entirely sure what the best solution is.
Skipping the entire thermal code in that situation doesn't seem the be
correct. Maybe there needs to be a shim function for the thermal code to
only update last_thermal_state if the request was indeed made by the thermal
subsystem.

Guenter




[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