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 09/21] gpio: add function _dm_gpio_set_dir_flags
Date: Mon, 13 Jan 2020 11:35:03 +0100	[thread overview]
Message-ID: <20200113103515.20879-10-patrick.delaunay@st.com> (raw)
In-Reply-To: <20200113103515.20879-1-patrick.delaunay@st.com>

Introduce the function _dm_gpio_set_dir_flags to set dir flags
without check if the GPIO is reserved.

Separate the reserved check for "set_dir" and "set_dir_flags".

This patch is a preliminary step to add new ops.

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

This patch was part of v2 08/14
= gpio: add ops for configuration with dir flags


Changes in v3:
- Split the previous patch [PATCH v2 08/14] to help review

Changes in v2: None

 drivers/gpio/gpio-uclass.c | 38 +++++++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index bdf7f5bb4e..94e90cb8ac 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -510,15 +510,11 @@ int dm_gpio_set_value(const struct gpio_desc *desc, int value)
 	return 0;
 }
 
-int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
+static int _dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
 {
 	struct udevice *dev = desc->dev;
 	struct dm_gpio_ops *ops = gpio_get_ops(dev);
-	int ret;
-
-	ret = check_reserved(desc, "set_dir");
-	if (ret)
-		return ret;
+	int ret = 0;
 
 	if (flags & GPIOD_IS_OUT) {
 		int value = flags & GPIOD_IS_OUT_ACTIVE ? 1 : 0;
@@ -529,20 +525,36 @@ int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
 	} else  if (flags & GPIOD_IS_IN) {
 		ret = ops->direction_input(dev, desc->offset);
 	}
+
+	return ret;
+}
+
+int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags)
+{
+	int ret;
+
+	ret = check_reserved(desc, "set_dir_flags");
 	if (ret)
 		return ret;
-	/*
-	 * Update desc->flags here, so that GPIO_ACTIVE_LOW is honoured in
-	 * futures
-	 */
-	desc->flags = flags;
 
-	return 0;
+	ret = _dm_gpio_set_dir_flags(desc, flags);
+
+	/* update the descriptor flags */
+	if (ret)
+		desc->flags = flags;
+
+	return ret;
 }
 
 int dm_gpio_set_dir(struct gpio_desc *desc)
 {
-	return dm_gpio_set_dir_flags(desc, desc->flags);
+	int ret;
+
+	ret = check_reserved(desc, "set_dir");
+	if (ret)
+		return ret;
+
+	return _dm_gpio_set_dir_flags(desc, desc->flags);
 }
 
 /**
-- 
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 ` [PATCH v3 07/21] gpio: add gpio descriptor initialization helper Patrick Delaunay
2020-04-17 21:06   ` 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 ` Patrick Delaunay [this message]
2020-01-30  2:18   ` [PATCH v3 09/21] gpio: add function _dm_gpio_set_dir_flags 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-10-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.