aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/max8649.c
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2012-04-07 11:28:28 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-04-10 06:04:26 -0400
commitdc553a7994e5492237562c7a5400e4b13111ff92 (patch)
tree28809b12fb884e3cf66a0059fc7fa3b92edc2540 /drivers/regulator/max8649.c
parent268a164135b0635418ba703f77f4f654ea5abaec (diff)
regulator: max8649: Use devm_* APIs
Signed-off-by: Axel Lin <axel.lin@gmail.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/regulator/max8649.c')
-rw-r--r--drivers/regulator/max8649.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 991f517c8dc8..4ce72081c2e3 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -230,17 +230,18 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
230 unsigned char data; 230 unsigned char data;
231 int ret; 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 if (!info) { 235 if (!info) {
235 dev_err(&client->dev, "No enough memory\n"); 236 dev_err(&client->dev, "No enough memory\n");
236 return -ENOMEM; 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 if (IS_ERR(info->regmap)) { 241 if (IS_ERR(info->regmap)) {
241 ret = PTR_ERR(info->regmap); 242 ret = PTR_ERR(info->regmap);
242 dev_err(&client->dev, "Failed to allocate register map: %d\n", ret); 243 dev_err(&client->dev, "Failed to allocate register map: %d\n", ret);
243 goto fail; 244 return ret;
244 } 245 }
245 246
246 info->dev = &client->dev; 247 info->dev = &client->dev;
@@ -268,7 +269,7 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
268 if (ret != 0) { 269 if (ret != 0) {
269 dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n", 270 dev_err(info->dev, "Failed to detect ID of MAX8649:%d\n",
270 ret); 271 ret);
271 goto out; 272 return ret;
272 } 273 }
273 dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val); 274 dev_info(info->dev, "Detected MAX8649 (ID:%x)\n", val);
274 275
@@ -306,16 +307,10 @@ static int __devinit max8649_regulator_probe(struct i2c_client *client,
306 if (IS_ERR(info->regulator)) { 307 if (IS_ERR(info->regulator)) {
307 dev_err(info->dev, "failed to register regulator %s\n", 308 dev_err(info->dev, "failed to register regulator %s\n",
308 dcdc_desc.name); 309 dcdc_desc.name);
309 ret = PTR_ERR(info->regulator); 310 return PTR_ERR(info->regulator);
310 goto out;
311 } 311 }
312 312
313 return 0; 313 return 0;
314out:
315 regmap_exit(info->regmap);
316fail:
317 kfree(info);
318 return ret;
319} 314}
320 315
321static int __devexit max8649_regulator_remove(struct i2c_client *client) 316static int __devexit max8649_regulator_remove(struct i2c_client *client)
@@ -325,8 +320,6 @@ static int __devexit max8649_regulator_remove(struct i2c_client *client)
325 if (info) { 320 if (info) {
326 if (info->regulator) 321 if (info->regulator)
327 regulator_unregister(info->regulator); 322 regulator_unregister(info->regulator);
328 regmap_exit(info->regmap);
329 kfree(info);
330 } 323 }
331 324
332 return 0; 325 return 0;