All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dario Binacchi <dariobin@libero.it>
To: u-boot@lists.denx.de
Subject: [PATCH 09/11] pinctrl: single: add get_pin_name operation
Date: Sat, 23 Jan 2021 19:27:09 +0100	[thread overview]
Message-ID: <20210123182711.7177-10-dariobin@libero.it> (raw)
In-Reply-To: <20210123182711.7177-1-dariobin@libero.it>

It returns the name of the requested pin.

Signed-off-by: Dario Binacchi <dariobin@libero.it>
---

 drivers/pinctrl/pinctrl-single.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 21a3bbaaa7..04e2b00f7e 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -30,12 +30,14 @@ struct single_pdata {
  * struct single_priv - private data
  * @bits_per_pin: number of bits per pin
  * @npins: number of selectable pins
+ * @pin_name: temporary buffer to store the pin name
  * @read: function to read from a configuration register
  * @write: function to write to a configuration register
  */
 struct single_priv {
 	unsigned int bits_per_pin;
 	unsigned int npins;
+	char pin_name[PINNAME_SIZE];
 	unsigned int (*read)(fdt_addr_t reg);
 	void (*write)(unsigned int val, fdt_addr_t reg);
 };
@@ -207,6 +209,19 @@ static int single_set_state(struct udevice *dev,
 	return len;
 }
 
+static const char *single_get_pin_name(struct udevice *dev,
+				       unsigned int selector)
+{
+	struct single_priv *priv = dev_get_priv(dev);
+
+	if (selector >= priv->npins)
+		snprintf(priv->pin_name, PINNAME_SIZE, "Error");
+	else
+		snprintf(priv->pin_name, PINNAME_SIZE, "PIN%u", selector);
+
+	return priv->pin_name;
+}
+
 static int single_get_pins_count(struct udevice *dev)
 {
 	struct single_priv *priv = dev_get_priv(dev);
@@ -286,6 +301,7 @@ static int single_of_to_plat(struct udevice *dev)
 
 const struct pinctrl_ops single_pinctrl_ops = {
 	.get_pins_count	= single_get_pins_count,
+	.get_pin_name = single_get_pin_name,
 	.set_state = single_set_state,
 };
 
-- 
2.17.1

  parent reply	other threads:[~2021-01-23 18:27 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-23 18:27 [PATCH 00/11] Add support for pinmux status command on beaglebone Dario Binacchi
2021-01-23 18:27 ` [PATCH 01/11] pinctrl: single: fix format of structure documentation Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-23 18:27 ` [PATCH 02/11] pinctrl: single: fix the loop counter variable type Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-25 16:53   ` Pratyush Yadav
2021-01-23 18:27 ` [PATCH 03/11] pinctrl: single: fix debug messages formatting Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-25 17:09   ` Pratyush Yadav
2021-01-26 11:20     ` Dario Binacchi
2021-01-27  9:29       ` Pratyush Yadav
2021-01-23 18:27 ` [PATCH 04/11] pinctrl: single: get register area size by device API Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-23 18:27 ` [PATCH 05/11] pinctrl: single: check "register-width" DT property Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-23 18:27 ` [PATCH 06/11] pinctrl: single: change function mask default value Dario Binacchi
2021-01-23 18:27 ` [PATCH 07/11] pinctrl: single: use function pointer for register access Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-24 16:50     ` Dario Binacchi
2021-01-24 18:00       ` Simon Glass
2021-01-23 18:27 ` [PATCH 08/11] pinctrl: single: add get_pins_count operation Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-23 18:27 ` Dario Binacchi [this message]
2021-01-24  2:03   ` [PATCH 09/11] pinctrl: single: add get_pin_name operation Simon Glass
2021-01-23 18:27 ` [PATCH 10/11] pinctrl: single: add get_pin_muxing operation Dario Binacchi
2021-01-24  2:03   ` Simon Glass
2021-01-26 11:28     ` Dario Binacchi
2021-02-01 20:38       ` Simon Glass
2021-01-23 18:27 ` [PATCH 11/11] test: pinmux: add test for 'pinctrl-single' driver Dario Binacchi
2021-01-24  2:03   ` Simon Glass

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=20210123182711.7177-10-dariobin@libero.it \
    --to=dariobin@libero.it \
    --cc=u-boot@lists.denx.de \
    /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 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.