linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] leds: gpio: Configure per-LED pin control
@ 2022-11-07  0:31 Marek Vasut
  2022-11-07  9:15 ` Christoph Niedermaier
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Marek Vasut @ 2022-11-07  0:31 UTC (permalink / raw)
  To: linux-leds; +Cc: Marek Vasut, Christoph Niedermaier, Pavel Machek

Each gpio-leds DT node DT subnode can have a pinctrl property assigned
to it, parse the DT subnode pinctrl properties and configure each pin
accordingly.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
Cc: Pavel Machek <pavel@ucw.cz>
To: linux-leds@vger.kernel.org
---
 drivers/leds/leds-gpio.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
index 092eb59a7d325..01ca88876f008 100644
--- a/drivers/leds/leds-gpio.c
+++ b/drivers/leds/leds-gpio.c
@@ -13,6 +13,7 @@
 #include <linux/leds.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
 #include <linux/slab.h>
@@ -77,6 +78,7 @@ static int create_gpio_led(const struct gpio_led *template,
 	struct fwnode_handle *fwnode, gpio_blink_set_t blink_set)
 {
 	struct led_init_data init_data = {};
+	struct pinctrl *pinctrl;
 	int ret, state;
 
 	led_dat->cdev.default_trigger = template->default_trigger;
@@ -119,6 +121,22 @@ static int create_gpio_led(const struct gpio_led *template,
 						     &init_data);
 	}
 
+	if (ret)
+		return ret;
+
+	pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev);
+	if (IS_ERR(pinctrl)) {
+		ret = PTR_ERR(pinctrl);
+		if (ret != -ENODEV) {
+			dev_warn(led_dat->cdev.dev,
+				 "Failed to select %pOF pinctrl: %d\n",
+				 to_of_node(fwnode), ret);
+		} else {
+			/* pinctrl-%d not present, not an error */
+			ret = 0;
+		}
+	}
+
 	return ret;
 }
 
-- 
2.35.1


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

* RE: [PATCH] leds: gpio: Configure per-LED pin control
  2022-11-07  0:31 [PATCH] leds: gpio: Configure per-LED pin control Marek Vasut
@ 2022-11-07  9:15 ` Christoph Niedermaier
  2023-02-28 22:01 ` Marek Vasut
  2023-03-27 11:58 ` Pavel Machek
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Niedermaier @ 2022-11-07  9:15 UTC (permalink / raw)
  To: Marek Vasut; +Cc: Pavel Machek, linux-leds@vger.kernel.org

From: Marek Vasut [mailto:marex@denx.de]
Sent: Monday, November 7, 2022 1:32 AM
> Each gpio-leds DT node DT subnode can have a pinctrl property assigned
> to it, parse the DT subnode pinctrl properties and configure each pin
> accordingly.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> To: linux-leds@vger.kernel.org
> ---
>  drivers/leds/leds-gpio.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 092eb59a7d325..01ca88876f008 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -13,6 +13,7 @@
>  #include <linux/leds.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
>  #include <linux/slab.h>
> @@ -77,6 +78,7 @@ static int create_gpio_led(const struct gpio_led *template,
>         struct fwnode_handle *fwnode, gpio_blink_set_t blink_set)
>  {
>         struct led_init_data init_data = {};
> +       struct pinctrl *pinctrl;
>         int ret, state;
> 
>         led_dat->cdev.default_trigger = template->default_trigger;
> @@ -119,6 +121,22 @@ static int create_gpio_led(const struct gpio_led *template,
>                                                      &init_data);
>         }
> 
> +       if (ret)
> +               return ret;
> +
> +       pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev);
> +       if (IS_ERR(pinctrl)) {
> +               ret = PTR_ERR(pinctrl);
> +               if (ret != -ENODEV) {
> +                       dev_warn(led_dat->cdev.dev,
> +                                "Failed to select %pOF pinctrl: %d\n",
> +                                to_of_node(fwnode), ret);
> +               } else {
> +                       /* pinctrl-%d not present, not an error */
> +                       ret = 0;
> +               }
> +       }
> +
>         return ret;
>  }
> 

Tested-by: Christoph Niedermaier <cniedermaier@dh-electronics.com>


Regards
Christoph

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

* Re: [PATCH] leds: gpio: Configure per-LED pin control
  2022-11-07  0:31 [PATCH] leds: gpio: Configure per-LED pin control Marek Vasut
  2022-11-07  9:15 ` Christoph Niedermaier
@ 2023-02-28 22:01 ` Marek Vasut
  2023-03-27 11:58 ` Pavel Machek
  2 siblings, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2023-02-28 22:01 UTC (permalink / raw)
  To: linux-leds, pavel Machek; +Cc: Christoph Niedermaier, Pavel Machek

On 11/7/22 01:31, Marek Vasut wrote:
> Each gpio-leds DT node DT subnode can have a pinctrl property assigned
> to it, parse the DT subnode pinctrl properties and configure each pin
> accordingly.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
> Cc: Pavel Machek <pavel@ucw.cz>
> To: linux-leds@vger.kernel.org
> ---
>   drivers/leds/leds-gpio.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
> 
> diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
> index 092eb59a7d325..01ca88876f008 100644
> --- a/drivers/leds/leds-gpio.c
> +++ b/drivers/leds/leds-gpio.c
> @@ -13,6 +13,7 @@
>   #include <linux/leds.h>
>   #include <linux/module.h>
>   #include <linux/of.h>
> +#include <linux/pinctrl/consumer.h>
>   #include <linux/platform_device.h>
>   #include <linux/property.h>
>   #include <linux/slab.h>
> @@ -77,6 +78,7 @@ static int create_gpio_led(const struct gpio_led *template,
>   	struct fwnode_handle *fwnode, gpio_blink_set_t blink_set)
>   {
>   	struct led_init_data init_data = {};
> +	struct pinctrl *pinctrl;
>   	int ret, state;
>   
>   	led_dat->cdev.default_trigger = template->default_trigger;
> @@ -119,6 +121,22 @@ static int create_gpio_led(const struct gpio_led *template,
>   						     &init_data);
>   	}
>   
> +	if (ret)
> +		return ret;
> +
> +	pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev);
> +	if (IS_ERR(pinctrl)) {
> +		ret = PTR_ERR(pinctrl);
> +		if (ret != -ENODEV) {
> +			dev_warn(led_dat->cdev.dev,
> +				 "Failed to select %pOF pinctrl: %d\n",
> +				 to_of_node(fwnode), ret);
> +		} else {
> +			/* pinctrl-%d not present, not an error */
> +			ret = 0;
> +		}
> +	}
> +
>   	return ret;
>   }
>   

Any news on this patch ?

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

* Re: [PATCH] leds: gpio: Configure per-LED pin control
  2022-11-07  0:31 [PATCH] leds: gpio: Configure per-LED pin control Marek Vasut
  2022-11-07  9:15 ` Christoph Niedermaier
  2023-02-28 22:01 ` Marek Vasut
@ 2023-03-27 11:58 ` Pavel Machek
  2023-04-02 21:58   ` Marek Vasut
  2 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2023-03-27 11:58 UTC (permalink / raw)
  To: Marek Vasut, lee.jones; +Cc: linux-leds, Christoph Niedermaier

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

Hi!

> Each gpio-leds DT node DT subnode can have a pinctrl property assigned
> to it, parse the DT subnode pinctrl properties and configure each pin
> accordingly.

Do we need update to
Documentation/devicetree/bindings/leds/leds-gpio.yaml ?

Otherwise looks good to me.

Thank you,
								Pavel

> +++ b/drivers/leds/leds-gpio.c
> @@ -13,6 +13,7 @@
>  #include <linux/leds.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/pinctrl/consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/property.h>
>  #include <linux/slab.h>
> @@ -77,6 +78,7 @@ static int create_gpio_led(const struct gpio_led *template,
>  	struct fwnode_handle *fwnode, gpio_blink_set_t blink_set)
>  {
>  	struct led_init_data init_data = {};
> +	struct pinctrl *pinctrl;
>  	int ret, state;
>  
>  	led_dat->cdev.default_trigger = template->default_trigger;
> @@ -119,6 +121,22 @@ static int create_gpio_led(const struct gpio_led *template,
>  						     &init_data);
>  	}
>  
> +	if (ret)
> +		return ret;
> +
> +	pinctrl = devm_pinctrl_get_select_default(led_dat->cdev.dev);
> +	if (IS_ERR(pinctrl)) {
> +		ret = PTR_ERR(pinctrl);
> +		if (ret != -ENODEV) {
> +			dev_warn(led_dat->cdev.dev,
> +				 "Failed to select %pOF pinctrl: %d\n",
> +				 to_of_node(fwnode), ret);
> +		} else {
> +			/* pinctrl-%d not present, not an error */
> +			ret = 0;
> +		}
> +	}
> +
>  	return ret;
>  }
>  

-- 
People of Russia, stop Putin before his war on Ukraine escalates.

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

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

* Re: [PATCH] leds: gpio: Configure per-LED pin control
  2023-03-27 11:58 ` Pavel Machek
@ 2023-04-02 21:58   ` Marek Vasut
  2023-05-07 23:11     ` Marek Vasut
  0 siblings, 1 reply; 6+ messages in thread
From: Marek Vasut @ 2023-04-02 21:58 UTC (permalink / raw)
  To: Pavel Machek, lee.jones; +Cc: linux-leds, Christoph Niedermaier

On 3/27/23 13:58, Pavel Machek wrote:
> Hi!
> 
>> Each gpio-leds DT node DT subnode can have a pinctrl property assigned
>> to it, parse the DT subnode pinctrl properties and configure each pin
>> accordingly.
> 
> Do we need update to
> Documentation/devicetree/bindings/leds/leds-gpio.yaml ?

As far as I can tell, no. The pinctrl properties are generic and outside 
of the leds-gpio yaml schema.

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

* Re: [PATCH] leds: gpio: Configure per-LED pin control
  2023-04-02 21:58   ` Marek Vasut
@ 2023-05-07 23:11     ` Marek Vasut
  0 siblings, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2023-05-07 23:11 UTC (permalink / raw)
  To: Pavel Machek, lee.jones; +Cc: linux-leds, Christoph Niedermaier

On 4/2/23 23:58, Marek Vasut wrote:
> On 3/27/23 13:58, Pavel Machek wrote:
>> Hi!
>>
>>> Each gpio-leds DT node DT subnode can have a pinctrl property assigned
>>> to it, parse the DT subnode pinctrl properties and configure each pin
>>> accordingly.
>>
>> Do we need update to
>> Documentation/devicetree/bindings/leds/leds-gpio.yaml ?
> 
> As far as I can tell, no. The pinctrl properties are generic and outside 
> of the leds-gpio yaml schema.

Are there any further concerns or can this patch be applied now ?

Thanks!

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

end of thread, other threads:[~2023-05-07 23:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-07  0:31 [PATCH] leds: gpio: Configure per-LED pin control Marek Vasut
2022-11-07  9:15 ` Christoph Niedermaier
2023-02-28 22:01 ` Marek Vasut
2023-03-27 11:58 ` Pavel Machek
2023-04-02 21:58   ` Marek Vasut
2023-05-07 23:11     ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).