]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mfd: tps65912: Use devm helper functions to simplify probe
authorAndrew Davis <afd@ti.com>
Thu, 13 Jun 2024 17:54:30 +0000 (12:54 -0500)
committerLee Jones <lee@kernel.org>
Thu, 4 Jul 2024 16:38:40 +0000 (17:38 +0100)
This simplifies probe and also allows us to remove the remove
callbacks from the core and interface drivers. Do that here.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240613175430.57698-1-afd@ti.com
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/tps65912-core.c
drivers/mfd/tps65912-i2c.c
drivers/mfd/tps65912-spi.c
include/linux/mfd/tps65912.h

index 2305ea60367ac32c87c8bea709404035b1199c68..87ee6aac376363cff728331fbd199c6a2d7d7c26 100644 (file)
@@ -90,29 +90,22 @@ int tps65912_device_init(struct tps65912 *tps)
 {
        int ret;
 
-       ret = regmap_add_irq_chip(tps->regmap, tps->irq, IRQF_ONESHOT, 0,
-                                 &tps65912_irq_chip, &tps->irq_data);
+       ret = devm_regmap_add_irq_chip(tps->dev, tps->regmap, tps->irq,
+                                      IRQF_ONESHOT, 0, &tps65912_irq_chip,
+                                      &tps->irq_data);
        if (ret)
                return ret;
 
-       ret = mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65912_cells,
-                             ARRAY_SIZE(tps65912_cells), NULL, 0,
-                             regmap_irq_get_domain(tps->irq_data));
-       if (ret) {
-               regmap_del_irq_chip(tps->irq, tps->irq_data);
+       ret = devm_mfd_add_devices(tps->dev, PLATFORM_DEVID_AUTO, tps65912_cells,
+                                  ARRAY_SIZE(tps65912_cells), NULL, 0,
+                                  regmap_irq_get_domain(tps->irq_data));
+       if (ret)
                return ret;
-       }
 
        return 0;
 }
 EXPORT_SYMBOL_GPL(tps65912_device_init);
 
-void tps65912_device_exit(struct tps65912 *tps)
-{
-       regmap_del_irq_chip(tps->irq, tps->irq_data);
-}
-EXPORT_SYMBOL_GPL(tps65912_device_exit);
-
 MODULE_AUTHOR("Andrew F. Davis <afd@ti.com>");
 MODULE_DESCRIPTION("TPS65912x MFD Driver");
 MODULE_LICENSE("GPL v2");
index 3cc1bc68be7c3ef23c0223e8bba1a3b8cd4d1b2d..138e50497b5141d617f027cca8dd464cd67b9e5d 100644 (file)
@@ -42,13 +42,6 @@ static int tps65912_i2c_probe(struct i2c_client *client)
        return tps65912_device_init(tps);
 }
 
-static void tps65912_i2c_remove(struct i2c_client *client)
-{
-       struct tps65912 *tps = i2c_get_clientdata(client);
-
-       tps65912_device_exit(tps);
-}
-
 static const struct i2c_device_id tps65912_i2c_id_table[] = {
        { "tps65912" },
        { /* sentinel */ }
@@ -61,7 +54,6 @@ static struct i2c_driver tps65912_i2c_driver = {
                .of_match_table = tps65912_i2c_of_match_table,
        },
        .probe          = tps65912_i2c_probe,
-       .remove         = tps65912_i2c_remove,
        .id_table       = tps65912_i2c_id_table,
 };
 module_i2c_driver(tps65912_i2c_driver);
index 9e976f9c6bbe3b712a16046d5164d7b33cafc5ac..2a77dccd60599e63803baf970c025662ab635afe 100644 (file)
@@ -42,13 +42,6 @@ static int tps65912_spi_probe(struct spi_device *spi)
        return tps65912_device_init(tps);
 }
 
-static void tps65912_spi_remove(struct spi_device *spi)
-{
-       struct tps65912 *tps = spi_get_drvdata(spi);
-
-       tps65912_device_exit(tps);
-}
-
 static const struct spi_device_id tps65912_spi_id_table[] = {
        { "tps65912", 0 },
        { /* sentinel */ }
@@ -61,7 +54,6 @@ static struct spi_driver tps65912_spi_driver = {
                .of_match_table = tps65912_spi_of_match_table,
        },
        .probe          = tps65912_spi_probe,
-       .remove         = tps65912_spi_remove,
        .id_table       = tps65912_spi_id_table,
 };
 module_spi_driver(tps65912_spi_driver);
index 860ec0a16c9639d7571eea57387fecfc7628fe6a..e5373c302722c9db050b31b03b06708c3ec72fca 100644 (file)
@@ -314,6 +314,5 @@ struct tps65912 {
 extern const struct regmap_config tps65912_regmap_config;
 
 int tps65912_device_init(struct tps65912 *tps);
-void tps65912_device_exit(struct tps65912 *tps);
 
 #endif /*  __LINUX_MFD_TPS65912_H */