Re: [PATCH] hwmon: Conditionally clear individual status bits for pmbus rev >= 1.2

From: Guenter Roeck
Date: Mon Sep 09 2024 - 12:55:07 EST


On Mon, Sep 09, 2024 at 11:30:28AM +0200, Patryk Biel wrote:
> This change adds fetching PMBus revision and using it to conditionally
> clear individual status bits while calling pmbus_show_boolean, only if
> the device is compliant with PMBus specs >= 1.2.
>
> Signed-off-by: Patryk Biel <pbiel7@xxxxxxxxx>
> ---
> Current implementation of pmbus_show_boolean assumes that all devices
> support write-back operation of status register so as to clear pending
> warning or faults. Since clearing individual bits in the status registers
> was introduced in PMBus specification 1.2, this operation may not be
> supported by some older devices, thus resulting in error while reading
> boolean attributes like e.g. temp1_max_alarm.
>
> This change adds fetching PMBus revision supported by device and
> modifies pmbus_show_boolean so that it only tries to clear individual
> status bits if the device is compilant with PMBus specs >= 1.2.
>
Most of the above should have been in the description, and "This change
adds" should be "Add ...". See the "submitting Patches" document for
rationale.

> + ret = i2c_smbus_read_byte_data(client, PMBUS_REVISION);
> + if (ret > 0)

>= 0 for consistency

> + data->revision = ret;
> +

The code needs to be be further up, ahead of clearing faults, to have the
faults cleared if the command failed.

Never mind, though, I made those changes and applied the patch (I want to
make sure this patch is upstream in v6.11 final).

Thanks,
Guenter