diff mbox series

video: meson: dw-hdmi: do not fail probe if HDMI regulator is already enabled

Message ID 20241008-u-boot-video-fix-hdmi-supply-already-on-v1-1-3a12c73ff3f1@linaro.org
State Superseded
Headers show
Series video: meson: dw-hdmi: do not fail probe if HDMI regulator is already enabled | expand

Commit Message

Neil Armstrong Oct. 8, 2024, 12:58 p.m. UTC
If the regulator is already enabled, this happens if the regulator
is set in regulator-always-on, regulator_set_enable() return -EALREADY.

Ignore the -EALREADY return since it's not an error.

Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
---
 drivers/video/meson/meson_dw_hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 28dc47038edc4e93f32d75a357131bcf01a18d85
change-id: 20241008-u-boot-video-fix-hdmi-supply-already-on-e6a9af27b1eb

Best regards,

Comments

Jonas Karlman Oct. 8, 2024, 2:36 p.m. UTC | #1
Hi Neil,

On 2024-10-08 14:58, Neil Armstrong wrote:
> If the regulator is already enabled, this happens if the regulator
> is set in regulator-always-on, regulator_set_enable() return -EALREADY.
> 
> Ignore the -EALREADY return since it's not an error.
> 
> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
> ---
>  drivers/video/meson/meson_dw_hdmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/video/meson/meson_dw_hdmi.c b/drivers/video/meson/meson_dw_hdmi.c
> index 587df7beb9b..ee219ce6ec4 100644
> --- a/drivers/video/meson/meson_dw_hdmi.c
> +++ b/drivers/video/meson/meson_dw_hdmi.c
> @@ -419,7 +419,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
>  
>  	if (!ret) {
>  		ret = regulator_set_enable(supply, true);
> -		if (ret)
> +		if (ret && ret != -EALREADY)

You could possible relax this further using something like:

  ret = regulator_set_enable_if_allowed(supply, true);
  if (ret && ret != -ENOSYS)

That way you only reach the error state when there is an error with
supply, for other states e.g. when supply is not found, DM_REGULATOR=n
or the regulator is already enabled will be treated as success (ret=0).

Regards,
Jonas

>  			return ret;
>  	}
>  #endif
> 
> ---
> base-commit: 28dc47038edc4e93f32d75a357131bcf01a18d85
> change-id: 20241008-u-boot-video-fix-hdmi-supply-already-on-e6a9af27b1eb
> 
> Best regards,
Neil Armstrong Oct. 8, 2024, 3:15 p.m. UTC | #2
On 08/10/2024 16:36, Jonas Karlman wrote:
> Hi Neil,
> 
> On 2024-10-08 14:58, Neil Armstrong wrote:
>> If the regulator is already enabled, this happens if the regulator
>> is set in regulator-always-on, regulator_set_enable() return -EALREADY.
>>
>> Ignore the -EALREADY return since it's not an error.
>>
>> Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
>> ---
>>   drivers/video/meson/meson_dw_hdmi.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/meson/meson_dw_hdmi.c b/drivers/video/meson/meson_dw_hdmi.c
>> index 587df7beb9b..ee219ce6ec4 100644
>> --- a/drivers/video/meson/meson_dw_hdmi.c
>> +++ b/drivers/video/meson/meson_dw_hdmi.c
>> @@ -419,7 +419,7 @@ static int meson_dw_hdmi_probe(struct udevice *dev)
>>   
>>   	if (!ret) {
>>   		ret = regulator_set_enable(supply, true);
>> -		if (ret)
>> +		if (ret && ret != -EALREADY)
> 
> You could possible relax this further using something like:
> 
>    ret = regulator_set_enable_if_allowed(supply, true);
>    if (ret && ret != -ENOSYS)
> 
> That way you only reach the error state when there is an error with
> supply, for other states e.g. when supply is not found, DM_REGULATOR=n
> or the regulator is already enabled will be treated as success (ret=0).

Nice, thanks for the suggestion :-)

Neil

> 
> Regards,
> Jonas
> 
>>   			return ret;
>>   	}
>>   #endif
>>
>> ---
>> base-commit: 28dc47038edc4e93f32d75a357131bcf01a18d85
>> change-id: 20241008-u-boot-video-fix-hdmi-supply-already-on-e6a9af27b1eb
>>
>> Best regards,
>
diff mbox series

Patch

diff --git a/drivers/video/meson/meson_dw_hdmi.c b/drivers/video/meson/meson_dw_hdmi.c
index 587df7beb9b..ee219ce6ec4 100644
--- a/drivers/video/meson/meson_dw_hdmi.c
+++ b/drivers/video/meson/meson_dw_hdmi.c
@@ -419,7 +419,7 @@  static int meson_dw_hdmi_probe(struct udevice *dev)
 
 	if (!ret) {
 		ret = regulator_set_enable(supply, true);
-		if (ret)
+		if (ret && ret != -EALREADY)
 			return ret;
 	}
 #endif