diff mbox series

[06/40] gpio: Avoid using an invalid ofnode

Message ID 20230601162404.220488-5-sjg@chromium.org
State Accepted
Commit 11c341b118a236423a294a7d62f71bf33e20aea3
Delegated to: Tom Rini
Headers show
Series expo: Add an initial configuration editor | expand

Commit Message

Simon Glass June 1, 2023, 4:22 p.m. UTC
Devices do not necessarily have nodes attached to them, since they can be
created from platdata. In SPL a devicetree may in fact not exist at all.

Check the node before using it. This avoids failure when OF_CHECKS is
enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 5fc7cf8c8e2 ("gpio: add gpio-hog support")
---

 drivers/gpio/gpio-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heiko Schocher June 2, 2023, 5:09 a.m. UTC | #1
Hello Simon,

On 01.06.23 18:22, Simon Glass wrote:
> Devices do not necessarily have nodes attached to them, since they can be
> created from platdata. In SPL a devicetree may in fact not exist at all.
> 
> Check the node before using it. This avoids failure when OF_CHECKS is
> enabled.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Fixes: 5fc7cf8c8e2 ("gpio: add gpio-hog support")
> ---
> 
>  drivers/gpio/gpio-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 712119c3415b..31027f3d9902 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -1474,7 +1474,7 @@  static int gpio_post_bind(struct udevice *dev)
 	}
 #endif
 
-	if (CONFIG_IS_ENABLED(GPIO_HOG)) {
+	if (CONFIG_IS_ENABLED(GPIO_HOG) && dev_has_ofnode(dev)) {
 		struct udevice *child;
 		ofnode node;