Commit b7bd05b8d546cebbf05e98194b54d7b122aadf0e

Authored by Axel Lin
Committed by Mark Brown
1 parent ef6bd5a3f1

regulator: max1586: Use devm_kzalloc()

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Showing 1 changed file with 5 additions and 11 deletions Side-by-side Diff

drivers/regulator/max1586.c
... ... @@ -189,18 +189,17 @@
189 189 struct max1586_data *max1586;
190 190 int i, id, ret = -ENOMEM;
191 191  
192   - max1586 = kzalloc(sizeof(struct max1586_data) +
  192 + max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) +
193 193 sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
194 194 GFP_KERNEL);
195 195 if (!max1586)
196   - goto out;
  196 + return -ENOMEM;
197 197  
198 198 max1586->client = client;
199 199  
200   - if (!pdata->v3_gain) {
201   - ret = -EINVAL;
202   - goto out_unmap;
203   - }
  200 + if (!pdata->v3_gain)
  201 + return -EINVAL;
  202 +
204 203 max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
205 204 max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000;
206 205  
... ... @@ -234,9 +233,6 @@
234 233 err:
235 234 while (--i >= 0)
236 235 regulator_unregister(rdev[i]);
237   -out_unmap:
238   - kfree(max1586);
239   -out:
240 236 return ret;
241 237 }
242 238  
... ... @@ -248,8 +244,6 @@
248 244 for (i = 0; i <= MAX1586_V6; i++)
249 245 if (max1586->rdev[i])
250 246 regulator_unregister(max1586->rdev[i]);
251   - kfree(max1586);
252   -
253 247 return 0;
254 248 }
255 249