All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC/RFT] regulator: core: Support setting suspend_[mode|voltage] if set_suspend_[en|dis]able is NULL
@ 2012-04-14  1:14 Axel Lin
  2012-04-16  9:20 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-04-14  1:14 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mark Brown, Liam Girdwood

In current implementation, to support set_suspend_voltage and set_suspend_mode
the regulator code needs the regulator driver to implement both
set_suspend_enable and set_suspend_disable callbacks.

This patch removes this limitation. In the case set_suspend_enable and/or
set_suspend_disable are NULL, the regulator code assumes we don't need to
do any thing to enable/disable regulator when system is suspended and
then will continue to handle set_suspend_mode and set_suspend_voltage.

Currently the regulator core creates suspend state related sysfs entries only
if both set_suspend_enable and set_suspend_disable callbacks are not NULL.
A side-effect of this change is that the regulator core will create suspend
state related sysfs entries unconditionally now.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/core.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index f241671..ecbf37c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -673,17 +673,14 @@ static int suspend_set_state(struct regulator_dev *rdev,
 	struct regulator_state *rstate)
 {
 	int ret = 0;
-	bool can_set_state;
-
-	can_set_state = rdev->desc->ops->set_suspend_enable &&
-		rdev->desc->ops->set_suspend_disable;
 
 	/* If we have no suspend mode configration don't set anything;
-	 * only warn if the driver actually makes the suspend mode
-	 * configurable.
+	 * only warn if the driver implements set_suspend_voltage or
+	 * set_suspend_mode callback.
 	 */
 	if (!rstate->enabled && !rstate->disabled) {
-		if (can_set_state)
+		if (rdev->desc->ops->set_suspend_voltage ||
+		    rdev->desc->ops->set_suspend_mode)
 			rdev_warn(rdev, "No configuration\n");
 		return 0;
 	}
@@ -693,15 +690,13 @@ static int suspend_set_state(struct regulator_dev *rdev,
 		return -EINVAL;
 	}
 
-	if (!can_set_state) {
-		rdev_err(rdev, "no way to set suspend state\n");
-		return -EINVAL;
-	}
-
-	if (rstate->enabled)
+	if (rstate->enabled && rdev->desc->ops->set_suspend_enable)
 		ret = rdev->desc->ops->set_suspend_enable(rdev);
-	else
+	else if (rstate->disabled && rdev->desc->ops->set_suspend_disable)
 		ret = rdev->desc->ops->set_suspend_disable(rdev);
+	else /* OK if set_suspend_enable or set_suspend_disable is NULL */
+		ret = 0;
+
 	if (ret < 0) {
 		rdev_err(rdev, "failed to enabled/disable\n");
 		return ret;
@@ -2781,10 +2776,6 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
 			return status;
 	}
 
-	/* suspend mode constraints need multiple supporting methods */
-	if (!(ops->set_suspend_enable && ops->set_suspend_disable))
-		return status;
-
 	status = device_create_file(dev, &dev_attr_suspend_standby_state);
 	if (status < 0)
 		return status;
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH RFC/RFT] regulator: core: Support setting suspend_[mode|voltage] if set_suspend_[en|dis]able is NULL
  2012-04-14  1:14 [PATCH RFC/RFT] regulator: core: Support setting suspend_[mode|voltage] if set_suspend_[en|dis]able is NULL Axel Lin
@ 2012-04-16  9:20 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-04-16  9:20 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Liam Girdwood

[-- Attachment #1: Type: text/plain, Size: 279 bytes --]

On Sat, Apr 14, 2012 at 09:14:34AM +0800, Axel Lin wrote:
> In current implementation, to support set_suspend_voltage and set_suspend_mode
> the regulator code needs the regulator driver to implement both
> set_suspend_enable and set_suspend_disable callbacks.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-16  9:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-14  1:14 [PATCH RFC/RFT] regulator: core: Support setting suspend_[mode|voltage] if set_suspend_[en|dis]able is NULL Axel Lin
2012-04-16  9:20 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.