aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/lp872x.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-07-15 04:57:12 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-07-16 15:58:30 -0400
commit5bae062830b57e75a00f1a643a6e031ad0f15129 (patch)
tree0900c35136e6c48170c7034fd8f95abcebb93540 /drivers/regulator/lp872x.c
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/lp872x.c')
-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)
796} 796}
797 797
798static struct regulator_init_data 798static struct regulator_init_data
799*lp872x_find_regulator_init_data(int idx, struct lp872x *lp) 799*lp872x_find_regulator_init_data(int id, struct lp872x *lp)
800{ 800{
801 int i, base, id, max_regulators; 801 int i;
802
803 switch (lp->chipid) {
804 case LP8720:
805 base = LP8720_ID_BASE;
806 max_regulators = LP8720_NUM_REGULATORS;
807 break;
808 case LP8725:
809 base = LP8725_ID_BASE;
810 max_regulators = LP8725_NUM_REGULATORS;
811 break;
812 default:
813 return NULL;
814 }
815 802
816 id = base + idx; 803 for (i = 0; i < lp->num_regulators; i++) {
817 for (i = 0 ; i < max_regulators ; i++)
818 if (lp->pdata->regulator_data[i].id == id) 804 if (lp->pdata->regulator_data[i].id == id)
819 break; 805 return lp->pdata->regulator_data[i].init_data;
806 }
820 807
821 return (i == max_regulators) ? NULL : 808 return NULL;
822 lp->pdata->regulator_data[i].init_data;
823} 809}
824 810
825static int lp872x_regulator_register(struct lp872x *lp) 811static int lp872x_regulator_register(struct lp872x *lp)
@@ -834,7 +820,7 @@ static int lp872x_regulator_register(struct lp872x *lp)
834 &lp8725_regulator_desc[i]; 820 &lp8725_regulator_desc[i];
835 821
836 cfg.dev = lp->dev; 822 cfg.dev = lp->dev;
837 cfg.init_data = lp872x_find_regulator_init_data(i, lp); 823 cfg.init_data = lp872x_find_regulator_init_data(desc->id, lp);
838 cfg.driver_data = lp; 824 cfg.driver_data = lp;
839 cfg.regmap = lp->regmap; 825 cfg.regmap = lp->regmap;
840 826