]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: pwm_backlight: use regulator_set_enable_if_allowed
authorSvyatoslav Ryhel <clamor95@gmail.com>
Tue, 3 Oct 2023 06:25:32 +0000 (09:25 +0300)
committerAnatolij Gustschin <agust@denx.de>
Sun, 22 Oct 2023 17:23:47 +0000 (19:23 +0200)
With the commit 4fcba5d556b4 ("regulator: implement basic reference
counter") the return value of regulator_set_enable may be EALREADY or
EBUSY for fixed/gpio regulators and may be further expanded on all
regulators.

Change to use the more relaxed regulator_set_enable_if_allowed to
continue if regulator already was enabled or disabled.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
drivers/video/pwm_backlight.c

index aa0e2928666a0c2d7189d0fdcf9347d53ddade4b..1c747d98d7acfdd1d3024d3523af94e01fceff5c 100644 (file)
@@ -100,8 +100,8 @@ static int enable_sequence(struct udevice *dev, int seq)
                        plat = dev_get_uclass_plat(priv->reg);
                        log_debug("Enable '%s', regulator '%s'/'%s'\n",
                                  dev->name, priv->reg->name, plat->name);
-                       ret = regulator_set_enable(priv->reg, true);
-                       if (ret) {
+                       ret = regulator_set_enable_if_allowed(priv->reg, true);
+                       if (ret && ret != -ENOSYS) {
                                log_debug("Cannot enable regulator for PWM '%s'\n",
                                          dev->name);
                                return log_ret(ret);
@@ -181,11 +181,10 @@ static int pwm_backlight_set_brightness(struct udevice *dev, int percent)
        }
        if (disable) {
                dm_gpio_set_value(&priv->enable, 0);
-               if (priv->reg) {
-                       ret = regulator_set_enable(priv->reg, false);
-                       if (ret)
-                               return log_ret(ret);
-               }
+               ret = regulator_set_enable_if_allowed(priv->reg, false);
+               if (ret && ret != -ENOSYS)
+                       return log_ret(ret);
+
                priv->enabled = false;
        }