]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/hwmon/mlxreg-fan.c
Merge tag 'riscv-for-linus-5.15-rc5' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-jammy-kernel.git] / drivers / hwmon / mlxreg-fan.c
index 116681fde33d2de2aeea021f3edc10e921e76eb5..89fe7b9fe26be3e837f879b2dad1a97fba6de9ea 100644 (file)
@@ -315,8 +315,8 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev,
 {
        struct mlxreg_fan *fan = cdev->devdata;
        unsigned long cur_state;
+       int i, config = 0;
        u32 regval;
-       int i;
        int err;
 
        /*
@@ -329,6 +329,12 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev,
         * overwritten.
         */
        if (state >= MLXREG_FAN_SPEED_MIN && state <= MLXREG_FAN_SPEED_MAX) {
+               /*
+                * This is configuration change, which is only supported through sysfs.
+                * For configuration non-zero value is to be returned to avoid thermal
+                * statistics update.
+                */
+               config = 1;
                state -= MLXREG_FAN_MAX_STATE;
                for (i = 0; i < state; i++)
                        fan->cooling_levels[i] = state;
@@ -343,7 +349,7 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev,
 
                cur_state = MLXREG_FAN_PWM_DUTY2STATE(regval);
                if (state < cur_state)
-                       return 0;
+                       return config;
 
                state = cur_state;
        }
@@ -359,7 +365,7 @@ static int mlxreg_fan_set_cur_state(struct thermal_cooling_device *cdev,
                dev_err(fan->dev, "Failed to write PWM duty\n");
                return err;
        }
-       return 0;
+       return config;
 }
 
 static const struct thermal_cooling_device_ops mlxreg_fan_cooling_ops = {