Regulator: Reorder the min max assignment in the sequence of regulator_set_voltage function
PATCH 1/1 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.
--- drivers/regulator/core.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/regulator/core.c +9 -0
@@ -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; }
Signature · 1 line
1.7.5.4
Hi Mark/Liam,
Any comments in this?
Regards,
Keerthy
-----Original Message-----
From: J, KEERTHY
Sent: Friday, February 01, 2013 10:35 AM
To: [email protected]; [email protected]; [email protected]
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.
--- drivers/regulator/core.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/regulator/core.c +9 -0
@@ -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; }
Signature · 1 line
1.7.5.4
Quoted 3 lines · KEERTHY
Hi Mark/Liam,
Any comments in this?
Don't top post and a reasonable amount of time for a reply.
drivers/regulator/core.c struct regulator { · line 85
Quoted 7 lines · J Keerthy
+++
b/drivers/regulator/core.cdrivers/regulator/core.c +2
-0@@ -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?
Hi Mark,
Quoted 10 lines
-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Friday, February 08, 2013 4:59 PM
To: J, KEERTHY
Cc: [email protected]; [email protected]
Subject: Re: [PATCH] Regulator: Reorder the min max assignment in the sequence ofregulator_set_voltagefunctionOn Fri, Feb 01, 2013 at 10:34:58AM +0530, J Keerthy wrote:
Quoted 10 lines
drivers/regulator/core.c struct regulator { · line 85
Quoted 7 lines
+++
b/drivers/regulator/core.cdrivers/regulator/core.c +2
-0@@ -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