From: Lars Petter Mostad <larspm@gmail.com>
To: jdelvare@suse.com, linux@roeck-us.net, linux-hwmon@vger.kernel.org
Cc: Lars Petter Mostad <lars.petter.mostad@appear.net>
Subject: [PATCH] hwmon: (emc1403) Decode fractional temperatures.
Date: Fri, 26 Apr 2024 16:13:22 +0200 [thread overview]
Message-ID: <20240426141322.609642-1-lars.petter.mostad@appear.net> (raw)
Decode all diode data low byte registers.
Signed-off-by: Lars Petter Mostad <lars.petter.mostad@appear.net>
---
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
next reply other threads:[~2024-04-26 14:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-26 14:13 Lars Petter Mostad [this message]
2024-04-28 18:00 ` [PATCH] hwmon: (emc1403) Decode fractional temperatures Guenter Roeck
2024-04-28 18:07 ` Guenter Roeck
2024-04-30 11:11 ` Lars Petter Mostad
2024-04-30 15:37 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240426141322.609642-1-lars.petter.mostad@appear.net \
--to=larspm@gmail.com \
--cc=jdelvare@suse.com \
--cc=lars.petter.mostad@appear.net \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).