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>
dev_info(&client->dev, "VERSIONCRC is %02x\n", ret);
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");
tps6586x->client = client;
tps6586x->dev = &client->dev;
tps6586x->client = client;
tps6586x->dev = &client->dev;
pdata->irq_base);
if (ret) {
dev_err(&client->dev, "IRQ init failed: %d\n", ret);
pdata->irq_base);
if (ret) {
dev_err(&client->dev, "IRQ init failed: %d\n", ret);
err_gpio_init:
if (client->irq)
free_irq(client->irq, tps6586x);
err_gpio_init:
if (client->irq)
free_irq(client->irq, tps6586x);
-err_irq_init:
- kfree(tps6586x);
}
tps6586x_remove_subdevs(tps6586x);
}
tps6586x_remove_subdevs(tps6586x);