* [PATCH] regulator: core: export function to check if regulator always on
@ 2014-11-12 11:18 Richard Fitzgerald
2014-11-12 11:35 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Richard Fitzgerald @ 2014-11-12 11:18 UTC (permalink / raw)
To: broonie; +Cc: lgirdwood, linux-kernel, patches
Export a function to allow a consumer to check if its supply
regulator is always on. Drivers might wish to take different
action based on this - for example skipping time-consuming
power-saving preparations that are irrelevant if the regulator
cannot be disabled.
Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
---
drivers/regulator/core.c | 16 ++++++++++++++++
include/linux/regulator/consumer.h | 6 ++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index cd87c0c..e93db90 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2184,6 +2184,22 @@ int regulator_is_enabled(struct regulator *regulator)
EXPORT_SYMBOL_GPL(regulator_is_enabled);
/**
+ * regulator_is_always_on - check if regulator is always on
+ * @regulator: regulator source
+ *
+ * Returns positive if the regulator driver backing the source/client
+ * is always on, false otherwise.
+ */
+int regulator_is_always_on(struct regulator *regulator)
+{
+ if (regulator->always_on)
+ return 1;
+ else
+ return 0;
+}
+EXPORT_SYMBOL_GPL(regulator_is_always_on);
+
+/**
* regulator_can_change_voltage - check if regulator can change voltage
* @regulator: regulator source
*
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index f540b14..bd6daef 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -217,6 +217,7 @@ int regulator_bulk_force_disable(int num_consumers,
void regulator_bulk_free(int num_consumers,
struct regulator_bulk_data *consumers);
+int regulator_is_always_on(struct regulator *regulator);
int regulator_can_change_voltage(struct regulator *regulator);
int regulator_count_voltages(struct regulator *regulator);
int regulator_list_voltage(struct regulator *regulator, unsigned selector);
@@ -425,6 +426,11 @@ static inline void regulator_bulk_free(int num_consumers,
{
}
+static inline int regulator_is_always_on(struct regulator *regulator)
+{
+ return 1;
+}
+
static inline int regulator_can_change_voltage(struct regulator *regulator)
{
return 0;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: core: export function to check if regulator always on
2014-11-12 11:18 [PATCH] regulator: core: export function to check if regulator always on Richard Fitzgerald
@ 2014-11-12 11:35 ` Mark Brown
2014-11-12 13:07 ` Richard Fitzgerald
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2014-11-12 11:35 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: lgirdwood, linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 815 bytes --]
On Wed, Nov 12, 2014 at 11:18:35AM +0000, Richard Fitzgerald wrote:
> Export a function to allow a consumer to check if its supply
> regulator is always on. Drivers might wish to take different
> action based on this - for example skipping time-consuming
> power-saving preparations that are irrelevant if the regulator
> cannot be disabled.
I'd like to see a user here, and I'd also like to understand why this is
a better approach than using a callback to postpone these expensive
operations until the regulator is actually powered off like we already
do for some things like register cache resyncs. That is normally better
since it also avoids the work in cases where the regulator isn't always
on like reenabling during a delayed powerdown or shared regulators.
You're also missing a !CONFIG_REGULATOR stub.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: core: export function to check if regulator always on
2014-11-12 11:35 ` Mark Brown
@ 2014-11-12 13:07 ` Richard Fitzgerald
2014-11-12 14:58 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Richard Fitzgerald @ 2014-11-12 13:07 UTC (permalink / raw)
To: Mark Brown; +Cc: lgirdwood, linux-kernel, patches
On Wed, Nov 12, 2014 at 11:35:41AM +0000, Mark Brown wrote:
> On Wed, Nov 12, 2014 at 11:18:35AM +0000, Richard Fitzgerald wrote:
> > Export a function to allow a consumer to check if its supply
> > regulator is always on. Drivers might wish to take different
> > action based on this - for example skipping time-consuming
> > power-saving preparations that are irrelevant if the regulator
> > cannot be disabled.
>
> I'd like to see a user here,
The user will be the Arizona codec drivers but I wanted to upstream
this patch first for discussion.
> and I'd also like to understand why this is
> a better approach than using a callback to postpone these expensive
> operations until the regulator is actually powered off like we already
> do for some things like register cache resyncs. That is normally better
> since it also avoids the work in cases where the regulator isn't always
> on like reenabling during a delayed powerdown or shared regulators.
>
The runtime_suspend() for the Arizona drivers has to do a bunch of
preparation before disabling the DCVDD regulator (and there's more
preparation steps that need to be upstreamed). There's no point doing
any of this if at the end the regulator isn't going to switch off.
> You're also missing a !CONFIG_REGULATOR stub.
It's there at the end of the patch, returning 1.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: core: export function to check if regulator always on
2014-11-12 13:07 ` Richard Fitzgerald
@ 2014-11-12 14:58 ` Mark Brown
2014-11-12 16:58 ` Richard Fitzgerald
0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2014-11-12 14:58 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: lgirdwood, linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 1299 bytes --]
On Wed, Nov 12, 2014 at 01:07:35PM +0000, Richard Fitzgerald wrote:
> On Wed, Nov 12, 2014 at 11:35:41AM +0000, Mark Brown wrote:
> > I'd like to see a user here,
> The user will be the Arizona codec drivers but I wanted to upstream
> this patch first for discussion.
My point is that the code using the API is useful input to the
discussion.
> > and I'd also like to understand why this is
> > a better approach than using a callback to postpone these expensive
> > operations until the regulator is actually powered off like we already
> > do for some things like register cache resyncs. That is normally better
> > since it also avoids the work in cases where the regulator isn't always
> > on like reenabling during a delayed powerdown or shared regulators.
> The runtime_suspend() for the Arizona drivers has to do a bunch of
> preparation before disabling the DCVDD regulator (and there's more
> preparation steps that need to be upstreamed). There's no point doing
> any of this if at the end the regulator isn't going to switch off.
I'm not sure that this addresses my concern about postponing the
expensive work until the regulator is actually powered off at all?
> > You're also missing a !CONFIG_REGULATOR stub.
> It's there at the end of the patch, returning 1.
Bah, so it is.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: core: export function to check if regulator always on
2014-11-12 14:58 ` Mark Brown
@ 2014-11-12 16:58 ` Richard Fitzgerald
2014-11-12 17:26 ` Mark Brown
0 siblings, 1 reply; 6+ messages in thread
From: Richard Fitzgerald @ 2014-11-12 16:58 UTC (permalink / raw)
To: Mark Brown; +Cc: lgirdwood, linux-kernel, patches
On Wed, Nov 12, 2014 at 02:58:02PM +0000, Mark Brown wrote:
> On Wed, Nov 12, 2014 at 01:07:35PM +0000, Richard Fitzgerald wrote:
> > On Wed, Nov 12, 2014 at 11:35:41AM +0000, Mark Brown wrote:
>
> > > I'd like to see a user here,
>
> > The user will be the Arizona codec drivers but I wanted to upstream
> > this patch first for discussion.
>
> My point is that the code using the API is useful input to the
> discussion.
>
Ok, I'll push up a patch showing what I'm intending to do with this
new function
> > > and I'd also like to understand why this is
> > > a better approach than using a callback to postpone these expensive
> > > operations until the regulator is actually powered off like we already
> > > do for some things like register cache resyncs. That is normally better
> > > since it also avoids the work in cases where the regulator isn't always
> > > on like reenabling during a delayed powerdown or shared regulators.
>
> > The runtime_suspend() for the Arizona drivers has to do a bunch of
> > preparation before disabling the DCVDD regulator (and there's more
> > preparation steps that need to be upstreamed). There's no point doing
> > any of this if at the end the regulator isn't going to switch off.
>
> I'm not sure that this addresses my concern about postponing the
> expensive work until the regulator is actually powered off at all?
>
The point is that the work we want to avoid has to happen while the
regulator is still powered up. We can't just rip power from the codec,
it has to be setup ready for the DCVDD to be turned off. So it's
pre-power down work we're avoiding by knowing that a power-down will
never actually happen, it's not post-power-down work.
But as you say the code that's going to use it will help explain.
> > > You're also missing a !CONFIG_REGULATOR stub.
>
> > It's there at the end of the patch, returning 1.
>
> Bah, so it is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] regulator: core: export function to check if regulator always on
2014-11-12 16:58 ` Richard Fitzgerald
@ 2014-11-12 17:26 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2014-11-12 17:26 UTC (permalink / raw)
To: Richard Fitzgerald; +Cc: lgirdwood, linux-kernel, patches
[-- Attachment #1: Type: text/plain, Size: 1752 bytes --]
On Wed, Nov 12, 2014 at 04:58:56PM +0000, Richard Fitzgerald wrote:
> On Wed, Nov 12, 2014 at 02:58:02PM +0000, Mark Brown wrote:
> > > > and I'd also like to understand why this is
> > > > a better approach than using a callback to postpone these expensive
> > > > operations until the regulator is actually powered off like we already
> > > > do for some things like register cache resyncs. That is normally better
> > > > since it also avoids the work in cases where the regulator isn't always
> > > > on like reenabling during a delayed powerdown or shared regulators.
> > > The runtime_suspend() for the Arizona drivers has to do a bunch of
> > > preparation before disabling the DCVDD regulator (and there's more
> > > preparation steps that need to be upstreamed). There's no point doing
> > > any of this if at the end the regulator isn't going to switch off.
> > I'm not sure that this addresses my concern about postponing the
> > expensive work until the regulator is actually powered off at all?
> The point is that the work we want to avoid has to happen while the
> regulator is still powered up. We can't just rip power from the codec,
> it has to be setup ready for the DCVDD to be turned off. So it's
> pre-power down work we're avoiding by knowing that a power-down will
> never actually happen, it's not post-power-down work.
I'm sorry but you're still not addressing my question - to repeat, my
question is why this is better than postponing these expensive
operations to a callback at the time we want to power off. You keep
saying that you want to avoid these operations when they're not needed
but that's not what I'm asking about, what I'm asking is why polling
this particular possible reason is better than a notifier?
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-11-12 17:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-12 11:18 [PATCH] regulator: core: export function to check if regulator always on Richard Fitzgerald
2014-11-12 11:35 ` Mark Brown
2014-11-12 13:07 ` Richard Fitzgerald
2014-11-12 14:58 ` Mark Brown
2014-11-12 16:58 ` Richard Fitzgerald
2014-11-12 17:26 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox