Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Linux: Kernel

[PATCH RFC/RFT] regulator: ab3100: Use regulator_map_voltage_iterate()

 

 

Linux kernel RSS feed   Index | Next | Previous | View Threaded


axel.lin at gmail

May 16, 2012, 10:06 PM

Post #1 of 3 (126 views)
Permalink
[PATCH RFC/RFT] regulator: ab3100: Use regulator_map_voltage_iterate()

regulator_map_voltage_iterate() is for drivers implementing set_voltage_sel()
and list_voltage() to use it as their map_voltage() operation.

In this case, regulator_map_voltage_iterate() happen to be doing the same thing
as ab3100_get_best_voltage_index() function. So we can use it to replace
ab3100_get_best_voltage_index() function.


Signed-off-by: Axel Lin <axel.lin [at] gmail>
---
drivers/regulator/ab3100.c | 35 +----------------------------------
1 files changed, 1 insertions(+), 34 deletions(-)

diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index e2062ad..03f4d9c 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -304,39 +304,6 @@ static int ab3100_get_voltage_regulator(struct regulator_dev *reg)
return abreg->typ_voltages[regval];
}

-static int ab3100_get_best_voltage_index(struct regulator_dev *reg,
- int min_uV, int max_uV)
-{
- struct ab3100_regulator *abreg = reg->reg_data;
- int i;
- int bestmatch;
- int bestindex;
-
- /*
- * Locate the minimum voltage fitting the criteria on
- * this regulator. The switchable voltages are not
- * in strict falling order so we need to check them
- * all for the best match.
- */
- bestmatch = INT_MAX;
- bestindex = -1;
- for (i = 0; i < abreg->voltages_len; i++) {
- if (abreg->typ_voltages[i] <= max_uV &&
- abreg->typ_voltages[i] >= min_uV &&
- abreg->typ_voltages[i] < bestmatch) {
- bestmatch = abreg->typ_voltages[i];
- bestindex = i;
- }
- }
-
- if (bestindex < 0) {
- dev_warn(&reg->dev, "requested %d<=x<=%d uV, out of range!\n",
- min_uV, max_uV);
- return -EINVAL;
- }
- return bestindex;
-}
-
static int ab3100_set_voltage_regulator_sel(struct regulator_dev *reg,
unsigned selector)
{
@@ -383,7 +350,7 @@ static int ab3100_set_suspend_voltage_regulator(struct regulator_dev *reg,
return -EINVAL;

/* LDO E and BUCK have special suspend voltages you can set */
- bestindex = ab3100_get_best_voltage_index(reg, uV, uV);
+ bestindex = regulator_map_voltage_iterate(reg, uV, uV);

err = abx500_get_register_interruptible(abreg->dev, 0,
targetreg, &regval);
--
1.7.5.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/


broonie at opensource

May 18, 2012, 12:40 AM

Post #2 of 3 (122 views)
Permalink
Re: [PATCH RFC/RFT] regulator: ab3100: Use regulator_map_voltage_iterate() [In reply to]

On Thu, May 17, 2012 at 01:06:18PM +0800, Axel Lin wrote:
> regulator_map_voltage_iterate() is for drivers implementing set_voltage_sel()
> and list_voltage() to use it as their map_voltage() operation.
>
> In this case, regulator_map_voltage_iterate() happen to be doing the same thing
> as ab3100_get_best_voltage_index() function. So we can use it to replace
> ab3100_get_best_voltage_index() function.

Applied, thanks.
Attachments: signature.asc (0.82 KB)


linus.walleij at linaro

May 20, 2012, 2:13 PM

Post #3 of 3 (119 views)
Permalink
Re: [PATCH RFC/RFT] regulator: ab3100: Use regulator_map_voltage_iterate() [In reply to]

On Thu, May 17, 2012 at 7:06 AM, Axel Lin <axel.lin [at] gmail> wrote:

> regulator_map_voltage_iterate() is for drivers implementing set_voltage_sel()
> and list_voltage() to use it as their map_voltage() operation.
>
> In this case, regulator_map_voltage_iterate() happen to be doing the same thing
> as ab3100_get_best_voltage_index() function. So we can use it to replace
> ab3100_get_best_voltage_index() function.
>
>
> Signed-off-by: Axel Lin <axel.lin [at] gmail>

Acked-by: Linus Walleij <linus.walleij [at] linaro>

I think Mark already applied it too, great!

Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo [at] vger
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Linux kernel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.