public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: Joonyoung Shim <jy0922.shim@samsung.com>
Cc: lrg@slimlogic.co.uk, kyungmin.park@samsung.com,
	mk7.kang@samsung.com, linux-kernel@vger.kernel.org
Subject: Re: The use_count problem of regulator
Date: Wed, 20 Jan 2010 10:35:00 +0000	[thread overview]
Message-ID: <20100120103500.GC2657@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <4B56A300.7000907@samsung.com>

On Wed, Jan 20, 2010 at 03:30:24PM +0900, Joonyoung Shim wrote:

> In the regulator framework, if the regulator is enabled for example by 
> boot_on constraint, when regulator_get is called at the driver probe 
> function, the use_count of struct regulator_dev is zero. But if 
> regulator_has_full_constraints() is used, even though above the 
> regulator is using, it is disabled by regulator_init_complete() because
> the use_count is zero.

This is expected behaviour if the regulator is not marked as always_on.
The idea is that the regulators will have been claimed and enabled by a
regulator consumer during the init process, and if it hasn't then it's
not in active use at the current time and may therefore be powered off.

> Of course, we can use regulator_get_exclusive instead of regulator_get,
> but if the regulator can be shared, i think this will be a problem.

If the consumer is using the regulator then it should enable the
regulator without reference to the existing state of the regulator.
This is required to support sharing of supplies - if another consumer
enabled the regulator then it may later decide to turn it off when it's
done with it, which would have the same effect as you're seeing from the
full constraints code.

A consumer using regulator_get() should in general never need to check
if the regulator is enabled except possibly during startup in order to
gracefully handle the handover of the initial hardware state.  Normally
they should call enable() when they start using the device and disable() 
when they stop.

      reply	other threads:[~2010-01-20 10:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20  6:30 The use_count problem of regulator Joonyoung Shim
2010-01-20 10:35 ` Mark Brown [this message]

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=20100120103500.GC2657@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=jy0922.shim@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=mk7.kang@samsung.com \
    /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