Re: [PATCH v2] hwmon: pm_bus: core: Implement regulator get_status

From: Guenter Roeck
Date: Fri Nov 18 2022 - 17:07:19 EST


On Fri, Nov 18, 2022 at 08:32:26PM +0530, Naresh Solanki wrote:
> > > +
> > > + mutex_lock(&data->update_lock);
> > > + status = pmbus_get_status(client, page, PMBUS_STATUS_WORD);
> > > + mutex_unlock(&data->update_lock);
> >
> > I do not see the point of this lock here and elsewhere in this function.
> > If you want to ensure that the status is consistent, you would need to
> > hold the lock over the entire function, not repeatedly acquire and release
> > it. Even then there would be no guarantee that the status is consistent
> > because it can change anytime on the chip side.
> Will hold the lock till end of function. Agree that chip side, status may
> change any moment.
>
> With this I got a question i.e., what should regulator status be reported if
> regulator had previously encountered some fault but currently while reading
> the status found that pgood bit indicate output power is good.
> Should we continue to still report historical fault or instead report
> current regulator output status based on pgood ?
>
> IMHO, it should report regulator status as ON if pgood bit is clear(i.e.,
> output is good) & leave previously encountered error reporting to
> get_error_flag function.
>
> I need your Suggestion here.
>
That is really a question for the regulator subsystem. Personally I think
the current status should be reported, but that is just me.

Guenter