mirror of
https://github.com/torvalds/linux.git
synced 2026-06-05 04:56:13 +02:00
hwmon fixes for v6.17-rc5
- ina238: Various value range fixes when writing limit attributes - mlxreg-fan: Prevent fans from getting stuck at 0 RPM -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEiHPvMQj9QTOCiqgVyx8mb86fmYEFAmi7Fo8ACgkQyx8mb86f mYG1Hg/+JniJ+6QLJ7PFADv5WCX/HBRt9LtupFENjdn6uHBWUWsUSDVMKsNy6v5j ErPE0FitAg/fNSm++Bueb2bmfYYtE4YG5gMHIgsztIGL8j6kpUrafadkELaccKQD hB9XT0RDvQ92qVjbB0qG6/7YC2s1V+p6tpW4CwKG2349YHuQl8rpzo8IMLPkU7Ex 6U/VuC6nCxKAYPwDHjKohMFoBZcu+hDnpLJqWB/wkk1ihlLVnZ10Clv8Vq4jVUn5 2HKvwwvlTfEzhZ4E9cLEgJBOKmudZNGy+N6xjMlAqXWS3yH2lF6uP8dYl8xwDIi1 2/PLpW2bp5fnZv8ZszQX1X66BWLjiRPFApOIAgeCUL/GpyLsZrB8CUpkD43dJKzw zPc7X9A0qRUuWtAfAlW81er4pwtoaJXHp+gwddkhgf1SzKQhFn4LE4DkeNRDZpIe Ig2j1ut2valRIBwNq6YOCqzf0NhSrDR8UsppmGHMt5tZzHbC78NMo0hSO7NFvEPO tUXFiKamlRGFx2QEVJvyYriFLyQp42mNisIwVMkyO+nSZ8tPiwQ/G/XMG/OvDlW6 58tM87lJQEh20A+u/HzIEbuyniyqJs3y0U0NnmxYhJqas9/9eUYVgIZxd9GWWE5l i+BallpZ2jvP36Zpei69y3vymFeWWgLnxfderATbgB0387OIWbk= =scpq -----END PGP SIGNATURE----- Merge tag 'hwmon-for-v6.17-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon fixes from Guenter Roeck: - ina238: Various value range fixes when writing limit attributes - mlxreg-fan: Prevent fans from getting stuck at 0 RPM * tag 'hwmon-for-v6.17-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (ina238) Correctly clamp power limits hwmon: (ina238) Correctly clamp shunt voltage limit hwmon: (ina238) Correctly clamp temperature hwmon: mlxreg-fan: Prevent fans from getting stuck at 0 RPM
This commit is contained in:
commit
260aa8d5f0
|
|
@ -379,7 +379,7 @@ static int ina238_write_in(struct device *dev, u32 attr, int channel,
|
|||
regval = clamp_val(val, -163, 163);
|
||||
regval = (regval * 1000 * 4) /
|
||||
(INA238_SHUNT_VOLTAGE_LSB * data->gain);
|
||||
regval = clamp_val(regval, S16_MIN, S16_MAX);
|
||||
regval = clamp_val(regval, S16_MIN, S16_MAX) & 0xffff;
|
||||
|
||||
switch (attr) {
|
||||
case hwmon_in_max:
|
||||
|
|
@ -517,9 +517,10 @@ static int ina238_write_power(struct device *dev, u32 attr, long val)
|
|||
* Unsigned postive values. Compared against the 24-bit power register,
|
||||
* lower 8-bits are truncated. Same conversion to/from uW as POWER
|
||||
* register.
|
||||
* The first clamp_val() is to establish a baseline to avoid overflows.
|
||||
*/
|
||||
regval = clamp_val(val, 0, LONG_MAX);
|
||||
regval = div_u64(val * 4 * 100 * data->rshunt, data->config->power_calculate_factor *
|
||||
regval = clamp_val(val, 0, LONG_MAX / 2);
|
||||
regval = div_u64(regval * 4 * 100 * data->rshunt, data->config->power_calculate_factor *
|
||||
1000ULL * INA238_FIXED_SHUNT * data->gain);
|
||||
regval = clamp_val(regval >> 8, 0, U16_MAX);
|
||||
|
||||
|
|
@ -572,7 +573,7 @@ static int ina238_write_temp(struct device *dev, u32 attr, long val)
|
|||
return -EOPNOTSUPP;
|
||||
|
||||
/* Signed */
|
||||
regval = clamp_val(val, -40000, 125000);
|
||||
val = clamp_val(val, -40000, 125000);
|
||||
regval = div_s64(val * 10000, data->config->temp_lsb) << data->config->temp_shift;
|
||||
regval = clamp_val(regval, S16_MIN, S16_MAX) & (0xffff << data->config->temp_shift);
|
||||
|
||||
|
|
|
|||
|
|
@ -561,15 +561,14 @@ static int mlxreg_fan_cooling_config(struct device *dev, struct mlxreg_fan *fan)
|
|||
if (!pwm->connected)
|
||||
continue;
|
||||
pwm->fan = fan;
|
||||
/* Set minimal PWM speed. */
|
||||
pwm->last_hwmon_state = MLXREG_FAN_PWM_DUTY2STATE(MLXREG_FAN_MIN_DUTY);
|
||||
pwm->cdev = devm_thermal_of_cooling_device_register(dev, NULL, mlxreg_fan_name[i],
|
||||
pwm, &mlxreg_fan_cooling_ops);
|
||||
if (IS_ERR(pwm->cdev)) {
|
||||
dev_err(dev, "Failed to register cooling device\n");
|
||||
return PTR_ERR(pwm->cdev);
|
||||
}
|
||||
|
||||
/* Set minimal PWM speed. */
|
||||
pwm->last_hwmon_state = MLXREG_FAN_PWM_DUTY2STATE(MLXREG_FAN_MIN_DUTY);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user