[U-Boot] [PATCH 10/13] gpio: sandbox: cleanup flag support

Patrick Delaunay patrick.delaunay at st.com
Wed Oct 23 13:44:45 UTC 2019


Replace the GPIOF_ defines of gpio UCLASS (they are not bitfields but
enum gpio_func_t = State of a GPIO, as reported by get_function())
by GPIO_FLAG to access to the bitfield 'flags' of struct gpio_state.

This patch avoid confusion between sandbox and gpio UCLASS defines.

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

 drivers/gpio/sandbox.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 2ef5c67ad5..b6c78cc46a 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -11,14 +11,14 @@
 #include <dm/of.h>
 #include <dt-bindings/gpio/gpio.h>
 
-/* Flags for each GPIO */
-#define GPIOF_OUTPUT	(1 << 0)	/* Currently set as an output */
-#define GPIOF_HIGH	(1 << 1)	/* Currently set high */
-#define GPIOF_ODR	(1 << 2)	/* Currently set to open drain mode */
+/* Internal flags for each GPIO : bitfield*/
+#define GPIO_FLAG_OUTPUT	BIT(0)	/* Currently set as an output */
+#define GPIO_FLAG_HIGH		BIT(1)	/* Currently set high */
+#define GPIO_FLAG_ODR		BIT(2)	/* Currently set to open drain mode */
 
 struct gpio_state {
 	const char *label;	/* label given by requester */
-	u8 flags;		/* flags (GPIOF_...) */
+	u8 flags;		/* bitfield flags (GPIO_FLAG_...) */
 };
 
 /* Access routines for GPIO state */
@@ -60,34 +60,34 @@ static int set_gpio_flag(struct udevice *dev, unsigned offset, int flag,
 
 int sandbox_gpio_get_value(struct udevice *dev, unsigned offset)
 {
-	if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
+	if (get_gpio_flag(dev, offset, GPIO_FLAG_OUTPUT))
 		debug("sandbox_gpio: get_value on output gpio %u\n", offset);
-	return get_gpio_flag(dev, offset, GPIOF_HIGH);
+	return get_gpio_flag(dev, offset, GPIO_FLAG_HIGH);
 }
 
 int sandbox_gpio_set_value(struct udevice *dev, unsigned offset, int value)
 {
-	return set_gpio_flag(dev, offset, GPIOF_HIGH, value);
+	return set_gpio_flag(dev, offset, GPIO_FLAG_HIGH, value);
 }
 
 int sandbox_gpio_get_open_drain(struct udevice *dev, unsigned offset)
 {
-	return get_gpio_flag(dev, offset, GPIOF_ODR);
+	return get_gpio_flag(dev, offset, GPIO_FLAG_ODR);
 }
 
 int sandbox_gpio_set_open_drain(struct udevice *dev, unsigned offset, int value)
 {
-	return set_gpio_flag(dev, offset, GPIOF_ODR, value);
+	return set_gpio_flag(dev, offset, GPIO_FLAG_ODR, value);
 }
 
 int sandbox_gpio_get_direction(struct udevice *dev, unsigned offset)
 {
-	return get_gpio_flag(dev, offset, GPIOF_OUTPUT);
+	return get_gpio_flag(dev, offset, GPIO_FLAG_OUTPUT);
 }
 
 int sandbox_gpio_set_direction(struct udevice *dev, unsigned offset, int output)
 {
-	return set_gpio_flag(dev, offset, GPIOF_OUTPUT, output);
+	return set_gpio_flag(dev, offset, GPIO_FLAG_OUTPUT, output);
 }
 
 /*
@@ -158,7 +158,7 @@ static int sb_gpio_set_open_drain(struct udevice *dev, unsigned offset, int valu
 
 static int sb_gpio_get_function(struct udevice *dev, unsigned offset)
 {
-	if (get_gpio_flag(dev, offset, GPIOF_OUTPUT))
+	if (get_gpio_flag(dev, offset, GPIO_FLAG_OUTPUT))
 		return GPIOF_OUTPUT;
 	return GPIOF_INPUT;
 }
-- 
2.17.1



More information about the U-Boot mailing list