Re: [PATCH v3] hwmon: (pmbus/core): Implement regulator get_status

From: Naresh Solanki
Date: Mon Nov 21 2022 - 06:38:51 EST


Hi Guenter,

On 20-11-2022 07:44 pm, Guenter Roeck wrote:
On Sat, Nov 19, 2022 at 07:25:16PM +0100, Naresh Solanki wrote:
From: Patrick Rudolph <patrick.rudolph@xxxxxxxxxxxxx>

Add get_status for pmbus_regulator_ops.

Changes:
- use lock throughout the function
- Avoid line continuation upto 100 column
- Optimize use of & and | operator
- Check for VOUT, IOUT, TEMPERATURE bit in status word before checking
respective status register for fault.
- Report regulator current status.

Change log should be after '---'
Sure

Also, when looking into this, I realized that we already have
pmbus_regulator_get_error_flags() which has somewhat overlapping
functionality. Would it be possible to utilize that function to get
the error status instead of more or less hand-coding it ?
Sure. But looking at get_status scope, I feel that we are already checking the following:
1. Check if regulator is off & yes then return off
2. If not off then it should be on & has power good then return on
3. If no power good then this itself is error condition so return error. Decoding status register for fault just double confirms that & may not be needed in get_status unless we are going to print or utilize the error bit information in some other way but that is out of scope of get_status call unless I missed something.

Does this approach makes sense ?

Thanks,
Guenter