diff mbox series

[3/3] led: gpio: Check device compatible string to determine the top level node

Message ID 20220422131555.123598-3-marex@denx.de
State Accepted
Commit e3aa76644c2af14631a1fb5ba17022e0a396a6c4
Delegated to: Tom Rini
Headers show
Series [1/3] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag | expand

Commit Message

Marek Vasut April 22, 2022, 1:15 p.m. UTC
Since 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing"),
all LED nodes have some sort of label. Use device_is_compatible(..."leds-gpio")
to determine whether this is a top-level node, since it is only the top
level node which is compatible with "leds-gpio", the GPIO LEDs subnodes
are not.

Fixes: 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing")
Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
---
 drivers/led/led_gpio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Patrice CHOTARD April 22, 2022, 1:45 p.m. UTC | #1
Hi Marek

On 4/22/22 15:15, Marek Vasut wrote:
> Since 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing"),
> all LED nodes have some sort of label. Use device_is_compatible(..."leds-gpio")
> to determine whether this is a top-level node, since it is only the top
> level node which is compatible with "leds-gpio", the GPIO LEDs subnodes
> are not.
> 
> Fixes: 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Sean Anderson <seanga2@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Steven Lawrance <steven.lawrance@softathome.com>
> ---
>  drivers/led/led_gpio.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
> index 958dbd31e77..23156907593 100644
> --- a/drivers/led/led_gpio.c
> +++ b/drivers/led/led_gpio.c
> @@ -57,12 +57,11 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev)
>  
>  static int led_gpio_probe(struct udevice *dev)
>  {
> -	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
>  	struct led_gpio_priv *priv = dev_get_priv(dev);
>  	int ret;
>  
>  	/* Ignore the top-level LED node */
> -	if (!uc_plat->label)
> +	if (device_is_compatible(dev, "gpio-leds"))
>  		return 0;
>  
>  	ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>

Tested on stm32mp157c-dk2 board
Thanks
Patrice
Tom Rini April 28, 2022, 7:42 p.m. UTC | #2
On Fri, Apr 22, 2022 at 03:15:55PM +0200, Marek Vasut wrote:

> Since 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing"),
> all LED nodes have some sort of label. Use device_is_compatible(..."leds-gpio")
> to determine whether this is a top-level node, since it is only the top
> level node which is compatible with "leds-gpio", the GPIO LEDs subnodes
> are not.
> 
> Fixes: 2d1deaf88ed ("led: gpio: Drop duplicate OF "label" property parsing")
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Patrice Chotard <patrice.chotard@foss.st.com>
> Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
> Cc: Sean Anderson <seanga2@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Steven Lawrance <steven.lawrance@softathome.com>
> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index 958dbd31e77..23156907593 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -57,12 +57,11 @@  static enum led_state_t gpio_led_get_state(struct udevice *dev)
 
 static int led_gpio_probe(struct udevice *dev)
 {
-	struct led_uc_plat *uc_plat = dev_get_uclass_plat(dev);
 	struct led_gpio_priv *priv = dev_get_priv(dev);
 	int ret;
 
 	/* Ignore the top-level LED node */
-	if (!uc_plat->label)
+	if (device_is_compatible(dev, "gpio-leds"))
 		return 0;
 
 	ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);