Commit dc553a7994e5492237562c7a5400e4b13111ff92
Committed by
Mark Brown
1 parent
268a164135
Exists in
master
and in
20 other branches
regulator: max8649: Use devm_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Showing 1 changed file with 6 additions and 13 deletions Side-by-side Diff
drivers/regulator/max8649.c
... | ... | @@ -230,17 +230,18 @@ |
230 | 230 | unsigned char data; |
231 | 231 | int ret; |
232 | 232 | |
233 | - info = kzalloc(sizeof(struct max8649_regulator_info), GFP_KERNEL); | |
233 | + info = devm_kzalloc(&client->dev, sizeof(struct max8649_regulator_info), | |
234 | + GFP_KERNEL); | |
234 | 235 | if (!info) { |
235 | 236 | dev_err(&client->dev, "No enough memory\n"); |
236 | 237 | return -ENOMEM; |
237 | 238 | } |
238 | 239 | |
239 | - info->regmap = regmap_init_i2c(client, &max8649_regmap_config); | |
240 | + info->regmap = devm_regmap_init_i2c(client, &max8649_regmap_config); | |
240 | 241 | if (IS_ERR(info->regmap)) { |
241 | 242 | ret = PTR_ERR(info->regmap); |
242 | 243 | dev_err(&client->dev, "Failed to allocate register map: %d\n", ret); |
243 | - goto fail; | |
244 | + return ret; | |
244 | 245 | } |
245 | 246 | |
246 | 247 | info->dev = &client->dev; |
... | ... | @@ -268,7 +269,7 @@ |
268 | 269 | if (ret != 0) { |
269 | 270 | dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n", |
270 | 271 | ret); |
271 | - goto out; | |
272 | + return ret; | |
272 | 273 | } |
273 | 274 | dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val); |
274 | 275 | |
275 | 276 | |
... | ... | @@ -306,16 +307,10 @@ |
306 | 307 | if (IS_ERR(info->regulator)) { |
307 | 308 | dev_err(info->dev, "failed to register regulator %s\n", |
308 | 309 | dcdc_desc.name); |
309 | - ret = PTR_ERR(info->regulator); | |
310 | - goto out; | |
310 | + return PTR_ERR(info->regulator); | |
311 | 311 | } |
312 | 312 | |
313 | 313 | return 0; |
314 | -out: | |
315 | - regmap_exit(info->regmap); | |
316 | -fail: | |
317 | - kfree(info); | |
318 | - return ret; | |
319 | 314 | } |
320 | 315 | |
321 | 316 | static int __devexit max8649_regulator_remove(struct i2c_client *client) |
... | ... | @@ -325,8 +320,6 @@ |
325 | 320 | if (info) { |
326 | 321 | if (info->regulator) |
327 | 322 | regulator_unregister(info->regulator); |
328 | - regmap_exit(info->regmap); | |
329 | - kfree(info); | |
330 | 323 | } |
331 | 324 | |
332 | 325 | return 0; |