[PATCH linux dev-4.10 3/3] hwmon: pmbus: core: One-shot retries for failure to set page
Matt Spinler
mspinler at linux.vnet.ibm.com
Fri Oct 27 07:58:36 AEDT 2017
Reviewed-by: Matt Spinler mspinler at linux.vnet.ibm.com
On 10/26/2017 1:19 AM, Andrew Jeffery wrote:
> 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).
>
> Cc: Eddie James <eajames at linux.vnet.ibm.com>
> Cc: Matt Spinler <mspinler at linux.vnet.ibm.com>
> Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
> ---
> drivers/hwmon/pmbus/pmbus_core.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> 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;
More information about the openbmc
mailing list