diff mbox series

[v3,08/21] gpio: add function _gpio_get_value

Message ID 20200113103515.20879-9-patrick.delaunay@st.com
State Accepted
Commit 8a9140cd38c5571fc23d1e7b293ca22325d41afc
Headers show
Series dm: add support of new binding in gpio and pincontrol | expand

Commit Message

Patrick Delaunay Jan. 13, 2020, 10:35 a.m. UTC
Introduce the function _gpio_get_value to get the GPIO value
without check if it is reserved.
This patch prepare new ops introduction.

Signed-off-by: Patrick Delaunay <patrick.delaunay at 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 | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Comments

Simon Glass Jan. 30, 2020, 2:18 a.m. UTC | #1
On Mon, 13 Jan 2020 at 03:35, Patrick Delaunay <patrick.delaunay at st.com> wrote:
>
> Introduce the function _gpio_get_value to get the GPIO value
> without check if it is reserved.
> This patch prepare new ops introduction.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay at 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 | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

Reviewed-by: Simon Glass <sjg at chromium.org>
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 0870458e96..bdf7f5bb4e 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -476,18 +476,24 @@  int gpio_direction_output(unsigned gpio, int value)
 							desc.offset, value);
 }
 
-int dm_gpio_get_value(const struct gpio_desc *desc)
+static int _gpio_get_value(const struct gpio_desc *desc)
 {
 	int value;
+
+	value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
+
+	return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
+}
+
+int dm_gpio_get_value(const struct gpio_desc *desc)
+{
 	int ret;
 
 	ret = check_reserved(desc, "get_value");
 	if (ret)
 		return ret;
 
-	value = gpio_get_ops(desc->dev)->get_value(desc->dev, desc->offset);
-
-	return desc->flags & GPIOD_ACTIVE_LOW ? !value : value;
+	return _gpio_get_value(desc);
 }
 
 int dm_gpio_set_value(const struct gpio_desc *desc, int value)