Re: [PATCH 1/1] lm73: detect i2c bus errors before scnprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>

Applied.

Just wondering - how comes the detect function did not report the error ?

Thanks,
Guenter

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux