From: Guenter Roeck Date: Wed, 26 May 2021 15:40:16 +0000 (-0700) Subject: hwmon: (max31790) Fix fan speed reporting for fan7..12 X-Git-Tag: accepted/tizen/unified/20230118.172025~7009^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbbf244f0515af3472084f22b6213121b4a63835;p=platform%2Fkernel%2Flinux-rpi.git hwmon: (max31790) Fix fan speed reporting for fan7..12 Fans 7..12 do not have their own set of configuration registers. So far the code ignored that and read beyond the end of the configuration register range to get the tachometer period. This resulted in more or less random fan speed values for those fans. The datasheet is quite vague when it comes to defining the tachometer period for fans 7..12. Experiments confirm that the period is the same for both fans associated with a given set of configuration registers. Fixes: 54187ff9d766 ("hwmon: (max31790) Convert to use new hwmon registration API") Fixes: 195a4b4298a7 ("hwmon: Driver for Maxim MAX31790") Cc: Jan Kundrát Reviewed-by: Jan Kundrát Cc: Václav Kubernát Reviewed-by: Jan Kundrát Signed-off-by: Guenter Roeck Link: https://lore.kernel.org/r/20210526154022.3223012-2-linux@roeck-us.net --- diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c index 86e6c71..f6d4fc0 100644 --- a/drivers/hwmon/max31790.c +++ b/drivers/hwmon/max31790.c @@ -170,7 +170,7 @@ static int max31790_read_fan(struct device *dev, u32 attr, int channel, switch (attr) { case hwmon_fan_input: - sr = get_tach_period(data->fan_dynamics[channel]); + sr = get_tach_period(data->fan_dynamics[channel % NR_CHANNEL]); rpm = RPM_FROM_REG(data->tach[channel], sr); *val = rpm; return 0;