aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max1586.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/regulator/max1586.c')
-rw-r--r--drivers/regulator/max1586.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index e242dd316d36..d23d0577754b 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -46,8 +46,6 @@ struct max1586_data {
46 46
47 unsigned int v3_curr_sel; 47 unsigned int v3_curr_sel;
48 unsigned int v6_curr_sel; 48 unsigned int v6_curr_sel;
49
50 struct regulator_dev *rdev[0];
51}; 49};
52 50
53/* 51/*
@@ -162,14 +160,12 @@ static struct regulator_desc max1586_reg[] = {
162static int max1586_pmic_probe(struct i2c_client *client, 160static int max1586_pmic_probe(struct i2c_client *client,
163 const struct i2c_device_id *i2c_id) 161 const struct i2c_device_id *i2c_id)
164{ 162{
165 struct regulator_dev **rdev;
166 struct max1586_platform_data *pdata = dev_get_platdata(&client->dev); 163 struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
167 struct regulator_config config = { }; 164 struct regulator_config config = { };
168 struct max1586_data *max1586; 165 struct max1586_data *max1586;
169 int i, id; 166 int i, id;
170 167
171 max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) + 168 max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data),
172 sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
173 GFP_KERNEL); 169 GFP_KERNEL);
174 if (!max1586) 170 if (!max1586)
175 return -ENOMEM; 171 return -ENOMEM;
@@ -186,8 +182,9 @@ static int max1586_pmic_probe(struct i2c_client *client,
186 max1586->v3_curr_sel = 24; /* 1.3V */ 182 max1586->v3_curr_sel = 24; /* 1.3V */
187 max1586->v6_curr_sel = 0; 183 max1586->v6_curr_sel = 0;
188 184
189 rdev = max1586->rdev;
190 for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) { 185 for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
186 struct regulator_dev *rdev;
187
191 id = pdata->subdevs[i].id; 188 id = pdata->subdevs[i].id;
192 if (!pdata->subdevs[i].platform_data) 189 if (!pdata->subdevs[i].platform_data)
193 continue; 190 continue;
@@ -207,12 +204,12 @@ static int max1586_pmic_probe(struct i2c_client *client,
207 config.init_data = pdata->subdevs[i].platform_data; 204 config.init_data = pdata->subdevs[i].platform_data;
208 config.driver_data = max1586; 205 config.driver_data = max1586;
209 206
210 rdev[i] = devm_regulator_register(&client->dev, 207 rdev = devm_regulator_register(&client->dev,
211 &max1586_reg[id], &config); 208 &max1586_reg[id], &config);
212 if (IS_ERR(rdev[i])) { 209 if (IS_ERR(rdev)) {
213 dev_err(&client->dev, "failed to register %s\n", 210 dev_err(&client->dev, "failed to register %s\n",
214 max1586_reg[id].name); 211 max1586_reg[id].name);
215 return PTR_ERR(rdev[i]); 212 return PTR_ERR(rdev);
216 } 213 }
217 } 214 }
218 215