Skip to content

Commit 84c8097

Browse files
Bartosz Golaszewskibroonie
authored andcommitted
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>
1 parent 81d4311 commit 84c8097

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/regulator/core.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2823,14 +2823,18 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev)
28232823
static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
28242824
{
28252825
struct regulator_enable_gpio *pin = rdev->ena_pin;
2826+
int ret;
28262827

28272828
if (!pin)
28282829
return -EINVAL;
28292830

28302831
if (enable) {
28312832
/* 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+
}
28342838

28352839
pin->enable_count++;
28362840
} else {
@@ -2841,7 +2845,10 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
28412845

28422846
/* Disable GPIO if not used */
28432847
if (pin->enable_count <= 1) {
2844-
gpiod_set_value_cansleep(pin->gpiod, 0);
2848+
ret = gpiod_set_value_cansleep(pin->gpiod, 0);
2849+
if (ret)
2850+
return ret;
2851+
28452852
pin->enable_count = 0;
28462853
}
28472854
}

0 commit comments

Comments
 (0)