Commit 5bae0628 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

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: default avatarAxel Lin <axel.lin@gmail.com>
Acked-by: default avatarMilo(Woogyom) Kim <milo.kim@ti.com>
Tested-by: default avatarMilo(Woogyom) Kim <milo.kim@ti.com>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent c6a717c9
...@@ -796,30 +796,16 @@ static int lp872x_config(struct lp872x *lp) ...@@ -796,30 +796,16 @@ static int lp872x_config(struct lp872x *lp)
} }
static struct regulator_init_data 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; int i;
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;
}
id = base + idx; for (i = 0; i < lp->num_regulators; i++) {
for (i = 0 ; i < max_regulators ; i++)
if (lp->pdata->regulator_data[i].id == id) if (lp->pdata->regulator_data[i].id == id)
break; return lp->pdata->regulator_data[i].init_data;
}
return (i == max_regulators) ? NULL : return NULL;
lp->pdata->regulator_data[i].init_data;
} }
static int lp872x_regulator_register(struct lp872x *lp) static int lp872x_regulator_register(struct lp872x *lp)
...@@ -834,7 +820,7 @@ static int lp872x_regulator_register(struct lp872x *lp) ...@@ -834,7 +820,7 @@ static int lp872x_regulator_register(struct lp872x *lp)
&lp8725_regulator_desc[i]; &lp8725_regulator_desc[i];
cfg.dev = lp->dev; 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.driver_data = lp;
cfg.regmap = lp->regmap; cfg.regmap = lp->regmap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment