Video: Keep fixed/gpio regulator counter in balance
Subsystems (2)
v2 cover Video: Keep fixed/gpio regulator counter in balance
The commit 4fcba5d556b4 ("regulator: implement basic reference counter") have made it more important to keep fixed/gpio regulators enable/disable state in balance.
The regulator_set_enable_if_allowed function is more relaxed and will wrap all cases where the regulator is busy, already active, missing or if DM_REGULATOR is not enabled.
These patches are an expansion of similar Jonas Karlman's patches.
---
Changes from v1:
- check return of regulator_set_enable_if_allowed for -ENOSYS to avoid error caused by disabled DM_REGULATOR (Jonas Karlman suggestion)
---
Svyatoslav Ryhel (3):
video: pwm_backlight: use regulator_set_enable_if_allowed
video: simple_panel: use regulator_set_enable_if_allowed
video: tegra20: dsi: use regulator_set_enable_if_allowed
drivers/video/pwm_backlight.c | 13 ++++++------- drivers/video/simple_panel.c | 10 +++++----- drivers/video/tegra20/tegra-dsi.c | 8 +++----- 3 files changed, 14 insertions(+), 17 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/3 video: pwm_backlight: use regulator_set_enable_if_allowed
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.
--- drivers/video/pwm_backlight.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/video/pwm_backlight.c +6 -7
@@ -97,8 +97,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);
@@ -178,11 +178,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; }
Signature · 1 line
2.39.2
PATCH v2 2/3 video: simple_panel: use regulator_set_enable_if_allowed
In reply to Svyatoslav RyhelWith 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.
--- drivers/video/simple_panel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/video/simple_panel.c +5 -5
@@ -114,11 +114,11 @@ static int simple_panel_probe(struct udevice *dev)const u32 dsi_data =dev_get_driver_data (dev);int ret; -if (CONFIG_IS_ENABLED (DM_REGULATOR ) && priv->reg) { -debug ("%s: Enable regulator '%s'\n" , __func__, priv->reg->name); - ret =regulator_set_enable (priv->reg, true); -if (ret) -return ret; + ret =regulator_set_enable_if_allowed (priv->reg, true); +if (ret && ret != -ENOSYS ) { +debug ("%s: failed to enable regulator '%s' %d\n" , + __func__, priv->reg->name, ret); +return ret; }switch (dsi_data) {
Signature · 1 line
2.39.2
PATCH v2 3/3 video: tegra20: dsi: use regulator_set_enable_if_allowed
In reply to Svyatoslav RyhelWith 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.
--- drivers/video/tegra20/tegra-dsi.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/video/tegra20/tegra-dsi.c +3 -5
@@ -831,11 +831,9 @@ static int tegra_dsi_bridge_probe(struct udevice *dev)tegra_dsi_get_format (device->format, &priv->format); -if (priv->avdd) { - ret =regulator_set_enable (priv->avdd, true); -if (ret) -return ret; - } + ret =regulator_set_enable_if_allowed (priv->avdd, true); +if (ret && ret != -ENOSYS ) +return ret;tegra_dsi_init_clocks (dev);
Signature · 1 line
2.39.2