Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: imu: inv_icm42600: Use devm_regulator_get_enable() for vdd regulator

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>

authored by

Sean Nyekjaer and committed by
Jonathan Cameron
9fd569aa 466f7a2f

+6 -24
-1
drivers/iio/imu/inv_icm42600/inv_icm42600.h
··· 167 167 enum inv_icm42600_chip chip; 168 168 const char *name; 169 169 struct regmap *map; 170 - struct regulator *vdd_supply; 171 170 struct regulator *vddio_supply; 172 171 int irq; 173 172 struct iio_mount_matrix orientation;
+6 -23
drivers/iio/imu/inv_icm42600/inv_icm42600_core.c
··· 697 697 return 0; 698 698 } 699 699 700 - static void inv_icm42600_disable_vdd_reg(void *_data) 701 - { 702 - struct inv_icm42600_state *st = _data; 703 - const struct device *dev = regmap_get_device(st->map); 704 - int ret; 705 - 706 - ret = regulator_disable(st->vdd_supply); 707 - if (ret) 708 - dev_err(dev, "failed to disable vdd error %d\n", ret); 709 - } 710 - 711 700 static void inv_icm42600_disable_vddio_reg(void *_data) 712 701 { 713 702 struct inv_icm42600_state *st = _data; ··· 754 765 return ret; 755 766 } 756 767 757 - st->vdd_supply = devm_regulator_get(dev, "vdd"); 758 - if (IS_ERR(st->vdd_supply)) 759 - return PTR_ERR(st->vdd_supply); 768 + ret = devm_regulator_get_enable(dev, "vdd"); 769 + if (ret) 770 + return dev_err_probe(dev, ret, 771 + "Failed to get vdd regulator\n"); 772 + 773 + msleep(INV_ICM42600_POWER_UP_TIME_MS); 760 774 761 775 st->vddio_supply = devm_regulator_get(dev, "vddio"); 762 776 if (IS_ERR(st->vddio_supply)) 763 777 return PTR_ERR(st->vddio_supply); 764 - 765 - ret = regulator_enable(st->vdd_supply); 766 - if (ret) 767 - return ret; 768 - msleep(INV_ICM42600_POWER_UP_TIME_MS); 769 - 770 - ret = devm_add_action_or_reset(dev, inv_icm42600_disable_vdd_reg, st); 771 - if (ret) 772 - return ret; 773 778 774 779 ret = inv_icm42600_enable_regulator_vddio(st); 775 780 if (ret)