Skip to contentSkip to conversation

serial: mxs-auart: Compare the return value of gpiod_get_direction against GPIO_LINE_DIRECTION_IN

PATCH In review Nikola Z. Ivanov 2 participants 3 messages Apr 16 – Apr 17

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 serial: mxs-auart: Compare the return value of gpiod_get_direction against GPIO_LINE_DIRECTION_IN

The GPIO_LINE_DIRECTION_* definitions have just recently been exposed to gpio consumers.h by breaking them out in a separate defs.h file.

Use this to validate the gpio direction instead of the hard-coded literal.

---
 drivers/tty/serial/mxs-auart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +1 -1
index cc65c9fb6446..6c6df4d5c21f 100644
@@ -1519,7 +1519,7 @@ static int mxs_auart_init_gpios(struct mxs_auart_port *s, struct device *dev)
 
 	for (i = 0; i < UART_GPIO_MAX; i++) {
 		gpiod = mctrl_gpio_to_gpiod(s->gpios, i);
-		if (gpiod && (gpiod_get_direction(gpiod) == 1))
+		if (gpiod && (gpiod_get_direction(gpiod) == GPIO_LINE_DIRECTION_IN))
 			s->gpio_irq[i] = gpiod_to_irq(gpiod);
 		else
 			s->gpio_irq[i] = -EINVAL;
Signature · 1 line
2.53.0
maintainer
#1 lore raw

On Thu, Apr 16, 2026 at 11:32:54AM +0300, Nikola Z. Ivanov wrote:

subjust suggest change to

Replace hardcode 1 with predefined macro GPIO_LINE_DIRECTION_IN

Frank

Quoted 26 lines

The GPIO_LINE_DIRECTION_* definitions have just recently been exposed to gpio consumers.h by breaking them out in a separate defs.h file.

Use this to validate the gpio direction instead of the hard-coded literal.

---
 drivers/tty/serial/mxs-auart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +1 -2
index cc65c9fb6446..6c6df4d5c21f 100644
@@ -1519,7 +1519,7 @@ static int mxs_auart_init_gpios(struct mxs_auart_port *s, struct device *dev)
 
 	for (i = 0; i < UART_GPIO_MAX; i++) {
 		gpiod = mctrl_gpio_to_gpiod(s->gpios, i);
-		if (gpiod && (gpiod_get_direction(gpiod) == 1))
+		if (gpiod && (gpiod_get_direction(gpiod) == GPIO_LINE_DIRECTION_IN))
 			s->gpio_irq[i] = gpiod_to_irq(gpiod);
 		else
 			s->gpio_irq[i] = -EINVAL;
--

2.53.0

#2 lore raw
Quoted 7 lines · Frank Li

On Thu, Apr 16, 2026 at 11:32:54AM +0300, Nikola Z. Ivanov wrote:

subjust suggest change to

Replace hardcode 1 with predefined macro GPIO_LINE_DIRECTION_IN

Frank

Hello,

I suppose you are suggesting a subject change, in that case I will send v2. Also I can see that automated code review notes that this will not build on greg's tty tree as 7.0 is not yet merged into it. I will wait for that to happen before mailing v2.

BR,
Nikola

Quoted 27 lines
Quoted 27 lines

The GPIO_LINE_DIRECTION_* definitions have just recently been exposed to gpio consumers.h by breaking them out in a separate defs.h file.

Use this to validate the gpio direction instead of the hard-coded literal.

---
  drivers/tty/serial/mxs-auart.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +1 -2
index cc65c9fb6446..6c6df4d5c21f 100644
@@ -1519,7 +1519,7 @@ static int mxs_auart_init_gpios(struct mxs_auart_port *s, struct device *dev)
 
  	for (i = 0; i < UART_GPIO_MAX; i++) {
  		gpiod = mctrl_gpio_to_gpiod(s->gpios, i);
-		if (gpiod && (gpiod_get_direction(gpiod) == 1))
+		if (gpiod && (gpiod_get_direction(gpiod) == GPIO_LINE_DIRECTION_IN))
  			s->gpio_irq[i] = gpiod_to_irq(gpiod);
  		else
  			s->gpio_irq[i] = -EINVAL;
--

2.53.0