summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Jeffery <andrew@aj.id.au>2017-10-26 09:19:40 +0300
committerAndrew Jeffery <andrew@aj.id.au>2017-10-27 02:11:30 +0300
commit64929c7fd2d88ef6a9e18d6a484ddc3957a6ecab (patch)
tree7f837e5167f4a9c6811beb83f21adce64d30b219
parent7f7c032a56a1ed21ff0932d3756d6190fdcb629c (diff)
downloadlinux-64929c7fd2d88ef6a9e18d6a484ddc3957a6ecab.tar.xz
hwmon: pmbus: core: One-shot retries for failure to set page
Work around the shonky behaviour seen with the MAX31785 where we fail to set the page register in some circumstances. There's no real elegant way to do this. We can propagate the error up, but that forces us to retry the operation way up the call tree in any number of places. It also forces callers to split out pmbus_set_page() from the pmbus_{read,write}_{byte,word}_data() functions in order to differentiate between a failure to set the page and a failure to read a register (that might not exist, in which case an error is anticiptated). OpenBMC-Staging-Count: 1 Cc: Eddie James <eajames@linux.vnet.ibm.com> Cc: Matt Spinler <mspinler@linux.vnet.ibm.com> Signed-off-by: Andrew Jeffery <andrew@aj.id.au> Reviewed-by: Matt Spinler mspinler@linux.vnet.ibm.com
-rw-r--r--drivers/hwmon/pmbus/pmbus_core.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
index 390a7b02b836..d4e959bda491 100644
--- a/drivers/hwmon/pmbus/pmbus_core.c
+++ b/drivers/hwmon/pmbus/pmbus_core.c
@@ -168,7 +168,18 @@ int pmbus_set_page(struct i2c_client *client, u8 page)
return 0;
if (!(data->info->func[page] & PMBUS_PAGE_VIRTUAL)) {
+ dev_dbg(&client->dev, "Want page %u, %u cached\n", page,
+ data->currpage);
+
rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE, page);
+ if (rv) {
+ rv = i2c_smbus_write_byte_data(client, PMBUS_PAGE,
+ page);
+ dev_warn(&client->dev,
+ "Failed to set page %u, performed one-shot retry %s: %d\n",
+ page, rv ? "and failed" : "with success", rv);
+ }
+
newpage = i2c_smbus_read_byte_data(client, PMBUS_PAGE);
if (newpage != page)
return -EIO;