mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: platform: don't fail of_find_device_by_node() if no driver bound
@ 2023-09-14  7:30 Ahmad Fatoum
  2023-09-26 11:38 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2023-09-14  7:30 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

of_find_device_by_node() may be called by a driver following
of_platform_populate in order to bind the children to drivers.
It's thus wrong to return NULL when a device has been found, but no
driver was registered. That also aligns the function with the
expectation resulting from its name: A device is found and devices may
be bound or not.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/of/platform.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index bd5f2ad82c6b..1f79a539f541 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -23,11 +23,9 @@
 struct device *of_find_device_by_node(struct device_node *np)
 {
 	struct device *dev;
-	int ret;
 
-	ret = of_device_ensure_probed(np);
-	if (ret)
-		return NULL;
+	/* Not having a driver is not an error here */
+	(void)of_device_ensure_probed(np);
 
 	if (deep_probe_is_supported())
 		return np->dev;
-- 
2.39.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] of: platform: don't fail of_find_device_by_node() if no driver bound
  2023-09-14  7:30 [PATCH] of: platform: don't fail of_find_device_by_node() if no driver bound Ahmad Fatoum
@ 2023-09-26 11:38 ` Sascha Hauer
  2023-10-05  6:53   ` Ahmad Fatoum
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2023-09-26 11:38 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Thu, Sep 14, 2023 at 09:30:18AM +0200, Ahmad Fatoum wrote:
> of_find_device_by_node() may be called by a driver following
> of_platform_populate in order to bind the children to drivers.
> It's thus wrong to return NULL when a device has been found, but no
> driver was registered. That also aligns the function with the
> expectation resulting from its name: A device is found and devices may
> be bound or not.

I hesitated applying this one because I am not sure if some users expect
to have a driver bound when of_find_device_by_node() returns a valid
pointer.

I applied it now, let's see what happens.

Sascha

> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/of/platform.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index bd5f2ad82c6b..1f79a539f541 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -23,11 +23,9 @@
>  struct device *of_find_device_by_node(struct device_node *np)
>  {
>  	struct device *dev;
> -	int ret;
>  
> -	ret = of_device_ensure_probed(np);
> -	if (ret)
> -		return NULL;
> +	/* Not having a driver is not an error here */
> +	(void)of_device_ensure_probed(np);
>  
>  	if (deep_probe_is_supported())
>  		return np->dev;
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] of: platform: don't fail of_find_device_by_node() if no driver bound
  2023-09-26 11:38 ` Sascha Hauer
@ 2023-10-05  6:53   ` Ahmad Fatoum
  0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-10-05  6:53 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

Hello Sascha,

On 26.09.23 13:38, Sascha Hauer wrote:
> On Thu, Sep 14, 2023 at 09:30:18AM +0200, Ahmad Fatoum wrote:
>> of_find_device_by_node() may be called by a driver following
>> of_platform_populate in order to bind the children to drivers.
>> It's thus wrong to return NULL when a device has been found, but no
>> driver was registered. That also aligns the function with the
>> expectation resulting from its name: A device is found and devices may
>> be bound or not.
> 
> I hesitated applying this one because I am not sure if some users expect
> to have a driver bound when of_find_device_by_node() returns a valid
> pointer.
> 
> I applied it now, let's see what happens.

I ran into this porting the CAAM driver to work on i.MX8M. I don't know
if existing drivers are affected, but it's the correct thing to do.

> 
> Sascha
> 
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>  drivers/of/platform.c | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
>> index bd5f2ad82c6b..1f79a539f541 100644
>> --- a/drivers/of/platform.c
>> +++ b/drivers/of/platform.c
>> @@ -23,11 +23,9 @@
>>  struct device *of_find_device_by_node(struct device_node *np)
>>  {
>>  	struct device *dev;
>> -	int ret;
>>  
>> -	ret = of_device_ensure_probed(np);
>> -	if (ret)
>> -		return NULL;
>> +	/* Not having a driver is not an error here */
>> +	(void)of_device_ensure_probed(np);
>>  
>>  	if (deep_probe_is_supported())
>>  		return np->dev;
>> -- 
>> 2.39.2
>>
>>
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-05  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-14  7:30 [PATCH] of: platform: don't fail of_find_device_by_node() if no driver bound Ahmad Fatoum
2023-09-26 11:38 ` Sascha Hauer
2023-10-05  6:53   ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox