All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] led: gpio: Use NOP uclass driver for top-level node
@ 2022-04-22 13:34 Marek Vasut
  2022-04-22 14:29 ` Patrice CHOTARD
  2022-04-28 19:42 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Marek Vasut @ 2022-04-22 13:34 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Patrice Chotard, Patrick Delaunay, Sean Anderson,
	Simon Glass, Steven Lawrance

The top level DT node of gpio-leds is not a LED itself, bind NOP uclass
driver to it, and bind different LED uclass driver to its subnodes which
represent the actual LEDs. This simplifies the probe() implementation
and fixes the bogus top-level not-an-LED in 'led list' command output:

```
=> led list
led             Error -121 <--- This is removed/fixed by this patch
green:user0     off
```

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 | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
index 23156907593..fbed151b5d9 100644
--- a/drivers/led/led_gpio.c
+++ b/drivers/led/led_gpio.c
@@ -58,17 +58,8 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev)
 static int led_gpio_probe(struct udevice *dev)
 {
 	struct led_gpio_priv *priv = dev_get_priv(dev);
-	int ret;
-
-	/* Ignore the top-level LED node */
-	if (device_is_compatible(dev, "gpio-leds"))
-		return 0;
-
-	ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
-	if (ret)
-		return ret;
 
-	return 0;
+	return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
 }
 
 static int led_gpio_remove(struct udevice *dev)
@@ -109,18 +100,23 @@ static const struct led_ops gpio_led_ops = {
 	.get_state	= gpio_led_get_state,
 };
 
-static const struct udevice_id led_gpio_ids[] = {
-	{ .compatible = "gpio-leds" },
-	{ }
-};
-
 U_BOOT_DRIVER(led_gpio) = {
 	.name	= "gpio_led",
 	.id	= UCLASS_LED,
-	.of_match = led_gpio_ids,
 	.ops	= &gpio_led_ops,
 	.priv_auto	= sizeof(struct led_gpio_priv),
-	.bind	= led_gpio_bind,
 	.probe	= led_gpio_probe,
 	.remove	= led_gpio_remove,
 };
+
+static const struct udevice_id led_gpio_ids[] = {
+	{ .compatible = "gpio-leds" },
+	{ }
+};
+
+U_BOOT_DRIVER(led_gpio_wrap) = {
+	.name	= "gpio_led_wrap",
+	.id	= UCLASS_NOP,
+	.of_match = led_gpio_ids,
+	.bind	= led_gpio_bind,
+};
-- 
2.35.1


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

* Re: [PATCH] led: gpio: Use NOP uclass driver for top-level node
  2022-04-22 13:34 [PATCH] led: gpio: Use NOP uclass driver for top-level node Marek Vasut
@ 2022-04-22 14:29 ` Patrice CHOTARD
  2022-04-28 19:42 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Patrice CHOTARD @ 2022-04-22 14:29 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: Patrick Delaunay, Sean Anderson, Simon Glass, Steven Lawrance

Hi Marek

On 4/22/22 15:34, Marek Vasut wrote:
> The top level DT node of gpio-leds is not a LED itself, bind NOP uclass
> driver to it, and bind different LED uclass driver to its subnodes which
> represent the actual LEDs. This simplifies the probe() implementation
> and fixes the bogus top-level not-an-LED in 'led list' command output:
> 
> ```
> => led list
> led             Error -121 <--- This is removed/fixed by this patch
> green:user0     off
> ```
> 
> 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 | 30 +++++++++++++-----------------
>  1 file changed, 13 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/led/led_gpio.c b/drivers/led/led_gpio.c
> index 23156907593..fbed151b5d9 100644
> --- a/drivers/led/led_gpio.c
> +++ b/drivers/led/led_gpio.c
> @@ -58,17 +58,8 @@ static enum led_state_t gpio_led_get_state(struct udevice *dev)
>  static int led_gpio_probe(struct udevice *dev)
>  {
>  	struct led_gpio_priv *priv = dev_get_priv(dev);
> -	int ret;
> -
> -	/* Ignore the top-level LED node */
> -	if (device_is_compatible(dev, "gpio-leds"))
> -		return 0;
> -
> -	ret = gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
> -	if (ret)
> -		return ret;
>  
> -	return 0;
> +	return gpio_request_by_name(dev, "gpios", 0, &priv->gpio, GPIOD_IS_OUT);
>  }
>  
>  static int led_gpio_remove(struct udevice *dev)
> @@ -109,18 +100,23 @@ static const struct led_ops gpio_led_ops = {
>  	.get_state	= gpio_led_get_state,
>  };
>  
> -static const struct udevice_id led_gpio_ids[] = {
> -	{ .compatible = "gpio-leds" },
> -	{ }
> -};
> -
>  U_BOOT_DRIVER(led_gpio) = {
>  	.name	= "gpio_led",
>  	.id	= UCLASS_LED,
> -	.of_match = led_gpio_ids,
>  	.ops	= &gpio_led_ops,
>  	.priv_auto	= sizeof(struct led_gpio_priv),
> -	.bind	= led_gpio_bind,
>  	.probe	= led_gpio_probe,
>  	.remove	= led_gpio_remove,
>  };
> +
> +static const struct udevice_id led_gpio_ids[] = {
> +	{ .compatible = "gpio-leds" },
> +	{ }
> +};
> +
> +U_BOOT_DRIVER(led_gpio_wrap) = {
> +	.name	= "gpio_led_wrap",
> +	.id	= UCLASS_NOP,
> +	.of_match = led_gpio_ids,
> +	.bind	= led_gpio_bind,
> +};

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

Tested on stm32mp157c-dk2
Thanks
Patrice


Thanks

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

* Re: [PATCH] led: gpio: Use NOP uclass driver for top-level node
  2022-04-22 13:34 [PATCH] led: gpio: Use NOP uclass driver for top-level node Marek Vasut
  2022-04-22 14:29 ` Patrice CHOTARD
@ 2022-04-28 19:42 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2022-04-28 19:42 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, Patrice Chotard, Patrick Delaunay, Sean Anderson,
	Simon Glass, Steven Lawrance

[-- Attachment #1: Type: text/plain, Size: 953 bytes --]

On Fri, Apr 22, 2022 at 03:34:00PM +0200, Marek Vasut wrote:

> The top level DT node of gpio-leds is not a LED itself, bind NOP uclass
> driver to it, and bind different LED uclass driver to its subnodes which
> represent the actual LEDs. This simplifies the probe() implementation
> and fixes the bogus top-level not-an-LED in 'led list' command output:
> 
> ```
> => led list
> led             Error -121 <--- This is removed/fixed by this patch
> green:user0     off
> ```
> 
> 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!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2022-04-28 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 13:34 [PATCH] led: gpio: Use NOP uclass driver for top-level node Marek Vasut
2022-04-22 14:29 ` Patrice CHOTARD
2022-04-28 19:42 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.