aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/lp872x.c
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-09-05 00:39:11 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-05 19:53:02 -0400
commit9ffaa8689ea71ad74075dfd2a7520e6b48ecd910 (patch)
tree93919165571af28f2a6ec4422fcd7b772d93655c /drivers/regulator/lp872x.c
parentba02dfd205a9c54ac6f9db119d9328d9609615bb (diff)
regulator: lp872x: remove regulator platform data dependency
This patch enables registering the regulator driver even though the regulator_init_data is not defined in the platform side. Signed-off-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.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 6199d0f6cca1..ddd60c6b27ea 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -796,11 +796,15 @@ static int lp872x_config(struct lp872x *lp)
796static struct regulator_init_data 796static struct regulator_init_data
797*lp872x_find_regulator_init_data(int id, struct lp872x *lp) 797*lp872x_find_regulator_init_data(int id, struct lp872x *lp)
798{ 798{
799 struct lp872x_platform_data *pdata = lp->pdata;
799 int i; 800 int i;
800 801
802 if (!pdata)
803 return NULL;
804
801 for (i = 0; i < lp->num_regulators; i++) { 805 for (i = 0; i < lp->num_regulators; i++) {
802 if (lp->pdata->regulator_data[i].id == id) 806 if (pdata->regulator_data[i].id == id)
803 return lp->pdata->regulator_data[i].init_data; 807 return pdata->regulator_data[i].init_data;
804 } 808 }
805 809
806 return NULL; 810 return NULL;
@@ -861,18 +865,12 @@ static const struct regmap_config lp872x_regmap_config = {
861static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) 865static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
862{ 866{
863 struct lp872x *lp; 867 struct lp872x *lp;
864 struct lp872x_platform_data *pdata = cl->dev.platform_data;
865 int ret, size, num_regulators; 868 int ret, size, num_regulators;
866 const int lp872x_num_regulators[] = { 869 const int lp872x_num_regulators[] = {
867 [LP8720] = LP8720_NUM_REGULATORS, 870 [LP8720] = LP8720_NUM_REGULATORS,
868 [LP8725] = LP8725_NUM_REGULATORS, 871 [LP8725] = LP8725_NUM_REGULATORS,
869 }; 872 };
870 873
871 if (!pdata) {
872 dev_err(&cl->dev, "no platform data\n");
873 return -EINVAL;
874 }
875
876 lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); 874 lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL);
877 if (!lp) 875 if (!lp)
878 goto err_mem; 876 goto err_mem;
@@ -892,7 +890,7 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
892 } 890 }
893 891
894 lp->dev = &cl->dev; 892 lp->dev = &cl->dev;
895 lp->pdata = pdata; 893 lp->pdata = cl->dev.platform_data;
896 lp->chipid = id->driver_data; 894 lp->chipid = id->driver_data;
897 lp->num_regulators = num_regulators; 895 lp->num_regulators = num_regulators;
898 i2c_set_clientdata(cl, lp); 896 i2c_set_clientdata(cl, lp);