aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/tc3589x.c
diff options
context:
space:
mode:
authorJingoo Han <jg1.han@samsung.com>2013-02-20 04:31:52 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2013-04-08 11:25:29 -0400
commit1383e00f79a7bd6333083a12b43481b6bf2bdcb4 (patch)
treeb7cc0e7ea8a2e0a2a637359198cc2e80835458ab /drivers/mfd/tc3589x.c
parentaa4dcf5bec80501933c6935f50f438594823c614 (diff)
mfd: tc3589x: Use devm_*() functions
Use devm_*() functions to make cleanup paths more simple. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/tc3589x.c')
-rw-r--r--drivers/mfd/tc3589x.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c
index ecc092c7f745..4cb92bb2aea2 100644
--- a/drivers/mfd/tc3589x.c
+++ b/drivers/mfd/tc3589x.c
@@ -350,7 +350,8 @@ static int tc3589x_probe(struct i2c_client *i2c,
350 | I2C_FUNC_SMBUS_I2C_BLOCK)) 350 | I2C_FUNC_SMBUS_I2C_BLOCK))
351 return -EIO; 351 return -EIO;
352 352
353 tc3589x = kzalloc(sizeof(struct tc3589x), GFP_KERNEL); 353 tc3589x = devm_kzalloc(&i2c->dev, sizeof(struct tc3589x),
354 GFP_KERNEL);
354 if (!tc3589x) 355 if (!tc3589x)
355 return -ENOMEM; 356 return -ENOMEM;
356 357
@@ -366,33 +367,27 @@ static int tc3589x_probe(struct i2c_client *i2c,
366 367
367 ret = tc3589x_chip_init(tc3589x); 368 ret = tc3589x_chip_init(tc3589x);
368 if (ret) 369 if (ret)
369 goto out_free; 370 return ret;
370 371
371 ret = tc3589x_irq_init(tc3589x, np); 372 ret = tc3589x_irq_init(tc3589x, np);
372 if (ret) 373 if (ret)
373 goto out_free; 374 return ret;
374 375
375 ret = request_threaded_irq(tc3589x->i2c->irq, NULL, tc3589x_irq, 376 ret = request_threaded_irq(tc3589x->i2c->irq, NULL, tc3589x_irq,
376 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 377 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
377 "tc3589x", tc3589x); 378 "tc3589x", tc3589x);
378 if (ret) { 379 if (ret) {
379 dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret); 380 dev_err(tc3589x->dev, "failed to request IRQ: %d\n", ret);
380 goto out_free; 381 return ret;
381 } 382 }
382 383
383 ret = tc3589x_device_init(tc3589x); 384 ret = tc3589x_device_init(tc3589x);
384 if (ret) { 385 if (ret) {
385 dev_err(tc3589x->dev, "failed to add child devices\n"); 386 dev_err(tc3589x->dev, "failed to add child devices\n");
386 goto out_freeirq; 387 return ret;
387 } 388 }
388 389
389 return 0; 390 return 0;
390
391out_freeirq:
392 free_irq(tc3589x->i2c->irq, tc3589x);
393out_free:
394 kfree(tc3589x);
395 return ret;
396} 391}
397 392
398static int tc3589x_remove(struct i2c_client *client) 393static int tc3589x_remove(struct i2c_client *client)
@@ -401,10 +396,6 @@ static int tc3589x_remove(struct i2c_client *client)
401 396
402 mfd_remove_devices(tc3589x->dev); 397 mfd_remove_devices(tc3589x->dev);
403 398
404 free_irq(tc3589x->i2c->irq, tc3589x);
405
406 kfree(tc3589x);
407
408 return 0; 399 return 0;
409} 400}
410 401