From: Guenter Roeck <linux@roeck-us.net>
To: Erik Schumacher <erik.schumacher@iris-sensing.com>
Cc: "linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jdelvare@suse.com" <jdelvare@suse.com>
Subject: Re: [PATCH] hwmon: (ad7314) Validate leading zero bit and return error
Date: Thu, 20 Feb 2025 14:22:29 -0800 [thread overview]
Message-ID: <7f299e75-a4c5-45c8-a755-e0365f8c7e2e@roeck-us.net> (raw)
In-Reply-To: <c54ef4dd7b562268768200239b00441a74b547c3.camel@iris-sensing.com>
On Thu, Feb 20, 2025 at 10:18:17AM +0000, Erik Schumacher wrote:
> A leading zero bit is sent on the bus before the temperature value is
> transmitted. If this bit is high, the connection might be unstable or it
> could mean that no AD7314 (or compatible) is connected on the bus.
> Return -ENXIO in that case.
>
> Signed-off-by: Erik Schumacher <erik.schumacher@iris-sensing.com>
> ---
> drivers/hwmon/ad7314.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/hwmon/ad7314.c b/drivers/hwmon/ad7314.c
> index 7802bbf5f958..025846f1f18b 100644
> --- a/drivers/hwmon/ad7314.c
> +++ b/drivers/hwmon/ad7314.c
> @@ -65,6 +65,10 @@ static ssize_t ad7314_temperature_show(struct device *dev,
> return ret;
> switch (spi_get_device_id(chip->spi_dev)->driver_data) {
> case ad7314:
> + if (ret & BIT(15)) {
> + /* Invalid read-out, leading zero bit is missing */
> + return -ENXIO;
ENXIO = No such device or address
We don't know if that is the case. -EIO seems more appropriate.
Also, AD7301 and AD7302 transmit two leading zeros. If we make this change
for one of the chips supported by the driver, we should make it for all
chips.
Thanks,
Guenter
prev parent reply other threads:[~2025-02-20 22:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 10:18 Erik Schumacher
2025-02-20 22:22 ` Guenter Roeck [this message]
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=7f299e75-a4c5-45c8-a755-e0365f8c7e2e@roeck-us.net \
--to=linux@roeck-us.net \
--cc=erik.schumacher@iris-sensing.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®