summaryrefslogtreecommitdiffstats
path: root/drivers/mfd/max77686.c
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2016-04-21 08:25:54 -0400
committerLee Jones <lee.jones@linaro.org>2016-05-09 08:27:20 -0400
commit1a5422c9e56a20898a73da5726d935d5d8072f78 (patch)
tree5175859be940d52244a9c6d61ec5bc93bd3770d8 /drivers/mfd/max77686.c
parent0bbfb87c567d982fd698b41e9fb68478727460f9 (diff)
mfd: max77686: Use devm_mfd_add_devices and devm_regmap_add_irq_chip
Use devm_mfd_add_devices() for adding MFD child devices and devm_regmap_add_irq_chip() for IRQ chip registration. This reduces the error code path and .remove callback for removing MFD child devices and deleting IRQ chip data. Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/max77686.c')
-rw-r--r--drivers/mfd/max77686.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/mfd/max77686.c b/drivers/mfd/max77686.c
index 7a0457e1771b..7b68ed72e9cb 100644
--- a/drivers/mfd/max77686.c
+++ b/drivers/mfd/max77686.c
@@ -230,38 +230,24 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
230 return -ENODEV; 230 return -ENODEV;
231 } 231 }
232 232
233 ret = regmap_add_irq_chip(max77686->regmap, max77686->irq, 233 ret = devm_regmap_add_irq_chip(&i2c->dev, max77686->regmap,
234 IRQF_TRIGGER_FALLING | IRQF_ONESHOT | 234 max77686->irq,
235 IRQF_SHARED, 0, irq_chip, 235 IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
236 &max77686->irq_data); 236 IRQF_SHARED, 0, irq_chip,
237 &max77686->irq_data);
237 if (ret < 0) { 238 if (ret < 0) {
238 dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret); 239 dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
239 return ret; 240 return ret;
240 } 241 }
241 242
242 ret = mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL, 0, NULL); 243 ret = devm_mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL,
244 0, NULL);
243 if (ret < 0) { 245 if (ret < 0) {
244 dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret); 246 dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
245 goto err_del_irqc; 247 return ret;
246 } 248 }
247 249
248 return 0; 250 return 0;
249
250err_del_irqc:
251 regmap_del_irq_chip(max77686->irq, max77686->irq_data);
252
253 return ret;
254}
255
256static int max77686_i2c_remove(struct i2c_client *i2c)
257{
258 struct max77686_dev *max77686 = i2c_get_clientdata(i2c);
259
260 mfd_remove_devices(max77686->dev);
261
262 regmap_del_irq_chip(max77686->irq, max77686->irq_data);
263
264 return 0;
265} 251}
266 252
267static const struct i2c_device_id max77686_i2c_id[] = { 253static const struct i2c_device_id max77686_i2c_id[] = {
@@ -317,7 +303,6 @@ static struct i2c_driver max77686_i2c_driver = {
317 .of_match_table = of_match_ptr(max77686_pmic_dt_match), 303 .of_match_table = of_match_ptr(max77686_pmic_dt_match),
318 }, 304 },
319 .probe = max77686_i2c_probe, 305 .probe = max77686_i2c_probe,
320 .remove = max77686_i2c_remove,
321 .id_table = max77686_i2c_id, 306 .id_table = max77686_i2c_id,
322}; 307};
323 308