mfd: rc5t583: Use devm_mfd_add_devices and devm_request_threaded_irq

Use devm_mfd_add_devices() for adding MFD child devices and
devm_request_threaded_irq() for IRQ registration.

This reduces the need of remove callback for removing MFD child
devices and unregistering IRQ.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
This commit is contained in:
Laxman Dewangan 2016-04-21 17:55:55 +05:30 committed by Lee Jones
parent 1a5422c9e5
commit b36c82724f
2 changed files with 5 additions and 30 deletions

View File

@ -389,17 +389,10 @@ int rc5t583_irq_init(struct rc5t583 *rc5t583, int irq, int irq_base)
irq_clear_status_flags(__irq, IRQ_NOREQUEST); irq_clear_status_flags(__irq, IRQ_NOREQUEST);
} }
ret = request_threaded_irq(irq, NULL, rc5t583_irq, IRQF_ONESHOT, ret = devm_request_threaded_irq(rc5t583->dev, irq, NULL, rc5t583_irq,
"rc5t583", rc5t583); IRQF_ONESHOT, "rc5t583", rc5t583);
if (ret < 0) if (ret < 0)
dev_err(rc5t583->dev, dev_err(rc5t583->dev,
"Error in registering interrupt error: %d\n", ret); "Error in registering interrupt error: %d\n", ret);
return ret; return ret;
} }
int rc5t583_irq_exit(struct rc5t583 *rc5t583)
{
if (rc5t583->chip_irq)
free_irq(rc5t583->chip_irq, rc5t583);
return 0;
}

View File

@ -252,7 +252,6 @@ static int rc5t583_i2c_probe(struct i2c_client *i2c,
struct rc5t583 *rc5t583; struct rc5t583 *rc5t583;
struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rc5t583_platform_data *pdata = dev_get_platdata(&i2c->dev);
int ret; int ret;
bool irq_init_success = false;
if (!pdata) { if (!pdata) {
dev_err(&i2c->dev, "Err: Platform data not found\n"); dev_err(&i2c->dev, "Err: Platform data not found\n");
@ -284,31 +283,15 @@ static int rc5t583_i2c_probe(struct i2c_client *i2c,
/* Still continue with warning, if irq init fails */ /* Still continue with warning, if irq init fails */
if (ret) if (ret)
dev_warn(&i2c->dev, "IRQ init failed: %d\n", ret); dev_warn(&i2c->dev, "IRQ init failed: %d\n", ret);
else
irq_init_success = true;
} }
ret = mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs, ret = devm_mfd_add_devices(rc5t583->dev, -1, rc5t583_subdevs,
ARRAY_SIZE(rc5t583_subdevs), NULL, 0, NULL); ARRAY_SIZE(rc5t583_subdevs), NULL, 0, NULL);
if (ret) { if (ret) {
dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret); dev_err(&i2c->dev, "add mfd devices failed: %d\n", ret);
goto err_add_devs;
}
return 0;
err_add_devs:
if (irq_init_success)
rc5t583_irq_exit(rc5t583);
return ret; return ret;
} }
static int rc5t583_i2c_remove(struct i2c_client *i2c)
{
struct rc5t583 *rc5t583 = i2c_get_clientdata(i2c);
mfd_remove_devices(rc5t583->dev);
rc5t583_irq_exit(rc5t583);
return 0; return 0;
} }
@ -324,7 +307,6 @@ static struct i2c_driver rc5t583_i2c_driver = {
.name = "rc5t583", .name = "rc5t583",
}, },
.probe = rc5t583_i2c_probe, .probe = rc5t583_i2c_probe,
.remove = rc5t583_i2c_remove,
.id_table = rc5t583_i2c_id, .id_table = rc5t583_i2c_id,
}; };