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

regulator: check the return value of gpiod_set_value_cansleep()

gpiod_set_value_cansleep() now returns an integer and can indicate
failures in the GPIO layer. Propagate any potential errors to regulator
core.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20251203084737.15891-1-bartosz.golaszewski@oss.qualcomm.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Bartosz Golaszewski and committed by
Mark Brown
84c8097e 81d43113

+10 -3
+10 -3
drivers/regulator/core.c
··· 2823 2823 static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable) 2824 2824 { 2825 2825 struct regulator_enable_gpio *pin = rdev->ena_pin; 2826 + int ret; 2826 2827 2827 2828 if (!pin) 2828 2829 return -EINVAL; 2829 2830 2830 2831 if (enable) { 2831 2832 /* Enable GPIO at initial use */ 2832 - if (pin->enable_count == 0) 2833 - gpiod_set_value_cansleep(pin->gpiod, 1); 2833 + if (pin->enable_count == 0) { 2834 + ret = gpiod_set_value_cansleep(pin->gpiod, 1); 2835 + if (ret) 2836 + return ret; 2837 + } 2834 2838 2835 2839 pin->enable_count++; 2836 2840 } else { ··· 2845 2841 2846 2842 /* Disable GPIO if not used */ 2847 2843 if (pin->enable_count <= 1) { 2848 - gpiod_set_value_cansleep(pin->gpiod, 0); 2844 + ret = gpiod_set_value_cansleep(pin->gpiod, 0); 2845 + if (ret) 2846 + return ret; 2847 + 2849 2848 pin->enable_count = 0; 2850 2849 } 2851 2850 }