Decode all diode data low byte registers. Signed-off-by: Lars Petter Mostad <lars.petter.mostad@xxxxxxxxxx> --- drivers/hwmon/emc1403.c | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) 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; 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; + 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; + } else { + val_lowbyte = 0; + } + + return sprintf(buf, "%d\n", + (((val << 8) | val_lowbyte) * (u32)1000) >> 8); } static ssize_t bit_show(struct device *dev, struct device_attribute *attr, base-commit: e723f6ca39fb54ae31f79b5af74fe8496308d4de -- 2.44.0