mfd: Use devm allocation for ab3100-core
Allocate memory and irq for device state using devm_* helpers to simplify memory accounting. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
78a27cd3e8
commit
7f0f07ce25
1 changed files with 7 additions and 16 deletions
|
@ -867,7 +867,7 @@ static int __devinit ab3100_probe(struct i2c_client *client,
|
||||||
int err;
|
int err;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ab3100 = kzalloc(sizeof(struct ab3100), GFP_KERNEL);
|
ab3100 = devm_kzalloc(&client->dev, sizeof(struct ab3100), GFP_KERNEL);
|
||||||
if (!ab3100) {
|
if (!ab3100) {
|
||||||
dev_err(&client->dev, "could not allocate AB3100 device\n");
|
dev_err(&client->dev, "could not allocate AB3100 device\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -921,7 +921,7 @@ static int __devinit ab3100_probe(struct i2c_client *client,
|
||||||
|
|
||||||
/* Attach a second dummy i2c_client to the test register address */
|
/* Attach a second dummy i2c_client to the test register address */
|
||||||
ab3100->testreg_client = i2c_new_dummy(client->adapter,
|
ab3100->testreg_client = i2c_new_dummy(client->adapter,
|
||||||
client->addr + 1);
|
client->addr + 1);
|
||||||
if (!ab3100->testreg_client) {
|
if (!ab3100->testreg_client) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto exit_no_testreg_client;
|
goto exit_no_testreg_client;
|
||||||
|
@ -931,13 +931,13 @@ static int __devinit ab3100_probe(struct i2c_client *client,
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_no_setup;
|
goto exit_no_setup;
|
||||||
|
|
||||||
err = request_threaded_irq(client->irq, NULL, ab3100_irq_handler,
|
err = devm_request_threaded_irq(&client->dev,
|
||||||
IRQF_ONESHOT, "ab3100-core", ab3100);
|
client->irq, NULL, ab3100_irq_handler,
|
||||||
/* This real unpredictable IRQ is of course sampled for entropy */
|
IRQF_ONESHOT, "ab3100-core", ab3100);
|
||||||
rand_initialize_irq(client->irq);
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
goto exit_no_irq;
|
goto exit_no_irq;
|
||||||
|
/* This real unpredictable IRQ is of course sampled for entropy */
|
||||||
|
rand_initialize_irq(client->irq);
|
||||||
|
|
||||||
err = abx500_register_ops(&client->dev, &ab3100_ops);
|
err = abx500_register_ops(&client->dev, &ab3100_ops);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -962,7 +962,6 @@ static int __devinit ab3100_probe(struct i2c_client *client,
|
||||||
i2c_unregister_device(ab3100->testreg_client);
|
i2c_unregister_device(ab3100->testreg_client);
|
||||||
exit_no_testreg_client:
|
exit_no_testreg_client:
|
||||||
exit_no_detect:
|
exit_no_detect:
|
||||||
kfree(ab3100);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -972,16 +971,8 @@ static int __devexit ab3100_remove(struct i2c_client *client)
|
||||||
|
|
||||||
/* Unregister subdevices */
|
/* Unregister subdevices */
|
||||||
mfd_remove_devices(&client->dev);
|
mfd_remove_devices(&client->dev);
|
||||||
|
|
||||||
ab3100_remove_debugfs();
|
ab3100_remove_debugfs();
|
||||||
i2c_unregister_device(ab3100->testreg_client);
|
i2c_unregister_device(ab3100->testreg_client);
|
||||||
|
|
||||||
/*
|
|
||||||
* At this point, all subscribers should have unregistered
|
|
||||||
* their notifiers so deactivate IRQ
|
|
||||||
*/
|
|
||||||
free_irq(client->irq, ab3100);
|
|
||||||
kfree(ab3100);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue