diff options
Diffstat (limited to 'drivers/regulator/lp872x.c')
-rw-r--r-- | drivers/regulator/lp872x.c | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 021d64d856bb..3de328ab41f3 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
@@ -106,7 +106,6 @@ struct lp872x { | |||
106 | struct device *dev; | 106 | struct device *dev; |
107 | enum lp872x_id chipid; | 107 | enum lp872x_id chipid; |
108 | struct lp872x_platform_data *pdata; | 108 | struct lp872x_platform_data *pdata; |
109 | struct regulator_dev **regulators; | ||
110 | int num_regulators; | 109 | int num_regulators; |
111 | enum lp872x_dvs_state dvs_pin; | 110 | enum lp872x_dvs_state dvs_pin; |
112 | int dvs_gpio; | 111 | int dvs_gpio; |
@@ -801,8 +800,6 @@ static int lp872x_regulator_register(struct lp872x *lp) | |||
801 | dev_err(lp->dev, "regulator register err"); | 800 | dev_err(lp->dev, "regulator register err"); |
802 | return PTR_ERR(rdev); | 801 | return PTR_ERR(rdev); |
803 | } | 802 | } |
804 | |||
805 | *(lp->regulators + i) = rdev; | ||
806 | } | 803 | } |
807 | 804 | ||
808 | return 0; | 805 | return 0; |
@@ -906,7 +903,7 @@ static struct lp872x_platform_data | |||
906 | static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | 903 | static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) |
907 | { | 904 | { |
908 | struct lp872x *lp; | 905 | struct lp872x *lp; |
909 | int ret, size, num_regulators; | 906 | int ret; |
910 | const int lp872x_num_regulators[] = { | 907 | const int lp872x_num_regulators[] = { |
911 | [LP8720] = LP8720_NUM_REGULATORS, | 908 | [LP8720] = LP8720_NUM_REGULATORS, |
912 | [LP8725] = LP8725_NUM_REGULATORS, | 909 | [LP8725] = LP8725_NUM_REGULATORS, |
@@ -918,38 +915,27 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id) | |||
918 | 915 | ||
919 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); | 916 | lp = devm_kzalloc(&cl->dev, sizeof(struct lp872x), GFP_KERNEL); |
920 | if (!lp) | 917 | if (!lp) |
921 | goto err_mem; | 918 | return -ENOMEM; |
922 | |||
923 | num_regulators = lp872x_num_regulators[id->driver_data]; | ||
924 | size = sizeof(struct regulator_dev *) * num_regulators; | ||
925 | 919 | ||
926 | lp->regulators = devm_kzalloc(&cl->dev, size, GFP_KERNEL); | 920 | lp->num_regulators = lp872x_num_regulators[id->driver_data]; |
927 | if (!lp->regulators) | ||
928 | goto err_mem; | ||
929 | 921 | ||
930 | lp->regmap = devm_regmap_init_i2c(cl, &lp872x_regmap_config); | 922 | lp->regmap = devm_regmap_init_i2c(cl, &lp872x_regmap_config); |
931 | if (IS_ERR(lp->regmap)) { | 923 | if (IS_ERR(lp->regmap)) { |
932 | ret = PTR_ERR(lp->regmap); | 924 | ret = PTR_ERR(lp->regmap); |
933 | dev_err(&cl->dev, "regmap init i2c err: %d\n", ret); | 925 | dev_err(&cl->dev, "regmap init i2c err: %d\n", ret); |
934 | goto err_dev; | 926 | return ret; |
935 | } | 927 | } |
936 | 928 | ||
937 | lp->dev = &cl->dev; | 929 | lp->dev = &cl->dev; |
938 | lp->pdata = dev_get_platdata(&cl->dev); | 930 | lp->pdata = dev_get_platdata(&cl->dev); |
939 | lp->chipid = id->driver_data; | 931 | lp->chipid = id->driver_data; |
940 | lp->num_regulators = num_regulators; | ||
941 | i2c_set_clientdata(cl, lp); | 932 | i2c_set_clientdata(cl, lp); |
942 | 933 | ||
943 | ret = lp872x_config(lp); | 934 | ret = lp872x_config(lp); |
944 | if (ret) | 935 | if (ret) |
945 | goto err_dev; | 936 | return ret; |
946 | 937 | ||
947 | return lp872x_regulator_register(lp); | 938 | return lp872x_regulator_register(lp); |
948 | |||
949 | err_mem: | ||
950 | return -ENOMEM; | ||
951 | err_dev: | ||
952 | return ret; | ||
953 | } | 939 | } |
954 | 940 | ||
955 | static const struct of_device_id lp872x_dt_ids[] = { | 941 | static const struct of_device_id lp872x_dt_ids[] = { |