Re: [PATCH 4/5] hwmon: (pmbus/core) improve handling of write protected regulators

From: Jerome Brunet
Date: Tue Oct 08 2024 - 08:45:18 EST


On Mon 23 Sep 2024 at 09:44, Guenter Roeck <linux@xxxxxxxxxxxx> wrote:

> On 9/23/24 06:21, Mark Brown wrote:
>> On Fri, Sep 20, 2024 at 06:47:05PM +0200, Jerome Brunet wrote:
>>
>>> +int pmbus_regulator_init_cb(struct regulator_dev *rdev,
>>> + struct regulator_config *config)
>>> +{
>>> + struct pmbus_data *data = config->driver_data;
>>> + struct regulation_constraints *constraints = rdev->constraints;
>>> +
>>> + if (data->flags & PMBUS_OP_PROTECTED)
>>> + constraints->valid_ops_mask &= ~REGULATOR_CHANGE_STATUS;
>>> +
>>> + if (data->flags & PMBUS_VOUT_PROTECTED)
>>> + constraints->valid_ops_mask &= ~REGULATOR_CHANGE_VOLTAGE;
>>> +
>>> + return 0;
>>> +}
>>> +EXPORT_SYMBOL_NS_GPL(pmbus_regulator_init_cb, PMBUS);
>> I'm fairly comfortable with this from a regulator point of view, modulo
>> the suggestion I posted in the other message about registering separate
>> ops. The fact that there's three combinations of ops is annoying but
>> doesn't feel too bad, though I didn't actually write it out so perhaps
>> it looks horrible. In general removing permissions is safe, and without
>> separate steps to remove write protect (which I see in your patch 5) the
>> writes wouldn't actually work anyway.
>
>
> I still consider the callback to be unnecessary, but I don't really have time
> to implement a better solution myself. If you accept the regulator patches,
> I'll have another look at the series as-is.

I'll group the regulator patches and resend to Mark, adjusted as
requested.

Guenter, should I the resend the hwmon patches here grouped with the
tps25990 series ? Or is there something you'd like me change before ?

>
> Guenter

--
Jerome