devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Jan Kundrát" <jan.kundrat@cesnet.cz>,
	"Pavel Machek" <pavel@ucw.cz>, "Lee Jones" <lee@kernel.org>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Jacek Anaszewski" <jacek.anaszewski@gmail.com>,
	linux-leds@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] leds: triggers: gpio: Rewrite to use trigger-sources
Date: Fri, 15 Sep 2023 09:15:49 -0500	[thread overview]
Message-ID: <20230915141549.GA3658872-robh@kernel.org> (raw)
In-Reply-To: <20230912-gpio-led-trigger-dt-v1-2-1b50e3756dda@linaro.org>

On Tue, Sep 12, 2023 at 03:44:31PM +0200, Linus Walleij wrote:
> By providing a GPIO line as "trigger-sources" in the FWNODE
> (such as from the device tree) and combining with the
> GPIO trigger, we can support a GPIO LED trigger in a natural
> way from the hardware description instead of using the
> custom sysfs and deprecated global GPIO numberspace.
> 
> Example:
> 
> gpio: gpio@0 {
>     compatible "my-gpio";
>     gpio-controller;
>     #gpio-cells = <2>;
>     interrupt-controller;
>     #interrupt-cells = <2>;
>     #trigger-source-cells = <2>;
> };
> 
> leds {
>     compatible = "gpio-leds";
>     led-my-gpio {
>         label = "device:blue:myled";
>         gpios = <&gpio 0 GPIO_ACTIVE_HIGH>;
>         default-state = "off";
>         linux,default-trigger = "gpio";
>         trigger-sources = <&gpio 1 GPIO_ACTIVE_HIGH>;
>     };
> };
> 
> Make this the norm, unmark the driver as broken.
> 
> Delete the sysfs handling of GPIOs.
> 
> Since GPIO descriptors inherently can describe inversion,
> the inversion handling can just be deleted.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---

[...]

> @@ -167,16 +78,47 @@ ATTRIBUTE_GROUPS(gpio_trig);
>  static int gpio_trig_activate(struct led_classdev *led)
>  {
>  	struct gpio_trig_data *gpio_data;
> +	struct device *dev = led->dev;
> +	int ret;
>  
>  	gpio_data = kzalloc(sizeof(*gpio_data), GFP_KERNEL);
>  	if (!gpio_data)
>  		return -ENOMEM;
>  
> -	gpio_data->led = led;
> -	gpio_data->gpio = -ENOENT;
> +	/*
> +	 * The generic property "trigger-sources" is followed,
> +	 * and we hope that this is a GPIO.
> +	 */
> +	gpio_data->gpiod = fwnode_gpiod_get_index(dev->fwnode,
> +						  "trigger-sources",
> +						  0, GPIOD_IN,
> +						  "led-trigger");

Isn't this going to look for "trigger-sources-gpio" and 
""trigger-sources-gpios"?

Rob

  parent reply	other threads:[~2023-09-15 14:15 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-12 13:44 [PATCH 0/2] Rewrite GPIO LED trigger to use trigger-sources Linus Walleij
2023-09-12 13:44 ` [PATCH 1/2] dt-bindings: leds: Mention GPIO triggers Linus Walleij
2023-09-12 17:11   ` Conor Dooley
2023-09-13 13:34   ` Rob Herring
2023-09-14  8:40     ` Linus Walleij
2023-09-14 14:27       ` Rob Herring
2023-09-15 12:01         ` Linus Walleij
2023-09-15 14:10           ` Rob Herring
2023-09-12 13:44 ` [PATCH 2/2] leds: triggers: gpio: Rewrite to use trigger-sources Linus Walleij
2023-09-14  9:10   ` Dan Carpenter
2023-09-15 14:15   ` Rob Herring [this message]
2023-09-15 18:14     ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230915141549.GA3658872-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jacek.anaszewski@gmail.com \
    --cc=jan.kundrat@cesnet.cz \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).