Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (sparx5) Fix initial reading of temperature

If the temperature is read before the internal calibration is
completed, the driver returns -EIO. Instead it should return -EAGAIN
to encourage repeating the operation.

Note (groeck): Returning -EAGAIN to userspace may result in hard loops;
some userspace code interprets -EAGAIN as request to retry immediately.
I would prefer -ENODATA, but it turns out that the thermal subsystem only
handles -EAGAIN silently, so we'll have to stick with that.

Signed-off-by: Lars Povlsen <lars.povlsen@microchip.com>
Link: https://lore.kernel.org/r/20200903134704.8949-1-lars.povlsen@microchip.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Lars Povlsen and committed by
Guenter Roeck
fcb575bf ba4f184e

+1 -1
+1 -1
drivers/hwmon/sparx5-temp.c
··· 56 56 case hwmon_temp_input: 57 57 stat = readl_relaxed(hwmon->base + TEMP_STAT); 58 58 if (!(stat & TEMP_STAT_VALID)) 59 - return -EIO; 59 + return -EAGAIN; 60 60 value = stat & TEMP_STAT_TEMP; 61 61 /* 62 62 * From register documentation: