Skip to content

Commit b7bd05b

Browse files
AxelLinbroonie
authored andcommitted
regulator: max1586: Use devm_kzalloc()
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
1 parent ef6bd5a commit b7bd05b

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

‎drivers/regulator/max1586.c‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,17 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
189189
struct max1586_data *max1586;
190190
int i, id, ret = -ENOMEM;
191191

192-
max1586 = kzalloc(sizeof(struct max1586_data) +
192+
max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) +
193193
sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
194194
GFP_KERNEL);
195195
if (!max1586)
196-
goto out;
196+
return -ENOMEM;
197197

198198
max1586->client = client;
199199

200-
if (!pdata->v3_gain) {
201-
ret = -EINVAL;
202-
goto out_unmap;
203-
}
200+
if (!pdata->v3_gain)
201+
return -EINVAL;
202+
204203
max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
205204
max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000;
206205

@@ -234,9 +233,6 @@ static int __devinit max1586_pmic_probe(struct i2c_client *client,
234233
err:
235234
while (--i >= 0)
236235
regulator_unregister(rdev[i]);
237-
out_unmap:
238-
kfree(max1586);
239-
out:
240236
return ret;
241237
}
242238

@@ -248,8 +244,6 @@ static int __devexit max1586_pmic_remove(struct i2c_client *client)
248244
for (i = 0; i <= MAX1586_V6; i++)
249245
if (max1586->rdev[i])
250246
regulator_unregister(max1586->rdev[i]);
251-
kfree(max1586);
252-
253247
return 0;
254248
}
255249

0 commit comments

Comments
 (0)