[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <54F70C5C.4080201@collabora.co.uk>
Date: Wed, 04 Mar 2015 14:45:00 +0100
From: Javier Martinez Canillas <javier.martinez@...labora.co.uk>
To: Doug Anderson <dianders@...omium.org>
CC: Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/1] regulator: Only enable disabled regulators on resume
Hello Doug,
On 03/03/2015 08:05 PM, Javier Martinez Canillas wrote:
> On 03/03/2015 06:24 PM, Doug Anderson wrote:
>>>
>>> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
>>> index f2452148c8da..8551400d57e4 100644
>>> --- a/drivers/regulator/core.c
>>> +++ b/drivers/regulator/core.c
>>> @@ -3816,9 +3816,11 @@ int regulator_suspend_finish(void)
>>> list_for_each_entry(rdev, ®ulator_list, list) {
>>> mutex_lock(&rdev->mutex);
>>> if (rdev->use_count > 0 || rdev->constraints->always_on) {
>>> - error = _regulator_do_enable(rdev);
>>> - if (error)
>>> - ret = error;
>>> + if (!_regulator_is_enabled(rdev)) {
>>
>> Looking at _regulator_enable() I see that _regulator_is_enabled()
>> could return an error. Should we be checking? Maybe we should have a
>> helper function called by both callers?
>>
>
> Thanks for pointing that out. I'll change it on v2 as well.
>
Looking at the code now I remember why I didn't checked for an error
in _regulator_is_enable(), sorry I wrote the patch months ago.
The thing is that _regulator_is_enabled() used to return -EINVAL if
the rdev didn't have an .is_enabled callback but that changed in
commit 9a7f6a4c6edc8 ("regulator: Assume regulators are enabled if
they don't report anything") and now returns 1 in that case. But
_regulator_enable() was not changed and is still checking for -EINVAL
which seems to me like a left over after the mentioned commit.
Also, _regulator_enable() is the only place that has a check for a
negative errno value returned by _regulator_is_enabled().
All other functions calling _regulator_is_enabled() seems to assume
that a return value != 0 means that the regulator is enabled.
Is true though that the rdev .is_enabled callback function may return
an error so I don't know if all those callers are missing a check or
if it's a design decision to assume that a regulator should be enabled
if the actual hardware state can't be obtained.
Best regards,
Javier
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists