diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-07-18 11:50:45 +0530 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-07-25 00:36:53 +0200 |
commit | b6719412dc28458f3c142a27bf3e0d2ab3ce0573 (patch) | |
tree | 877edd66855d972926cd9b761c4937c53e741528 /drivers/mfd/tps6586x.c | |
parent | 96c905f408d4ed16b7b87d7d2b16e8d8d02f0cc8 (diff) |
mfd: Use devm managed resources for tps6586x
Allocate memory for device state using devm_kzalloc()
to simplify accounting and letting the kernel do the
garbage-collection.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/tps6586x.c')
-rw-r--r-- | drivers/mfd/tps6586x.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/mfd/tps6586x.c b/drivers/mfd/tps6586x.c index c84b5506d5fb..c103ea903614 100644 --- a/drivers/mfd/tps6586x.c +++ b/drivers/mfd/tps6586x.c @@ -579,9 +579,11 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, dev_info(&client->dev, "VERSIONCRC is %02x\n", ret); - tps6586x = kzalloc(sizeof(struct tps6586x), GFP_KERNEL); - if (tps6586x == NULL) + tps6586x = devm_kzalloc(&client->dev, sizeof(*tps6586x), GFP_KERNEL); + if (tps6586x == NULL) { + dev_err(&client->dev, "memory for tps6586x alloc failed\n"); return -ENOMEM; + } tps6586x->client = client; tps6586x->dev = &client->dev; @@ -594,7 +596,7 @@ static int __devinit tps6586x_i2c_probe(struct i2c_client *client, pdata->irq_base); if (ret) { dev_err(&client->dev, "IRQ init failed: %d\n", ret); - goto err_irq_init; + return ret; } } @@ -622,8 +624,7 @@ err_add_devs: err_gpio_init: if (client->irq) free_irq(client->irq, tps6586x); -err_irq_init: - kfree(tps6586x); + return ret; } @@ -644,7 +645,6 @@ static int __devexit tps6586x_i2c_remove(struct i2c_client *client) } tps6586x_remove_subdevs(tps6586x); - kfree(tps6586x); return 0; } |