]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mfd: max77686: Use devm_mfd_add_devices and devm_regmap_add_irq_chip
authorLaxman Dewangan <ldewangan@nvidia.com>
Thu, 21 Apr 2016 12:25:54 +0000 (17:55 +0530)
committerLee Jones <lee.jones@linaro.org>
Mon, 9 May 2016 12:27:20 +0000 (13:27 +0100)
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>
drivers/mfd/max77686.c

index 7a0457e1771bcdeed534e90d5d3e991aa86b9f2a..7b68ed72e9cbfcc541d4d1f50a42b7d63d3bdbd6 100644 (file)
@@ -230,37 +230,23 @@ static int max77686_i2c_probe(struct i2c_client *i2c,
                return -ENODEV;
        }
 
-       ret = regmap_add_irq_chip(max77686->regmap, max77686->irq,
-                                 IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
-                                 IRQF_SHARED, 0, irq_chip,
-                                 &max77686->irq_data);
+       ret = devm_regmap_add_irq_chip(&i2c->dev, max77686->regmap,
+                                      max77686->irq,
+                                      IRQF_TRIGGER_FALLING | IRQF_ONESHOT |
+                                      IRQF_SHARED, 0, irq_chip,
+                                      &max77686->irq_data);
        if (ret < 0) {
                dev_err(&i2c->dev, "failed to add PMIC irq chip: %d\n", ret);
                return ret;
        }
 
-       ret = mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL, 0, NULL);
+       ret = devm_mfd_add_devices(max77686->dev, -1, cells, n_devs, NULL,
+                                  0, NULL);
        if (ret < 0) {
                dev_err(&i2c->dev, "failed to add MFD devices: %d\n", ret);
-               goto err_del_irqc;
+               return ret;
        }
 
-       return 0;
-
-err_del_irqc:
-       regmap_del_irq_chip(max77686->irq, max77686->irq_data);
-
-       return ret;
-}
-
-static int max77686_i2c_remove(struct i2c_client *i2c)
-{
-       struct max77686_dev *max77686 = i2c_get_clientdata(i2c);
-
-       mfd_remove_devices(max77686->dev);
-
-       regmap_del_irq_chip(max77686->irq, max77686->irq_data);
-
        return 0;
 }
 
@@ -317,7 +303,6 @@ static struct i2c_driver max77686_i2c_driver = {
                   .of_match_table = of_match_ptr(max77686_pmic_dt_match),
        },
        .probe = max77686_i2c_probe,
-       .remove = max77686_i2c_remove,
        .id_table = max77686_i2c_id,
 };