]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
iio: imu: inv_icm42600: Use devm_regulator_get_enable() for vdd regulator
authorSean Nyekjaer <sean@geanix.com>
Mon, 1 Sep 2025 07:49:16 +0000 (09:49 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 10 Sep 2025 18:47:06 +0000 (19:47 +0100)
The vdd regulator is not used for runtime power management, so it does
not need explicit enable/disable handling.
Use devm_regulator_get_enable() to let the regulator be managed
automatically by devm.

This simplifies the code by removing the manual enable and cleanup
logic.

Signed-off-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250901-icm42pmreg-v3-4-ef1336246960@geanix.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/imu/inv_icm42600/inv_icm42600.h
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c

index 1430ab4f1dea5d5ba6277d74275fc44a6cd30eb8..c8b48a5c5ed0677bb35201d32934936faaf7a1a6 100644 (file)
@@ -167,7 +167,6 @@ struct inv_icm42600_state {
        enum inv_icm42600_chip chip;
        const char *name;
        struct regmap *map;
-       struct regulator *vdd_supply;
        struct regulator *vddio_supply;
        int irq;
        struct iio_mount_matrix orientation;
index ee780f530dc8612cd25dc2216b153ef4e8c32b7b..4bf436c46f1cfd7e7e1bb911d94a0a566d63e791 100644 (file)
@@ -697,17 +697,6 @@ static int inv_icm42600_enable_regulator_vddio(struct inv_icm42600_state *st)
        return 0;
 }
 
-static void inv_icm42600_disable_vdd_reg(void *_data)
-{
-       struct inv_icm42600_state *st = _data;
-       const struct device *dev = regmap_get_device(st->map);
-       int ret;
-
-       ret = regulator_disable(st->vdd_supply);
-       if (ret)
-               dev_err(dev, "failed to disable vdd error %d\n", ret);
-}
-
 static void inv_icm42600_disable_vddio_reg(void *_data)
 {
        struct inv_icm42600_state *st = _data;
@@ -765,23 +754,17 @@ int inv_icm42600_core_probe(struct regmap *regmap, int chip,
                return ret;
        }
 
-       st->vdd_supply = devm_regulator_get(dev, "vdd");
-       if (IS_ERR(st->vdd_supply))
-               return PTR_ERR(st->vdd_supply);
+       ret = devm_regulator_get_enable(dev, "vdd");
+       if (ret)
+               return dev_err_probe(dev, ret,
+                                    "Failed to get vdd regulator\n");
+
+       msleep(INV_ICM42600_POWER_UP_TIME_MS);
 
        st->vddio_supply = devm_regulator_get(dev, "vddio");
        if (IS_ERR(st->vddio_supply))
                return PTR_ERR(st->vddio_supply);
 
-       ret = regulator_enable(st->vdd_supply);
-       if (ret)
-               return ret;
-       msleep(INV_ICM42600_POWER_UP_TIME_MS);
-
-       ret = devm_add_action_or_reset(dev, inv_icm42600_disable_vdd_reg, st);
-       if (ret)
-               return ret;
-
        ret = inv_icm42600_enable_regulator_vddio(st);
        if (ret)
                return ret;