Video: Keep fixed/gpio regulator counter in balance
Subsystems (2)
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.
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 | 11 +++++------ drivers/video/simple_panel.c | 10 +++++----- drivers/video/tegra20/tegra-dsi.c | 8 +++----- 3 files changed, 13 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.2
PATCH 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 | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/video/pwm_backlight.c +5 -6
@@ -97,7 +97,7 @@ 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); + ret =regulator_set_enable_if_allowed (priv->reg, true);if (ret) {log_debug ("Cannot enable regulator for PWM '%s'\n" , dev->name);
@@ -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) +return log_ret (ret); + priv->enabled = false; }
Signature · 1 line
2.39.2
PATCH 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) { +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
Re: [PATCH v1 2/3] video: simple_panel: use regulator_set_enable_if_allowed
Quoted 18 lines · Svyatoslav Ryhel
With the commit
4fcba5d556b4("regulator: implement basic reference counter") the return value ofregulator_set_enablemay 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_allowedto continue if regulator already was enabled or disabled.Signed-off-by Svyatoslav Ryhel <[email protected]>--- drivers/video/simple_panel.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/video/simple_panel.c +0
-0
drivers/video/simple_panel.c static int simple_panel_probe(struct udevice *dev) · line 118
Quoted 10 lines
drivers/video/simple_panel.c +2
-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) {
Should be 'ret && ret != -ENOSYS' because you remove the CONFIG_IS_ENABLED(DM_REGULATOR) check.
Regards,
Jonas
Quoted 6 lines
drivers/video/simple_panel.c +3
-0+debug ("%s: failed to enable regulator '%s' %d\n" , + __func__, priv->reg->name, ret); +return ret; }switch (dsi_data) {
PATCH 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) +return ret;tegra_dsi_init_clocks (dev);
Signature · 1 line
2.39.2