All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
@ 2013-02-01  5:04 J Keerthy
  2013-02-04 11:53 ` J, KEERTHY
  2013-02-08 11:28 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: J Keerthy @ 2013-02-01  5:04 UTC (permalink / raw)
  To: linux-kernel, lgirdwood, broonie; +Cc: j-keerthy

The min and max values for regulators are getting assigned before actually
the voltage is set. So making sure that min and max values are assigned
only if the voltage is successfully set else keeping the last successfully
set voltage's min and max values.

This is boot tested on OMAP4430 and OMAP4460 boards.

Signed-off-by: J Keerthy <j-keerthy@ti.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> 
---
 drivers/regulator/core.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2785843..12140fb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -81,6 +81,8 @@ struct regulator {
 	int uA_load;
 	int min_uV;
 	int max_uV;
+	int curr_min_uV;
+	int curr_max_uV;
 	char *supply_name;
 	struct device_attribute dev_attr;
 	struct regulator_dev *rdev;
@@ -2315,6 +2317,8 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
 	if (ret < 0)
 		goto out;
+	regulator->curr_min_uV = regulator->min_uV;
+	regulator->curr_max_uV = regulator->max_uV;
 	regulator->min_uV = min_uV;
 	regulator->max_uV = max_uV;
 
@@ -2325,6 +2329,11 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
 
 out:
+	if (ret) {
+		regulator->min_uV = regulator->curr_min_uV;
+		regulator->max_uV = regulator->curr_max_uV;
+	}
+
 	mutex_unlock(&rdev->mutex);
 	return ret;
 }
-- 
1.7.5.4


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

* RE: [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
  2013-02-01  5:04 [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function J Keerthy
@ 2013-02-04 11:53 ` J, KEERTHY
  2013-02-04 15:05   ` Mark Brown
  2013-02-08 11:28 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: J, KEERTHY @ 2013-02-04 11:53 UTC (permalink / raw)
  To: J, KEERTHY, linux-kernel, lgirdwood, broonie

Hi Mark/Liam,

Any comments in this?

Regards,
Keerthy

-----Original Message-----
From: J, KEERTHY 
Sent: Friday, February 01, 2013 10:35 AM
To: linux-kernel@vger.kernel.org; lgirdwood@gmail.com; broonie@opensource.wolfsonmicro.com
Cc: J, KEERTHY
Subject: [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function

The min and max values for regulators are getting assigned before actually
the voltage is set. So making sure that min and max values are assigned
only if the voltage is successfully set else keeping the last successfully
set voltage's min and max values.

This is boot tested on OMAP4430 and OMAP4460 boards.

Signed-off-by: J Keerthy <j-keerthy@ti.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> 
---
 drivers/regulator/core.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 2785843..12140fb 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -81,6 +81,8 @@ struct regulator {
 	int uA_load;
 	int min_uV;
 	int max_uV;
+	int curr_min_uV;
+	int curr_max_uV;
 	char *supply_name;
 	struct device_attribute dev_attr;
 	struct regulator_dev *rdev;
@@ -2315,6 +2317,8 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	ret = regulator_check_voltage(rdev, &min_uV, &max_uV);
 	if (ret < 0)
 		goto out;
+	regulator->curr_min_uV = regulator->min_uV;
+	regulator->curr_max_uV = regulator->max_uV;
 	regulator->min_uV = min_uV;
 	regulator->max_uV = max_uV;
 
@@ -2325,6 +2329,11 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
 	ret = _regulator_do_set_voltage(rdev, min_uV, max_uV);
 
 out:
+	if (ret) {
+		regulator->min_uV = regulator->curr_min_uV;
+		regulator->max_uV = regulator->curr_max_uV;
+	}
+
 	mutex_unlock(&rdev->mutex);
 	return ret;
 }
-- 
1.7.5.4


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

* Re: [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
  2013-02-04 11:53 ` J, KEERTHY
@ 2013-02-04 15:05   ` Mark Brown
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2013-02-04 15:05 UTC (permalink / raw)
  To: J, KEERTHY; +Cc: linux-kernel, lgirdwood

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

On Mon, Feb 04, 2013 at 11:53:20AM +0000, J, KEERTHY wrote:
> Hi Mark/Liam,
> 
> Any comments in this?

Don't top post and a reasonable amount of time for a reply.

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

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

* Re: [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
  2013-02-01  5:04 [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function J Keerthy
  2013-02-04 11:53 ` J, KEERTHY
@ 2013-02-08 11:28 ` Mark Brown
  2013-02-11  5:26   ` J, KEERTHY
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2013-02-08 11:28 UTC (permalink / raw)
  To: J Keerthy; +Cc: linux-kernel, lgirdwood

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

On Fri, Feb 01, 2013 at 10:34:58AM +0530, J Keerthy wrote:

> +++ b/drivers/regulator/core.c
> @@ -81,6 +81,8 @@ struct regulator {
>  	int uA_load;
>  	int min_uV;
>  	int max_uV;
> +	int curr_min_uV;
> +	int curr_max_uV;

This change makes sense but I don't see why we need to add these to
struct regulator - why not just store the values locally for unwinding?

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

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

* RE: [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
  2013-02-08 11:28 ` Mark Brown
@ 2013-02-11  5:26   ` J, KEERTHY
  0 siblings, 0 replies; 5+ messages in thread
From: J, KEERTHY @ 2013-02-11  5:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-kernel, lgirdwood

Hi Mark,

> -----Original Message-----
> From: Mark Brown [mailto:broonie@opensource.wolfsonmicro.com]
> Sent: Friday, February 08, 2013 4:59 PM
> To: J, KEERTHY
> Cc: linux-kernel@vger.kernel.org; lgirdwood@gmail.com
> Subject: Re: [PATCH] Regulator: Reorder the min max assignment in the
> sequence of regulator_set_voltage function
> 
> On Fri, Feb 01, 2013 at 10:34:58AM +0530, J Keerthy wrote:
> 
> > +++ b/drivers/regulator/core.c
> > @@ -81,6 +81,8 @@ struct regulator {
> >  	int uA_load;
> >  	int min_uV;
> >  	int max_uV;
> > +	int curr_min_uV;
> > +	int curr_max_uV;
> 
> This change makes sense but I don't see why we need to add these to
> struct regulator - why not just store the values locally for unwinding?

Ok. I will send an updated patch. Thanks for the response
And sorry for the top posting.

Regards,
Keerthy

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

end of thread, other threads:[~2013-02-11  5:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-01  5:04 [PATCH] Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function J Keerthy
2013-02-04 11:53 ` J, KEERTHY
2013-02-04 15:05   ` Mark Brown
2013-02-08 11:28 ` Mark Brown
2013-02-11  5:26   ` J, KEERTHY

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.