devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org,
	dev@lists.96boards.org
Cc: Mark Rutland <mark.rutland@arm.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Michal Simek <michal.simek@xilinx.com>,
	Rob Herring <robh+dt@kernel.org>, Mark Brown <broonie@kernel.org>,
	John Stultz <john.stultz@linaro.org>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Andy Shevchenko <andy@infradead.org>
Subject: [PATCH 1/5] RFC: gpio: Add API to explicitly name a consumer
Date: Mon, 18 Jun 2018 09:45:52 +0200	[thread overview]
Message-ID: <20180618074556.6944-2-linus.walleij@linaro.org> (raw)
In-Reply-To: <20180618074556.6944-1-linus.walleij@linaro.org>

The GPIO (descriptor) API registers a "label" naming what is
currently using the GPIO line. Typically this is taken from
things like the device tree node, so "reset-gpios" will result
in he line being labeled "reset".

The technical effect is pretty much zero: the use is for
debug and introspection, such as "lsgpio" and debugfs files.

However sometimes the user want this cuddly feeling of
listing all GPIO lines and seeing exactly what they are for
and it gives a very fulfilling sense of control. Especially
in the cases when the device tree node doesn't provide a
good name, or anonymous GPIO lines assigned just to
"gpios" in the device tree because the usage is implicit.

For these cases it may be nice to be able to label the
line directly and explicitly.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpiolib.c        | 13 +++++++++++++
 include/linux/gpio/consumer.h |  7 +++++++
 2 files changed, 20 insertions(+)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e11a3bb03820..c6f77e806cb8 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3193,6 +3193,19 @@ int gpiod_cansleep(const struct gpio_desc *desc)
 }
 EXPORT_SYMBOL_GPL(gpiod_cansleep);
 
+/**
+ * gpiod_set_consumer_name() - set the consumer name for the descriptor
+ * @desc: gpio to set the consumer name on
+ * @name: the new consumer name
+ */
+void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
+{
+	VALIDATE_DESC_VOID(desc);
+	/* Just overwrite whatever the previous name was */
+	desc->label = name;
+}
+EXPORT_SYMBOL_GPL(gpiod_set_consumer_name);
+
 /**
  * gpiod_to_irq() - return the IRQ corresponding to a GPIO
  * @desc: gpio whose IRQ will be returned (already requested)
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 243112c7fa7d..e8aaf34dd65d 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -145,6 +145,7 @@ int gpiod_is_active_low(const struct gpio_desc *desc);
 int gpiod_cansleep(const struct gpio_desc *desc);
 
 int gpiod_to_irq(const struct gpio_desc *desc);
+void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name);
 
 /* Convert between the old gpio_ and new gpiod_ interfaces */
 struct gpio_desc *gpio_to_desc(unsigned gpio);
@@ -467,6 +468,12 @@ static inline int gpiod_to_irq(const struct gpio_desc *desc)
 	return -EINVAL;
 }
 
+static inline void gpiod_set_consumer_name(struct gpio_desc *desc, const char *name)
+{
+	/* GPIO can never have been requested */
+	WARN_ON(1);
+}
+
 static inline struct gpio_desc *gpio_to_desc(unsigned gpio)
 {
 	return ERR_PTR(-EINVAL);
-- 
2.17.0

  reply	other threads:[~2018-06-18  7:45 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-18  7:45 [PATCH 0/5] RFC: Mezzanine handling for 96boards Linus Walleij
2018-06-18  7:45 ` Linus Walleij [this message]
2018-06-18  7:45 ` [PATCH 2/5] RFC: eeprom: at24: Allow passing gpiodesc from pdata Linus Walleij
2018-06-20  0:45   ` Andy Shevchenko
2018-06-18  7:45 ` [PATCH 3/5] RFC: spi: Make of_find_spi_device_by_node() available Linus Walleij
2018-06-18  7:45 ` [PATCH 4/5] RFC: bus: 96boards Low-Speed Connector Linus Walleij
2018-06-19 11:19   ` [Dev] " Daniel Thompson
2018-06-18  7:45 ` [PATCH 5/5] RFC: ARM64: dts: Add Low-Speed Connector to ZCU100 Linus Walleij
2018-06-19 14:55   ` Rob Herring
2018-06-22 13:22   ` Michal Simek
2018-06-18 12:21 ` [PATCH 0/5] RFC: Mezzanine handling for 96boards Arnd Bergmann
2018-06-18 13:22   ` Ard Biesheuvel
2018-06-18 14:15     ` Arnd Bergmann
2018-06-22 13:36       ` Michal Simek
2018-06-19 15:14     ` [Dev] " Yang Zhang
2018-06-19 15:25       ` Ard Biesheuvel
2018-06-19 15:26         ` Yang Zhang
2018-06-19 15:30           ` Ard Biesheuvel
2018-06-19 15:32             ` Yang Zhang
2018-06-22 13:08               ` Michal Simek
2018-06-26  9:10                 ` Linus Walleij
2018-06-26  8:09     ` Linus Walleij
2018-06-26  8:19       ` Ard Biesheuvel
2018-06-26  8:36         ` Linus Walleij
2018-06-26  8:02   ` Linus Walleij
2018-06-26  8:08     ` Arnd Bergmann
2018-06-26 12:12     ` Mark Brown
2018-07-16 15:07   ` Rob Herring
2018-06-19 11:10 ` [Dev] " Daniel Thompson
2018-06-19 11:56   ` Mark Brown
2018-06-19 15:52 ` Rob Herring
2018-06-21 13:02   ` Frank Rowand
2018-06-26  9:03     ` Linus Walleij
2018-06-26  9:00   ` Linus Walleij
2018-06-27 15:23     ` [Dev] " Rob Herring
2018-06-28  6:10       ` Michal Simek
2018-06-21 12:58 ` Frank Rowand

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=20180618074556.6944-2-linus.walleij@linaro.org \
    --to=linus.walleij@linaro.org \
    --cc=andy@infradead.org \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=dev@lists.96boards.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=mark.rutland@arm.com \
    --cc=michal.simek@xilinx.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=robh+dt@kernel.org \
    /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).