diff options
author | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-03-01 16:49:18 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2011-03-15 01:39:08 -0400 |
commit | 83274c68a34094bbb465589e61f91a3714f8d026 (patch) | |
tree | feeac423cf28ad6e5063f93620166a1954d1f4a6 /drivers/hwmon | |
parent | a3eeb453539d7ad9c0d8cced1e0883a6a8ed18f3 (diff) |
hwmon: (pmbus) More stringent checking of VOUT_MODE register
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@cisco.com>
Tested-by: Greg Schnorr <gschnorr@cisco.com>
Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com>
Acked-by: Greg Schnorr <gschnorr@cisco.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | 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 0edab1c9553e..b7c64ba31f4c 100644 --- a/drivers/hwmon/pmbus_core.c +++ b/drivers/hwmon/pmbus_core.c | |||
@@ -1426,10 +1426,11 @@ static void pmbus_find_attributes(struct i2c_client *client, | |||
1426 | static int pmbus_identify_common(struct i2c_client *client, | 1426 | static int pmbus_identify_common(struct i2c_client *client, |
1427 | struct pmbus_data *data) | 1427 | struct pmbus_data *data) |
1428 | { | 1428 | { |
1429 | int vout_mode, exponent; | 1429 | int vout_mode = -1, exponent; |
1430 | 1430 | ||
1431 | vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); | 1431 | if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) |
1432 | if (vout_mode >= 0) { | 1432 | vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE); |
1433 | if (vout_mode >= 0 && vout_mode != 0xff) { | ||
1433 | /* | 1434 | /* |
1434 | * Not all chips support the VOUT_MODE command, | 1435 | * Not all chips support the VOUT_MODE command, |
1435 | * so a failure to read it is not an error. | 1436 | * so a failure to read it is not an error. |