mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] of: platform: propagate of_devices_ensure_probed_by(name|property) errors
@ 2022-09-05 11:59 Ahmad Fatoum
  2022-09-12  8:50 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2022-09-05 11:59 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The of_devices_ensure_probed_by functions are expected to return an
error code after iterating over all matching devices should any device
have failed its of_device_ensure_probed. Doing this unearths one common
failure: a matching node has status = "disabled". These will have
of_device_ensure_probed return -ENODEV, which makes sense for users
wanting to ensure a specific device is probed, but doesn't when
iterating over multiple nodes.

We already have of_devices_ensure_probed_by_dev_id, which does an early
of_device_is_available check, so do likewise for the other to
ensure_probed_by_* functions.

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

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index dc784ea8e550..a9a5d4c2daf2 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -525,12 +525,15 @@ int of_devices_ensure_probed_by_property(const char *property_name)
 		return 0;
 
 	for_each_node_with_property(node, property_name) {
-		ret = of_device_ensure_probed(node);
+		if (!of_device_is_available(node))
+			continue;
+
+		err = of_device_ensure_probed(node);
 		if (err)
 			ret = err;
 	}
 
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_property);
 
@@ -543,12 +546,15 @@ int of_devices_ensure_probed_by_name(const char *name)
 		return 0;
 
 	for_each_node_by_name(node, name) {
-		ret = of_device_ensure_probed(node);
+		if (!of_device_is_available(node))
+			continue;
+
+		err = of_device_ensure_probed(node);
 		if (err)
 			ret = err;
 	}
 
-	return 0;
+	return ret;
 }
 EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_name);
 
-- 
2.30.2




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

* Re: [PATCH] of: platform: propagate of_devices_ensure_probed_by(name|property) errors
  2022-09-05 11:59 [PATCH] of: platform: propagate of_devices_ensure_probed_by(name|property) errors Ahmad Fatoum
@ 2022-09-12  8:50 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2022-09-12  8:50 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Sep 05, 2022 at 01:59:44PM +0200, Ahmad Fatoum wrote:
> The of_devices_ensure_probed_by functions are expected to return an
> error code after iterating over all matching devices should any device
> have failed its of_device_ensure_probed. Doing this unearths one common
> failure: a matching node has status = "disabled". These will have
> of_device_ensure_probed return -ENODEV, which makes sense for users
> wanting to ensure a specific device is probed, but doesn't when
> iterating over multiple nodes.
> 
> We already have of_devices_ensure_probed_by_dev_id, which does an early
> of_device_is_available check, so do likewise for the other to
> ensure_probed_by_* functions.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/of/platform.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index dc784ea8e550..a9a5d4c2daf2 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -525,12 +525,15 @@ int of_devices_ensure_probed_by_property(const char *property_name)
>  		return 0;
>  
>  	for_each_node_with_property(node, property_name) {
> -		ret = of_device_ensure_probed(node);
> +		if (!of_device_is_available(node))
> +			continue;
> +
> +		err = of_device_ensure_probed(node);
>  		if (err)
>  			ret = err;
>  	}
>  
> -	return 0;
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_property);
>  
> @@ -543,12 +546,15 @@ int of_devices_ensure_probed_by_name(const char *name)
>  		return 0;
>  
>  	for_each_node_by_name(node, name) {
> -		ret = of_device_ensure_probed(node);
> +		if (!of_device_is_available(node))
> +			continue;
> +
> +		err = of_device_ensure_probed(node);
>  		if (err)
>  			ret = err;
>  	}
>  
> -	return 0;
> +	return ret;
>  }
>  EXPORT_SYMBOL_GPL(of_devices_ensure_probed_by_name);
>  
> -- 
> 2.30.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] 2+ messages in thread

end of thread, other threads:[~2022-09-12  8:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05 11:59 [PATCH] of: platform: propagate of_devices_ensure_probed_by(name|property) errors Ahmad Fatoum
2022-09-12  8:50 ` Sascha Hauer

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