linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Tobias Diedrich <ranma+kernel@tdiedrich.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] gpio / ACPI: Add label to the gpio request
Date: Fri, 12 Jun 2015 17:49:27 +0300	[thread overview]
Message-ID: <20150612144927.GE1478@lahna.fi.intel.com> (raw)
In-Reply-To: <20150611000822.GA21213@yumi.tdiedrich.de>

On Thu, Jun 11, 2015 at 02:08:22AM +0200, Tobias Diedrich wrote:
> In create_gpio_led only the legacy pass propagates the label by passing it into
> devm_gpio_request_one.
> 
> On the newer devicetree/acpi path the label is lost as far as the GPIO
> subsystem goes (it is only retained as name in struct gpio_led.
> 
> Amend devm_get_gpiod_from_child to also pass the label into the GPIO layer, so
> it will show up in /sys/kernel/debug/gpio, so instead of:
> 
> GPIOs 288-511, platform/PRP0001:00, AMD SBX00:
>  gpio-477 (?                   ) out hi
>  gpio-478 (?                   ) out lo
>  gpio-479 (?                   ) out hi
> 
> we get the much nicer output:
> 
> GPIOs 288-511, platform/PRP0001:00, AMD SBX00:
>  gpio-477 (led1                ) out hi
>  gpio-478 (led2                ) out lo
>  gpio-479 (led3                ) out hi

I wonder if we can just put the con_id there?

> Signed-off-by: Tobias Diedrich <ranma+kernel@tdiedrich.de>
> ---
>  drivers/gpio/devres.c         | 6 +++++-
>  drivers/gpio/gpiolib.c        | 6 ++++--
>  include/linux/gpio/consumer.h | 3 ++-
>  3 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
> index 07ba823..089db97 100644
> --- a/drivers/gpio/devres.c
> +++ b/drivers/gpio/devres.c
> @@ -103,13 +103,17 @@ struct gpio_desc *__must_check __devm_gpiod_get_index(struct device *dev,
>  {
>  	struct gpio_desc **dr;
>  	struct gpio_desc *desc;
> +	const char *label = NULL;
>  
>  	dr = devres_alloc(devm_gpiod_release, sizeof(struct gpio_desc *),
>  			  GFP_KERNEL);
>  	if (!dr)
>  		return ERR_PTR(-ENOMEM);
>  
> -	desc = gpiod_get_index(dev, con_id, idx, flags);
> +	if (fwnode_property_present(child, "label"))
> +		fwnode_property_read_string(child, "label", &label);

This binding needs to be documented, I suppose.

But then again, does it really describe the hardware? We already have
names like "linux,label" in the bindings but as far as I understand
adding such things is not recommended.

> +
> +	desc = gpiod_get_index(dev, con_id, idx, flags, label);
>  	if (IS_ERR(desc)) {
>  		devres_free(dr);
>  		return desc;
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 6bc612b..fb2be68 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2017,6 +2017,7 @@ EXPORT_SYMBOL_GPL(__gpiod_get_index);
>   * fwnode_get_named_gpiod - obtain a GPIO from firmware node
>   * @fwnode:	handle of the firmware node
>   * @propname:	name of the firmware property representing the GPIO
> + * @label:	optional label for the GPIO
>   *
>   * This function can be used for drivers that get their configuration
>   * from firmware.
> @@ -2028,7 +2029,8 @@ EXPORT_SYMBOL_GPL(__gpiod_get_index);
>   * In case of error an ERR_PTR() is returned.
>   */
>  struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
> -					 const char *propname)
> +					 const char *propname,
> +					 const char *label)
>  {
>  	struct gpio_desc *desc = ERR_PTR(-ENODEV);
>  	bool active_low = false;
> @@ -2056,7 +2058,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
>  	if (IS_ERR(desc))
>  		return desc;
>  
> -	ret = gpiod_request(desc, NULL);
> +	ret = gpiod_request(desc, label);
>  	if (ret)
>  		return ERR_PTR(ret);
>  
> diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
> index 3a7c9ff..ef7d322 100644
> --- a/include/linux/gpio/consumer.h
> +++ b/include/linux/gpio/consumer.h
> @@ -134,7 +134,8 @@ int desc_to_gpio(const struct gpio_desc *desc);
>  struct fwnode_handle;
>  
>  struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
> -					 const char *propname);
> +					 const char *propname,
> +					 const char *label);
>  struct gpio_desc *devm_get_gpiod_from_child(struct device *dev,
>  					    const char *con_id,
>  					    struct fwnode_handle *child);
> -- 
> 2.1.4

  reply	other threads:[~2015-06-12 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-11  0:08 [PATCH] gpio / ACPI: Add label to the gpio request Tobias Diedrich
2015-06-12 14:49 ` Mika Westerberg [this message]
2015-06-13 19:25   ` Tobias Diedrich

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=20150612144927.GE1478@lahna.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ranma+kernel@tdiedrich.de \
    --cc=rjw@rjwysocki.net \
    /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).