[PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()

Sui Jingfeng posted 1 patch 2 years, 3 months ago
drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)
[PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Sui Jingfeng 2 years, 3 months ago
To reduce boilerplate, use of_graph_get_remote_node() helper instead of
the hand-rolling code.

Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
---
 drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
index d4c1a601bbb5..5f99f9724081 100644
--- a/drivers/gpu/drm/bridge/thc63lvd1024.c
+++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
@@ -123,28 +123,10 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
 	struct device_node *endpoint;
 	struct device_node *remote;
 
-	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
-						 THC63_RGB_OUT0, -1);
-	if (!endpoint) {
-		dev_err(thc63->dev, "Missing endpoint in port@%u\n",
-			THC63_RGB_OUT0);
-		return -ENODEV;
-	}
-
-	remote = of_graph_get_remote_port_parent(endpoint);
-	of_node_put(endpoint);
-	if (!remote) {
-		dev_err(thc63->dev, "Endpoint in port@%u unconnected\n",
-			THC63_RGB_OUT0);
+	remote = of_graph_get_remote_node(thc63->dev->of_node,
+					  THC63_RGB_OUT0, -1);
+	if (!remote)
 		return -ENODEV;
-	}
-
-	if (!of_device_is_available(remote)) {
-		dev_err(thc63->dev, "port@%u remote endpoint is disabled\n",
-			THC63_RGB_OUT0);
-		of_node_put(remote);
-		return -ENODEV;
-	}
 
 	thc63->next = of_drm_find_bridge(remote);
 	of_node_put(remote);
-- 
2.34.1
Re: [PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Laurent Pinchart 2 years, 3 months ago
Hi Sui,

Thank you for the patch.

On Sun, Mar 17, 2024 at 01:28:00AM +0800, Sui Jingfeng wrote:
> To reduce boilerplate, use of_graph_get_remote_node() helper instead of
> the hand-rolling code.
> 
> Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
> ---
>  drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
> index d4c1a601bbb5..5f99f9724081 100644
> --- a/drivers/gpu/drm/bridge/thc63lvd1024.c
> +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
> @@ -123,28 +123,10 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
>  	struct device_node *endpoint;
>  	struct device_node *remote;
>  
> -	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
> -						 THC63_RGB_OUT0, -1);
> -	if (!endpoint) {
> -		dev_err(thc63->dev, "Missing endpoint in port@%u\n",
> -			THC63_RGB_OUT0);
> -		return -ENODEV;
> -	}
> -
> -	remote = of_graph_get_remote_port_parent(endpoint);
> -	of_node_put(endpoint);
> -	if (!remote) {
> -		dev_err(thc63->dev, "Endpoint in port@%u unconnected\n",
> -			THC63_RGB_OUT0);
> +	remote = of_graph_get_remote_node(thc63->dev->of_node,
> +					  THC63_RGB_OUT0, -1);
> +	if (!remote)

The old logic is equivalent to of_graph_get_remote_node(), but now the
driver will fail probing without an error message. That's not very nice
as it leads to difficult to debug problems. I would keep one dev_err()
here:

		dev_err(thc63->dev, "No remote endpoint for port@%u\n",
			THC63_RGB_OUT0);

As your patch has been merged already, would you like to post a
follow-up patch to fix this ?

>  		return -ENODEV;
> -	}
> -
> -	if (!of_device_is_available(remote)) {
> -		dev_err(thc63->dev, "port@%u remote endpoint is disabled\n",
> -			THC63_RGB_OUT0);
> -		of_node_put(remote);
> -		return -ENODEV;
> -	}
>  
>  	thc63->next = of_drm_find_bridge(remote);
>  	of_node_put(remote);

-- 
Regards,

Laurent Pinchart
Re: [PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Sui Jingfeng 2 years, 3 months ago
Hi,


On 2024/3/18 23:33, Laurent Pinchart wrote:
> Hi Sui,
>
> Thank you for the patch.
>
> On Sun, Mar 17, 2024 at 01:28:00AM +0800, Sui Jingfeng wrote:
>> To reduce boilerplate, use of_graph_get_remote_node() helper instead of
>> the hand-rolling code.
>>
>> Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
>> ---
>>   drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
>>   1 file changed, 3 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
>> index d4c1a601bbb5..5f99f9724081 100644
>> --- a/drivers/gpu/drm/bridge/thc63lvd1024.c
>> +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
>> @@ -123,28 +123,10 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
>>   	struct device_node *endpoint;
>>   	struct device_node *remote;
>>   
>> -	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
>> -						 THC63_RGB_OUT0, -1);
>> -	if (!endpoint) {
>> -		dev_err(thc63->dev, "Missing endpoint in port@%u\n",
>> -			THC63_RGB_OUT0);
>> -		return -ENODEV;
>> -	}
>> -
>> -	remote = of_graph_get_remote_port_parent(endpoint);
>> -	of_node_put(endpoint);
>> -	if (!remote) {
>> -		dev_err(thc63->dev, "Endpoint in port@%u unconnected\n",
>> -			THC63_RGB_OUT0);
>> +	remote = of_graph_get_remote_node(thc63->dev->of_node,
>> +					  THC63_RGB_OUT0, -1);
>> +	if (!remote)
> The old logic is equivalent to of_graph_get_remote_node(), but now the
> driver will fail probing without an error message. That's not very nice
> as it leads to difficult to debug problems. I would keep one dev_err()
> here:
>
> 		dev_err(thc63->dev, "No remote endpoint for port@%u\n",
> 			THC63_RGB_OUT0);
>
> As your patch has been merged already, would you like to post a
> follow-up patch to fix this ?


Yes, this is indeed a difference. I will post a follow-up patch to fix this.


>>   		return -ENODEV;
>> -	}
>> -
>> -	if (!of_device_is_available(remote)) {
>> -		dev_err(thc63->dev, "port@%u remote endpoint is disabled\n",
>> -			THC63_RGB_OUT0);
>> -		of_node_put(remote);
>> -		return -ENODEV;
>> -	}
>>   
>>   	thc63->next = of_drm_find_bridge(remote);
>>   	of_node_put(remote);

-- 
Best regards,
Sui
Re: [PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Laurent Pinchart 2 years, 3 months ago
On Mon, Mar 18, 2024 at 11:53:11PM +0800, Sui Jingfeng wrote:
> On 2024/3/18 23:33, Laurent Pinchart wrote:
> > On Sun, Mar 17, 2024 at 01:28:00AM +0800, Sui Jingfeng wrote:
> >> To reduce boilerplate, use of_graph_get_remote_node() helper instead of
> >> the hand-rolling code.
> >>
> >> Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
> >> ---
> >>   drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
> >>   1 file changed, 3 insertions(+), 21 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
> >> index d4c1a601bbb5..5f99f9724081 100644
> >> --- a/drivers/gpu/drm/bridge/thc63lvd1024.c
> >> +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
> >> @@ -123,28 +123,10 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
> >>   	struct device_node *endpoint;
> >>   	struct device_node *remote;
> >>   
> >> -	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
> >> -						 THC63_RGB_OUT0, -1);
> >> -	if (!endpoint) {
> >> -		dev_err(thc63->dev, "Missing endpoint in port@%u\n",
> >> -			THC63_RGB_OUT0);
> >> -		return -ENODEV;
> >> -	}
> >> -
> >> -	remote = of_graph_get_remote_port_parent(endpoint);
> >> -	of_node_put(endpoint);
> >> -	if (!remote) {
> >> -		dev_err(thc63->dev, "Endpoint in port@%u unconnected\n",
> >> -			THC63_RGB_OUT0);
> >> +	remote = of_graph_get_remote_node(thc63->dev->of_node,
> >> +					  THC63_RGB_OUT0, -1);
> >> +	if (!remote)
> > The old logic is equivalent to of_graph_get_remote_node(), but now the
> > driver will fail probing without an error message. That's not very nice
> > as it leads to difficult to debug problems. I would keep one dev_err()
> > here:
> >
> > 		dev_err(thc63->dev, "No remote endpoint for port@%u\n",
> > 			THC63_RGB_OUT0);
> >
> > As your patch has been merged already, would you like to post a
> > follow-up patch to fix this ?
> 
> Yes, this is indeed a difference. I will post a follow-up patch to fix this.

I'm actually build-testing a patch I already wrote :-) I'll post it in a
moment.

> >>   		return -ENODEV;
> >> -	}
> >> -
> >> -	if (!of_device_is_available(remote)) {
> >> -		dev_err(thc63->dev, "port@%u remote endpoint is disabled\n",
> >> -			THC63_RGB_OUT0);
> >> -		of_node_put(remote);
> >> -		return -ENODEV;
> >> -	}
> >>   
> >>   	thc63->next = of_drm_find_bridge(remote);
> >>   	of_node_put(remote);

-- 
Regards,

Laurent Pinchart
Re: [PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Sui Jingfeng 2 years, 3 months ago
Hi,


On 2024/3/18 23:57, Laurent Pinchart wrote:
> On Mon, Mar 18, 2024 at 11:53:11PM +0800, Sui Jingfeng wrote:
>> On 2024/3/18 23:33, Laurent Pinchart wrote:
>>> On Sun, Mar 17, 2024 at 01:28:00AM +0800, Sui Jingfeng wrote:
>>>> To reduce boilerplate, use of_graph_get_remote_node() helper instead of
>>>> the hand-rolling code.
>>>>
>>>> Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
>>>> ---
>>>>    drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
>>>>    1 file changed, 3 insertions(+), 21 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/bridge/thc63lvd1024.c b/drivers/gpu/drm/bridge/thc63lvd1024.c
>>>> index d4c1a601bbb5..5f99f9724081 100644
>>>> --- a/drivers/gpu/drm/bridge/thc63lvd1024.c
>>>> +++ b/drivers/gpu/drm/bridge/thc63lvd1024.c
>>>> @@ -123,28 +123,10 @@ static int thc63_parse_dt(struct thc63_dev *thc63)
>>>>    	struct device_node *endpoint;
>>>>    	struct device_node *remote;
>>>>    
>>>> -	endpoint = of_graph_get_endpoint_by_regs(thc63->dev->of_node,
>>>> -						 THC63_RGB_OUT0, -1);
>>>> -	if (!endpoint) {
>>>> -		dev_err(thc63->dev, "Missing endpoint in port@%u\n",
>>>> -			THC63_RGB_OUT0);
>>>> -		return -ENODEV;
>>>> -	}
>>>> -
>>>> -	remote = of_graph_get_remote_port_parent(endpoint);
>>>> -	of_node_put(endpoint);
>>>> -	if (!remote) {
>>>> -		dev_err(thc63->dev, "Endpoint in port@%u unconnected\n",
>>>> -			THC63_RGB_OUT0);
>>>> +	remote = of_graph_get_remote_node(thc63->dev->of_node,
>>>> +					  THC63_RGB_OUT0, -1);
>>>> +	if (!remote)
>>> The old logic is equivalent to of_graph_get_remote_node(), but now the
>>> driver will fail probing without an error message. That's not very nice
>>> as it leads to difficult to debug problems. I would keep one dev_err()
>>> here:
>>>
>>> 		dev_err(thc63->dev, "No remote endpoint for port@%u\n",
>>> 			THC63_RGB_OUT0);
>>>
>>> As your patch has been merged already, would you like to post a
>>> follow-up patch to fix this ?
>> Yes, this is indeed a difference. I will post a follow-up patch to fix this.
> I'm actually build-testing a patch I already wrote :-) I'll post it in a
> moment.


OK, then.


>>>>    		return -ENODEV;
>>>> -	}
>>>> -
>>>> -	if (!of_device_is_available(remote)) {
>>>> -		dev_err(thc63->dev, "port@%u remote endpoint is disabled\n",
>>>> -			THC63_RGB_OUT0);
>>>> -		of_node_put(remote);
>>>> -		return -ENODEV;
>>>> -	}
>>>>    
>>>>    	thc63->next = of_drm_find_bridge(remote);
>>>>    	of_node_put(remote);

-- 
Best regards,
Sui
Re: [PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Neil Armstrong 2 years, 3 months ago
Hi,

On Sun, 17 Mar 2024 01:28:00 +0800, Sui Jingfeng wrote:
> To reduce boilerplate, use of_graph_get_remote_node() helper instead of
> the hand-rolling code.
> 
> 

Thanks, Applied to https://gitlab.freedesktop.org/drm/misc/kernel.git (drm-misc-next)

[1/1] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
      https://gitlab.freedesktop.org/drm/misc/kernel/-/commit/00084f0c01bf3a2591d007010b196e048281c455

-- 
Neil
Re: [PATCH] drm: bridge: thc63lvd1024: Switch to use of_graph_get_remote_node()
Posted by Dmitry Baryshkov 2 years, 3 months ago
On Sat, 16 Mar 2024 at 19:28, Sui Jingfeng <sui.jingfeng@linux.dev> wrote:
>
> To reduce boilerplate, use of_graph_get_remote_node() helper instead of
> the hand-rolling code.
>
> Signed-off-by: Sui Jingfeng <sui.jingfeng@linux.dev>
> ---
>  drivers/gpu/drm/bridge/thc63lvd1024.c | 24 +++---------------------
>  1 file changed, 3 insertions(+), 21 deletions(-)

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

-- 
With best wishes
Dmitry