On Fri, Apr 26, 2024 at 04:13:22PM +0200, Lars Petter Mostad wrote: > Decode all diode data low byte registers. > All ? > Signed-off-by: Lars Petter Mostad <lars.petter.mostad@xxxxxxxxxx> > --- > drivers/hwmon/emc1403.c | 34 ++++++++++++++++++++++++++++++++-- > 1 file changed, 32 insertions(+), 2 deletions(-) > > > base-commit: e723f6ca39fb54ae31f79b5af74fe8496308d4de > > diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c > index d370efd6f986..2b14db802f96 100644 > --- a/drivers/hwmon/emc1403.c > +++ b/drivers/hwmon/emc1403.c > @@ -37,13 +37,43 @@ static ssize_t temp_show(struct device *dev, struct device_attribute *attr, > { > struct sensor_device_attribute *sda = to_sensor_dev_attr(attr); > struct thermal_data *data = dev_get_drvdata(dev); > - unsigned int val; > + unsigned int val, val_lowbyte; FWIW, this is wrong. The upper bit of the high byte is a sign bit on emc1438. > int retval; > + int idx_lowbyte; > + > + switch (sda->index) { > + case 0x00: > + idx_lowbyte = 0x29; > + break; > + case 0x01: > + idx_lowbyte = 0x10; > + break; > + case 0x23: > + case 0x2a: > + case 0x41: > + case 0x43: > + case 0x45: > + case 0x47: > + idx_lowbyte = sda->index + 1; > + break; What about the following ? 2c -> 2e 2d -> 2f > + default: > + idx_lowbyte = 0; > + } > > retval = regmap_read(data->regmap, sda->index, &val); > if (retval < 0) > return retval; > - return sprintf(buf, "%d000\n", val); > + > + if (idx_lowbyte) { > + retval = regmap_read(data->regmap, idx_lowbyte, &val_lowbyte); > + if (retval < 0) > + val_lowbyte = 0; This is an error and should be handled, not ignored. > + } else { > + val_lowbyte = 0; > + } > + > + return sprintf(buf, "%d\n", > + (((val << 8) | val_lowbyte) * (u32)1000) >> 8); The u32 typecast is unnecessary and would interfer with negative temperatures. Guenter