summaryrefslogtreecommitdiff
path: root/drivers/regulator
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-07-15 16:57:12 +0800
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-16 20:58:30 +0100
commit5bae062830b57e75a00f1a643a6e031ad0f15129 (patch)
tree0900c35136e6c48170c7034fd8f95abcebb93540 /drivers/regulator
parentc6a717c9d740ec8f5bd134ac8c75b1b7c0666ff8 (diff)
regulator: lp872x: Simplify implementation of lp872x_find_regulator_init_data()
Pass regulator id rahter than the index to lp872x_find_regulator_init_data(), then the code can be simpler. We can also get max_regulators by lp->num_regulators. Signed-off-by: Axel Lin <axel.lin@gmail.com> Acked-by: Milo(Woogyom) Kim <milo.kim@ti.com> Tested-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/lp872x.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 471f8e82be41..212c38eaba70 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -796,30 +796,16 @@ static int lp872x_config(struct lp872x *lp)
}
static struct regulator_init_data
-*lp872x_find_regulator_init_data(int idx, struct lp872x *lp)
+*lp872x_find_regulator_init_data(int id, struct lp872x *lp)
{
- int i, base, id, max_regulators;
-
- switch (lp->chipid) {
- case LP8720:
- base = LP8720_ID_BASE;
- max_regulators = LP8720_NUM_REGULATORS;
- break;
- case LP8725:
- base = LP8725_ID_BASE;
- max_regulators = LP8725_NUM_REGULATORS;
- break;
- default:
- return NULL;
- }
+ int i;
- id = base + idx;
- for (i = 0 ; i < max_regulators ; i++)
+ for (i = 0; i < lp->num_regulators; i++) {
if (lp->pdata->regulator_data[i].id == id)
- break;
+ return lp->pdata->regulator_data[i].init_data;
+ }
- return (i == max_regulators) ? NULL :
- lp->pdata->regulator_data[i].init_data;
+ return NULL;
}
static int lp872x_regulator_register(struct lp872x *lp)
@@ -834,7 +820,7 @@ static int lp872x_regulator_register(struct lp872x *lp)
&lp8725_regulator_desc[i];
cfg.dev = lp->dev;
- cfg.init_data = lp872x_find_regulator_init_data(i, lp);
+ cfg.init_data = lp872x_find_regulator_init_data(desc->id, lp);
cfg.driver_data = lp;
cfg.regmap = lp->regmap;