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>
master
Bartosz Golaszewski 2025-12-03 09:47:37 +01:00 committed by Mark Brown
parent 81d431130a
commit 84c8097e67
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0
1 changed files with 10 additions and 3 deletions

View File

@ -2823,14 +2823,18 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev)
static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
{
struct regulator_enable_gpio *pin = rdev->ena_pin;
int ret;
if (!pin)
return -EINVAL;
if (enable) {
/* Enable GPIO at initial use */
if (pin->enable_count == 0)
gpiod_set_value_cansleep(pin->gpiod, 1);
if (pin->enable_count == 0) {
ret = gpiod_set_value_cansleep(pin->gpiod, 1);
if (ret)
return ret;
}
pin->enable_count++;
} else {
@ -2841,7 +2845,10 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
/* Disable GPIO if not used */
if (pin->enable_count <= 1) {
gpiod_set_value_cansleep(pin->gpiod, 0);
ret = gpiod_set_value_cansleep(pin->gpiod, 0);
if (ret)
return ret;
pin->enable_count = 0;
}
}