All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 07/21] gpio: add gpio descriptor initialization helper
Date: Mon, 13 Jan 2020 11:35:01 +0100	[thread overview]
Message-ID: <20200113103515.20879-8-patrick.delaunay@st.com> (raw)
In-Reply-To: <20200113103515.20879-1-patrick.delaunay@st.com>

Add a helper function gpio_desc_init() to initialize the gpio descriptor;
with this function the flags will be always set to 0.

It wasn't the case before this patch in dm_gpio_lookup_name.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

Changes in v3: None
Changes in v2:
- add gpio descriptor initialization helper

 drivers/gpio/gpio-uclass.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index eb599cbcfd..0870458e96 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -18,6 +18,22 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+/**
+ * gpio_desc_init() - Initialize the GPIO descriptor
+ *
+ * @desc:	GPIO descriptor to initialize
+ * @dev:	GPIO device
+ * @offset:	Offset of device GPIO
+ */
+static void gpio_desc_init(struct gpio_desc *desc,
+			   struct udevice *dev,
+			   uint offset)
+{
+	desc->dev = dev;
+	desc->offset = offset;
+	desc->flags = 0;
+}
+
 /**
  * gpio_to_device() - Convert global GPIO number to device, number
  *
@@ -41,9 +57,7 @@ static int gpio_to_device(unsigned int gpio, struct gpio_desc *desc)
 		uc_priv = dev_get_uclass_priv(dev);
 		if (gpio >= uc_priv->gpio_base &&
 		    gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
-			desc->dev = dev;
-			desc->offset = gpio - uc_priv->gpio_base;
-			desc->flags = 0;
+			gpio_desc_init(desc, dev, gpio - uc_priv->gpio_base);
 			return 0;
 		}
 	}
@@ -85,8 +99,7 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc)
 	if (!dev)
 		return ret ? ret : -EINVAL;
 
-	desc->dev = dev;
-	desc->offset = offset;
+	gpio_desc_init(desc, dev, offset);
 
 	return 0;
 }
@@ -772,9 +785,7 @@ static int gpio_request_tail(int ret, const char *nodename,
 			     struct gpio_desc *desc, int flags,
 			     bool add_index, struct udevice *gpio_dev)
 {
-	desc->dev = gpio_dev;
-	desc->offset = 0;
-	desc->flags = 0;
+	gpio_desc_init(desc, gpio_dev, 0);
 	if (ret)
 		goto err;
 
-- 
2.17.1

  parent reply	other threads:[~2020-01-13 10:35 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-13 10:34 [PATCH v3 00/21] dm: add support of new binding in gpio and pincontrol Patrick Delaunay
2020-01-13 10:34 ` [PATCH v3 01/21] dm: pinctrl: convert pinctrl-single to livetree Patrick Delaunay
2020-04-17 21:05   ` Tom Rini
2020-04-22 16:27     ` Tom Rini
2020-04-22 17:29       ` Lokesh Vutla
2020-01-13 10:34 ` [PATCH v3 02/21] dm: core: add ofnode and dev function to iterate on node property Patrick Delaunay
2020-01-30  2:17   ` Simon Glass
2020-04-17 21:05   ` Tom Rini
2020-01-13 10:34 ` [PATCH v3 03/21] dm: pinctrl: migrate pinctrl-generic to livetree Patrick Delaunay
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:34 ` [PATCH v3 04/21] dt-bindings: gpio: document the new pull-up/pull-down flags Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:34 ` [PATCH v3 05/21] gpio: remove GPIOD_REQUESTED Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 06/21] gpio: remove the open_drain API and ops Patrick Delaunay
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` Patrick Delaunay [this message]
2020-04-17 21:06   ` [PATCH v3 07/21] gpio: add gpio descriptor initialization helper Tom Rini
2020-01-13 10:35 ` [PATCH v3 08/21] gpio: add function _gpio_get_value Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 09/21] gpio: add function _dm_gpio_set_dir_flags Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 10/21] gpio: add function check_dir_flags Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 11/21] gpio: add helper GPIOD_FLAGS_OUTPUT Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 12/21] gpio: update dir_flags management Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 13/21] gpio: add support of new GPIO direction flag Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:06   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 14/21] gpio: add ops to get dir flags Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 15/21] gpio: add ops to set " Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 16/21] dt-bindings: gpio: alignment with kernel v5.3 Patrick Delaunay
2020-01-30  2:18   ` Simon Glass
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 17/21] pinctrl: sandbox: Add mux information in get_pin_muxing Patrick Delaunay
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 18/21] test: dm: update test for pins configuration in pinctrl node Patrick Delaunay
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 19/21] gpio: sandbox: cleanup binding support Patrick Delaunay
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 20/21] test: dm: update test for pins configuration in gpio Patrick Delaunay
2020-04-17 21:07   ` Tom Rini
2020-01-13 10:35 ` [PATCH v3 21/21] test: pinmux: add pincontrol-gpio for pin configuration Patrick Delaunay
2020-04-17 21:07   ` Tom Rini
2020-03-27 19:21 ` [PATCH v3 00/21] dm: add support of new binding in gpio and pincontrol Tom Rini
2020-03-27 19:44   ` Simon Glass
2020-03-28 20:04     ` 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=20200113103515.20879-8-patrick.delaunay@st.com \
    --to=patrick.delaunay@st.com \
    --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.