From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH 1/1] lm73: detect i2c bus errors before scnprintf()
Date: Sat, 22 Dec 2012 01:30:56 +0000 [thread overview]
Message-ID: <20121222013056.GA2068@roeck-us.net> (raw)
In-Reply-To: <1356083914-17579-1-git-send-email-kg4ysn@gmail.com>
On Fri, Dec 21, 2012 at 01:58:34AM -0800, Chris Verges wrote:
> If an LM73 device does not exist on an I2C bus, attempts to communicate
> with the device result in an error code returned from the i2c read/write
> functions. The current lm73 driver casts that return value from a s32
> type to a s16 type, then converts it to a temperature in celsius.
> Because negative temperatures are valid, it is difficult to distinguish
> between an error code printed to the response buffer and a negative
> temperature recorded by the sensor.
>
> The solution is to evaluate the return value from the i2c functions
> before performing any temperature calculations. If the i2c function did
> not succeed, the error code should be passed back through the virtual
> file system layer instead of being printed into the response buffer.
>
> Before:
>
> $ cat /sys/class/hwmon/hwmon0/device/temp1_input
> -46
>
> After:
>
> $ cat /sys/class/hwmon/hwmon0/device/temp1_input
> cat: read error: No such device or address
>
> Signed-off-by: Chris Verges <kg4ysn@gmail.com>
Applied.
Just wondering - how comes the detect function did not report the error ?
Thanks,
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2012-12-22 1:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-21 9:58 [lm-sensors] [PATCH 1/1] lm73: detect i2c bus errors before scnprintf() Chris Verges
2012-12-22 1:30 ` Guenter Roeck [this message]
2012-12-22 1:37 ` Chris Verges
2012-12-22 6:59 ` Guenter Roeck
2012-12-22 7:37 ` Chris Verges
2012-12-22 11:07 ` Guenter Roeck
2012-12-22 21:48 ` Chris Verges
2012-12-22 22:59 ` 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=20121222013056.GA2068@roeck-us.net \
--to=linux@roeck-us.net \
--cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.