2 Mar 2011 06:32
[PATCH] hwmon: (pmbus) More stringent checking of VOUT_MODE register
Guenter Roeck <guenter.roeck <at> ericsson.com>
2011-03-02 05:32:20 GMT
2011-03-02 05:32:20 GMT
Some PMBus chips do not support the VOUT_MODE register. To make matters worse,
such chips may not return an error when reading the register either, but instead
return 0xff.
Check if the register exists using pmbus_check_byte_register() before reading
its value. In addition, validate the returned value and ignore it if it is 0xff
(which is invalid).
Reported-by: Greg Schnorr <gschnorr <at> cisco.com>
Signed-off-by: Guenter Roeck <guenter.roeck <at> ericsson.com>
---
drivers/hwmon/pmbus_core.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/hwmon/pmbus_core.c b/drivers/hwmon/pmbus_core.c
index 0edab1c..b7c64ba 100644
--- a/drivers/hwmon/pmbus_core.c
+++ b/drivers/hwmon/pmbus_core.c
<at> <at> -1426,10 +1426,11 <at> <at> static void pmbus_find_attributes(struct i2c_client *client,
static int pmbus_identify_common(struct i2c_client *client,
struct pmbus_data *data)
{
- int vout_mode, exponent;
+ int vout_mode = -1, exponent;
- vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE);
- if (vout_mode >= 0) {
+ if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE))
+ vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE);
+ if (vout_mode >= 0 && vout_mode != 0xff) {
(Continue reading)
RSS Feed