public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Doug Anderson <dianders@chromium.org>
Cc: Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] regulator: Only enable disabled regulators on resume
Date: Wed, 04 Mar 2015 14:45:00 +0100	[thread overview]
Message-ID: <54F70C5C.4080201@collabora.co.uk> (raw)
In-Reply-To: <54F60602.3030505@collabora.co.uk>

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, &regulator_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

  reply	other threads:[~2015-03-04 13:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-02 20:40 [PATCH 1/1] regulator: Only enable disabled regulators on resume Javier Martinez Canillas
2015-03-03 17:24 ` Doug Anderson
2015-03-03 19:05   ` Javier Martinez Canillas
2015-03-04 13:45     ` Javier Martinez Canillas [this message]
2015-03-08 19:38       ` Mark Brown
2015-03-09  7:40         ` Javier Martinez Canillas
2015-03-11 10:57           ` Mark Brown
2015-03-11 11:00             ` Javier Martinez Canillas
2015-03-08 19:38 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54F70C5C.4080201@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=broonie@kernel.org \
    --cc=dianders@chromium.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox