Re: [PATCH] NFC: trf7970a: disable all regulators on removal

From: Krzysztof Kozlowski
Date: Thu Apr 18 2024 - 13:07:14 EST


On 18/04/2024 10:12, Paul Geurts wrote:
> On 17-04-2024 15:15, Krzysztof Kozlowski wrote:
>> On 16/04/2024 22:28, Paul Geurts wrote:
>>> During module probe, regulator 'vin' and 'vdd-io' are used and enabled,
>>> but the vdd-io regulator overwrites the 'vin' regulator pointer. During
>>> remove, only the vdd-io is disabled, as the vin regulator pointer is not
>>> available anymore. When regulator_put() is called during resource
>>> cleanup a kernel warning is given, as the regulator is still enabled.
>>>
>>> Store the two regulators in separate pointers and disable both the
>>> regulators on module remove.
>>>
>>> Fixes: 49d22c70aaf0 ("NFC: trf7970a: Add device tree option of 1.8 Volt IO voltage")
>>>
>>> Signed-off-by: Paul Geurts <paul_geurts@xxxxxxx>
>> No blank lines between tags. Please look at existing commits (git log).
> Will fix this, thanks
>>
>>> ---
>>> drivers/nfc/trf7970a.c | 42 +++++++++++++++++++++++-------------------
>>> 1 file changed, 23 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/drivers/nfc/trf7970a.c b/drivers/nfc/trf7970a.c
>>> index 7eb17f46a815..9e1a34e23af2 100644
>>> --- a/drivers/nfc/trf7970a.c
>>> +++ b/drivers/nfc/trf7970a.c
>>> @@ -424,7 +424,8 @@ struct trf7970a {
>>> enum trf7970a_state state;
>>> struct device *dev;
>>> struct spi_device *spi;
>>> - struct regulator *regulator;
>>> + struct regulator *vin_regulator;
>>> + struct regulator *vddio_regulator;
>>> struct nfc_digital_dev *ddev;
>>> u32 quirks;
>>> bool is_initiator;
>>> @@ -1883,7 +1884,7 @@ static int trf7970a_power_up(struct trf7970a *trf)
>>> if (trf->state != TRF7970A_ST_PWR_OFF)
>>> return 0;
>>>
>>> - ret = regulator_enable(trf->regulator);
>>> + ret = regulator_enable(trf->vin_regulator);
>> That does not look like equivalent code. Previously this was vddio, right?
> This is part of the original issue created by 49d22c70aaf0. This should be the VIN regulator, but the pointer override made it VDD-IO.

True, good point.


Reviewed-by: Krzysztof Kozlowski <krzk@xxxxxxxxxx>

Best regards,
Krzysztof