* [PATCH] regulator: da9052: Ensure setting current limit within specific range
@ 2012-11-26 7:23 Axel Lin
2012-11-27 20:23 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-11-26 7:23 UTC (permalink / raw)
To: Mark Brown; +Cc: David Dajun Chen, Ashish Jangam, Liam Girdwood, linux-kernel
Checking da9052_current_limits[row][i] <= max_uA is not enough, it is possible
da9052_current_limits[row][i] may less than the requested min_uA.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/da9052-regulator.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
index d6fbfd3..d096309 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -129,17 +129,17 @@ static int da9052_dcdc_set_current_limit(struct regulator_dev *rdev, int min_uA,
else if (offset == 0)
row = 1;
- if (min_uA > da9052_current_limits[row][DA9052_MAX_UA] ||
- max_uA < da9052_current_limits[row][DA9052_MIN_UA])
- return -EINVAL;
-
for (i = DA9052_CURRENT_RANGE - 1; i >= 0; i--) {
- if (da9052_current_limits[row][i] <= max_uA) {
+ if ((min_uA <= da9052_current_limits[row][i]) &&
+ (da9052_current_limits[row][i] <= max_uA)) {
reg_val = i;
break;
}
}
+ if (i < 0)
+ return -EINVAL;
+
/* Determine the even or odd position of the buck current limit
* register field
*/
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: da9052: Ensure setting current limit within specific range
2012-11-26 7:23 [PATCH] regulator: da9052: Ensure setting current limit within specific range Axel Lin
@ 2012-11-27 20:23 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2012-11-27 20:23 UTC (permalink / raw)
To: Axel Lin; +Cc: David Dajun Chen, Ashish Jangam, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
On Mon, Nov 26, 2012 at 03:23:38PM +0800, Axel Lin wrote:
> Checking da9052_current_limits[row][i] <= max_uA is not enough, it is possible
> da9052_current_limits[row][i] may less than the requested min_uA.
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-11-27 20:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26 7:23 [PATCH] regulator: da9052: Ensure setting current limit within specific range Axel Lin
2012-11-27 20:23 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).