Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error
@ 2019-08-14  9:27 Geert Uytterhoeven
  2019-08-14  9:27 ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, linux-renesas-soc, NXP Linux Team,
	Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel

	Hi Greg, Jiri,

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check in serial drivers if
mctrl_gpio_to_gpiod() returns an error value.  A simple NULL check is
sufficient.

This series follows the spirit of commit 445df7ff3fd1a0a9 ("serial:
mctrl-gpio: drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Thanks!

Geert Uytterhoeven (3):
  serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  serial: mxs-auart: Don't check for mctrl_gpio_to_gpiod() returning
    error
  serial: sh-sci: Don't check for mctrl_gpio_to_gpiod() returning error

 drivers/tty/serial/atmel_serial.c | 12 ++++--------
 drivers/tty/serial/mxs-auart.c    |  6 ++----
 drivers/tty/serial/sh-sci.c       | 12 +++++-------
 3 files changed, 11 insertions(+), 19 deletions(-)

-- 
2.17.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:27 [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error Geert Uytterhoeven
@ 2019-08-14  9:27 ` " Geert Uytterhoeven
  2019-08-14  9:27 ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, linux-renesas-soc, NXP Linux Team,
	Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/atmel_serial.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 19a85d6fe3d20541..e9620a81166b7dc1 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
 
 	mctrl_gpio_get(atmel_port->gpios, &ret);
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_CTS))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
 		if (ret & TIOCM_CTS)
 			status &= ~ATMEL_US_CTS;
 		else
 			status |= ATMEL_US_CTS;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_DSR))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) {
 		if (ret & TIOCM_DSR)
 			status &= ~ATMEL_US_DSR;
 		else
 			status |= ATMEL_US_DSR;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_RI))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) {
 		if (ret & TIOCM_RI)
 			status &= ~ATMEL_US_RI;
 		else
 			status |= ATMEL_US_RI;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_DCD))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) {
 		if (ret & TIOCM_CD)
 			status &= ~ATMEL_US_DCD;
 		else
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 2/3] serial: mxs-auart: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:27 [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error Geert Uytterhoeven
  2019-08-14  9:27 ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
@ 2019-08-14  9:27 ` " Geert Uytterhoeven
  2019-08-14  9:27 ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
  2019-08-14  9:29 ` [PATCH 0/3] serial: " Geert Uytterhoeven
  3 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, linux-renesas-soc, NXP Linux Team,
	Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/mxs-auart.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 4c188f4079b3ea68..e3452597068292f9 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -969,10 +969,8 @@ static int mxs_auart_dma_init(struct mxs_auart_port *s)
 
 }
 
-#define RTS_AT_AUART()	IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,	\
-							UART_GPIO_RTS))
-#define CTS_AT_AUART()	IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,	\
-							UART_GPIO_CTS))
+#define RTS_AT_AUART()	!mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_RTS)
+#define CTS_AT_AUART()	!mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_CTS)
 static void mxs_auart_settermios(struct uart_port *u,
 				 struct ktermios *termios,
 				 struct ktermios *old)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/3] serial: sh-sci: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:27 [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error Geert Uytterhoeven
  2019-08-14  9:27 ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
  2019-08-14  9:27 ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
@ 2019-08-14  9:27 ` " Geert Uytterhoeven
  2019-08-14  9:29 ` [PATCH 0/3] serial: " Geert Uytterhoeven
  3 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:27 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, linux-renesas-soc, NXP Linux Team,
	Pengutronix Kernel Team, Fabio Estevam, linux-arm-kernel

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/sh-sci.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7f565fcbf1ca4c5e..4e754a4850e6db63 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2099,12 +2099,12 @@ static unsigned int sci_get_mctrl(struct uart_port *port)
 	if (s->autorts) {
 		if (sci_get_cts(port))
 			mctrl |= TIOCM_CTS;
-	} else if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_CTS))) {
+	} else if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_CTS)) {
 		mctrl |= TIOCM_CTS;
 	}
-	if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_DSR)))
+	if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_DSR))
 		mctrl |= TIOCM_DSR;
-	if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_DCD)))
+	if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_DCD))
 		mctrl |= TIOCM_CAR;
 
 	return mctrl;
@@ -3285,10 +3285,8 @@ static int sci_probe_single(struct platform_device *dev,
 		return PTR_ERR(sciport->gpios);
 
 	if (sciport->has_rtscts) {
-		if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(sciport->gpios,
-							UART_GPIO_CTS)) ||
-		    !IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(sciport->gpios,
-							UART_GPIO_RTS))) {
+		if (mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_CTS) ||
+		    mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_RTS)) {
 			dev_err(&dev->dev, "Conflicting RTS/CTS config\n");
 			return -EINVAL;
 		}
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:27 [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error Geert Uytterhoeven
                   ` (2 preceding siblings ...)
  2019-08-14  9:27 ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
@ 2019-08-14  9:29 ` " Geert Uytterhoeven
  2019-08-14  9:29   ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
                     ` (2 more replies)
  3 siblings, 3 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, Frieder Schrempf, linux-renesas-soc,
	NXP Linux Team, Pengutronix Kernel Team, Uwe Kleine-König,
	Fabio Estevam, linux-arm-kernel

	Hi Greg, Jiri,

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check in serial drivers if
mctrl_gpio_to_gpiod() returns an error value.  A simple NULL check is
sufficient.

This series follows the spirit of commit 445df7ff3fd1a0a9 ("serial:
mctrl-gpio: drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Thanks!

Geert Uytterhoeven (3):
  serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  serial: mxs-auart: Don't check for mctrl_gpio_to_gpiod() returning
    error
  serial: sh-sci: Don't check for mctrl_gpio_to_gpiod() returning error

 drivers/tty/serial/atmel_serial.c | 12 ++++--------
 drivers/tty/serial/mxs-auart.c    |  6 ++----
 drivers/tty/serial/sh-sci.c       | 12 +++++-------
 3 files changed, 11 insertions(+), 19 deletions(-)

-- 
2.17.1

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:29 ` [PATCH 0/3] serial: " Geert Uytterhoeven
@ 2019-08-14  9:29   ` " Geert Uytterhoeven
  2019-08-14  9:35     ` Uwe Kleine-König
  2019-08-14  9:29   ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
  2019-08-14  9:29   ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
  2 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, Frieder Schrempf, linux-renesas-soc,
	NXP Linux Team, Pengutronix Kernel Team, Uwe Kleine-König,
	Fabio Estevam, linux-arm-kernel

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/atmel_serial.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 19a85d6fe3d20541..e9620a81166b7dc1 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
 
 	mctrl_gpio_get(atmel_port->gpios, &ret);
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_CTS))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
 		if (ret & TIOCM_CTS)
 			status &= ~ATMEL_US_CTS;
 		else
 			status |= ATMEL_US_CTS;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_DSR))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) {
 		if (ret & TIOCM_DSR)
 			status &= ~ATMEL_US_DSR;
 		else
 			status |= ATMEL_US_DSR;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_RI))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) {
 		if (ret & TIOCM_RI)
 			status &= ~ATMEL_US_RI;
 		else
 			status |= ATMEL_US_RI;
 	}
 
-	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
-						UART_GPIO_DCD))) {
+	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) {
 		if (ret & TIOCM_CD)
 			status &= ~ATMEL_US_DCD;
 		else
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 2/3] serial: mxs-auart: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:29 ` [PATCH 0/3] serial: " Geert Uytterhoeven
  2019-08-14  9:29   ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
@ 2019-08-14  9:29   ` " Geert Uytterhoeven
  2019-08-19 12:26     ` Simon Horman
  2019-08-14  9:29   ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
  2 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, Frieder Schrempf, linux-renesas-soc,
	NXP Linux Team, Pengutronix Kernel Team, Uwe Kleine-König,
	Fabio Estevam, linux-arm-kernel

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/mxs-auart.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
index 4c188f4079b3ea68..e3452597068292f9 100644
--- a/drivers/tty/serial/mxs-auart.c
+++ b/drivers/tty/serial/mxs-auart.c
@@ -969,10 +969,8 @@ static int mxs_auart_dma_init(struct mxs_auart_port *s)
 
 }
 
-#define RTS_AT_AUART()	IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,	\
-							UART_GPIO_RTS))
-#define CTS_AT_AUART()	IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,	\
-							UART_GPIO_CTS))
+#define RTS_AT_AUART()	!mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_RTS)
+#define CTS_AT_AUART()	!mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_CTS)
 static void mxs_auart_settermios(struct uart_port *u,
 				 struct ktermios *termios,
 				 struct ktermios *old)
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/3] serial: sh-sci: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:29 ` [PATCH 0/3] serial: " Geert Uytterhoeven
  2019-08-14  9:29   ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
  2019-08-14  9:29   ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
@ 2019-08-14  9:29   ` " Geert Uytterhoeven
  2019-08-19  9:51     ` Simon Horman
  2 siblings, 1 reply; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14  9:29 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, Geert Uytterhoeven, Richard Genoud, Shawn Guo,
	Sascha Hauer, Frieder Schrempf, linux-renesas-soc,
	NXP Linux Team, Pengutronix Kernel Team, Uwe Kleine-König,
	Fabio Estevam, linux-arm-kernel

Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
routine"), mctrl_gpio_init() returns failure if the assignment to any
member of the gpio array results in an error pointer.
Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
!CONFIG_GPIOLIB case.
Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
returning an error value.  A simple NULL check is sufficient.

This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/tty/serial/sh-sci.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 7f565fcbf1ca4c5e..4e754a4850e6db63 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2099,12 +2099,12 @@ static unsigned int sci_get_mctrl(struct uart_port *port)
 	if (s->autorts) {
 		if (sci_get_cts(port))
 			mctrl |= TIOCM_CTS;
-	} else if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_CTS))) {
+	} else if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_CTS)) {
 		mctrl |= TIOCM_CTS;
 	}
-	if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_DSR)))
+	if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_DSR))
 		mctrl |= TIOCM_DSR;
-	if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_DCD)))
+	if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_DCD))
 		mctrl |= TIOCM_CAR;
 
 	return mctrl;
@@ -3285,10 +3285,8 @@ static int sci_probe_single(struct platform_device *dev,
 		return PTR_ERR(sciport->gpios);
 
 	if (sciport->has_rtscts) {
-		if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(sciport->gpios,
-							UART_GPIO_CTS)) ||
-		    !IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(sciport->gpios,
-							UART_GPIO_RTS))) {
+		if (mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_CTS) ||
+		    mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_RTS)) {
 			dev_err(&dev->dev, "Conflicting RTS/CTS config\n");
 			return -EINVAL;
 		}
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:29   ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
@ 2019-08-14  9:35     ` Uwe Kleine-König
  2019-08-14 10:20       ` Geert Uytterhoeven
  0 siblings, 1 reply; 17+ messages in thread
From: Uwe Kleine-König @ 2019-08-14  9:35 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Alexandre Belloni, Pengutronix Kernel Team, linux-serial,
	Richard Genoud, Greg Kroah-Hartman, Sascha Hauer,
	Frieder Schrempf, linux-renesas-soc, Ludovic Desroches,
	NXP Linux Team, Fabio Estevam, Jiri Slaby, Shawn Guo,
	linux-arm-kernel

Hello,

[adding the Atmel guys to Cc]

On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> routine"), mctrl_gpio_init() returns failure if the assignment to any
> member of the gpio array results in an error pointer.
> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> !CONFIG_GPIOLIB case.
> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> returning an error value.  A simple NULL check is sufficient.
> 
> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>  
>  	mctrl_gpio_get(atmel_port->gpios, &ret);
>  
> -	if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> -						UART_GPIO_CTS))) {
> +	if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>  		if (ret & TIOCM_CTS)
>  			status &= ~ATMEL_US_CTS;
>  		else
>  			status |= ATMEL_US_CTS;
>  	}

The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
as expected (at least as expected by me). IMHO driving the hardware
function of the CTS pin shouldn't be conditional on the presence of a
cts-gpio. Is there a reason not to just drop the if completely?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:35     ` Uwe Kleine-König
@ 2019-08-14 10:20       ` Geert Uytterhoeven
  2019-08-14 11:08         ` Uwe Kleine-König
  2019-08-20 15:11         ` Richard Genoud
  0 siblings, 2 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-14 10:20 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Alexandre Belloni, Pengutronix Kernel Team, Geert Uytterhoeven,
	open list:SERIAL DRIVERS, Richard Genoud, Greg Kroah-Hartman,
	Sascha Hauer, Frieder Schrempf, Linux-Renesas, Ludovic Desroches,
	NXP Linux Team, Fabio Estevam, Jiri Slaby, Shawn Guo, Linux ARM

Hi Uwe,

On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> > Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> > routine"), mctrl_gpio_init() returns failure if the assignment to any
> > member of the gpio array results in an error pointer.
> > Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> > in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> > !CONFIG_GPIOLIB case.
> > Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> > returning an error value.  A simple NULL check is sufficient.
> >
> > This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> > drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> >  drivers/tty/serial/atmel_serial.c | 12 ++++--------
> >  1 file changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> > index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> > --- a/drivers/tty/serial/atmel_serial.c
> > +++ b/drivers/tty/serial/atmel_serial.c
> > @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
> >
> >       mctrl_gpio_get(atmel_port->gpios, &ret);
> >
> > -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> > -                                             UART_GPIO_CTS))) {
> > +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
> >               if (ret & TIOCM_CTS)
> >                       status &= ~ATMEL_US_CTS;
> >               else
> >                       status |= ATMEL_US_CTS;
> >       }
>
> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
> as expected (at least as expected by me). IMHO driving the hardware
> function of the CTS pin shouldn't be conditional on the presence of a
> cts-gpio. Is there a reason not to just drop the if completely?

The above code returns the hardware status if CTS is not a GPIO, and
returns (overrides with) the GPIO status if CTS is a GPIO.
Isn't that correct, or am I missing something?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14 10:20       ` Geert Uytterhoeven
@ 2019-08-14 11:08         ` Uwe Kleine-König
  2019-08-20 15:47           ` Richard Genoud
  2019-08-20 15:11         ` Richard Genoud
  1 sibling, 1 reply; 17+ messages in thread
From: Uwe Kleine-König @ 2019-08-14 11:08 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Alexandre Belloni, Pengutronix Kernel Team, Geert Uytterhoeven,
	open list:SERIAL DRIVERS, Richard Genoud, Greg Kroah-Hartman,
	Sascha Hauer, Frieder Schrempf, Linux-Renesas, Ludovic Desroches,
	NXP Linux Team, Fabio Estevam, Jiri Slaby, Shawn Guo, Linux ARM

On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
> Hi Uwe,
> 
> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> > > Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> > > routine"), mctrl_gpio_init() returns failure if the assignment to any
> > > member of the gpio array results in an error pointer.
> > > Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> > > in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> > > !CONFIG_GPIOLIB case.
> > > Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> > > returning an error value.  A simple NULL check is sufficient.
> > >
> > > This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> > > drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > >  drivers/tty/serial/atmel_serial.c | 12 ++++--------
> > >  1 file changed, 4 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> > > index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> > > --- a/drivers/tty/serial/atmel_serial.c
> > > +++ b/drivers/tty/serial/atmel_serial.c
> > > @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
> > >
> > >       mctrl_gpio_get(atmel_port->gpios, &ret);
> > >
> > > -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> > > -                                             UART_GPIO_CTS))) {
> > > +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
> > >               if (ret & TIOCM_CTS)
> > >                       status &= ~ATMEL_US_CTS;
> > >               else
> > >                       status |= ATMEL_US_CTS;
> > >       }
> >
> > The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
> > as expected (at least as expected by me). IMHO driving the hardware
> > function of the CTS pin shouldn't be conditional on the presence of a
> > cts-gpio. Is there a reason not to just drop the if completely?
> 
> The above code returns the hardware status if CTS is not a GPIO, and
> returns (overrides with) the GPIO status if CTS is a GPIO.
> Isn't that correct, or am I missing something?

I took a deeper look into this driver now. The task for
atmel_get_lines_status() isn't to implement the get_mctrl() callback.

Instead this is called in the irqhandler to set ATMEL_US_RI in a
"pending" value that then later in atmel_handle_status() is translated
to a "ring" event that is handled there.

So the right cleanup would be to let atmel_get_lines_status() just be

	return atmel_uart_readl(port, ATMEL_US_CSR);

. If something happend on the lines implemented as gpio the driver's irq
function isn't called anyhow.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 3/3] serial: sh-sci: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:29   ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
@ 2019-08-19  9:51     ` Simon Horman
  0 siblings, 0 replies; 17+ messages in thread
From: Simon Horman @ 2019-08-19  9:51 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Pengutronix Kernel Team, linux-serial, Richard Genoud,
	Greg Kroah-Hartman, Sascha Hauer, Jiri Slaby, Frieder Schrempf,
	linux-renesas-soc, NXP Linux Team, Fabio Estevam,
	Uwe Kleine-König, Shawn Guo, linux-arm-kernel

On Wed, Aug 14, 2019 at 11:29:24AM +0200, Geert Uytterhoeven wrote:
> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> routine"), mctrl_gpio_init() returns failure if the assignment to any
> member of the gpio array results in an error pointer.
> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> !CONFIG_GPIOLIB case.
> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> returning an error value.  A simple NULL check is sufficient.
> 
> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/tty/serial/sh-sci.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index 7f565fcbf1ca4c5e..4e754a4850e6db63 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -2099,12 +2099,12 @@ static unsigned int sci_get_mctrl(struct uart_port *port)
>  	if (s->autorts) {
>  		if (sci_get_cts(port))
>  			mctrl |= TIOCM_CTS;
> -	} else if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_CTS))) {
> +	} else if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_CTS)) {
>  		mctrl |= TIOCM_CTS;
>  	}
> -	if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_DSR)))
> +	if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_DSR))
>  		mctrl |= TIOCM_DSR;
> -	if (IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(gpios, UART_GPIO_DCD)))
> +	if (!mctrl_gpio_to_gpiod(gpios, UART_GPIO_DCD))
>  		mctrl |= TIOCM_CAR;
>  
>  	return mctrl;
> @@ -3285,10 +3285,8 @@ static int sci_probe_single(struct platform_device *dev,
>  		return PTR_ERR(sciport->gpios);
>  
>  	if (sciport->has_rtscts) {
> -		if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(sciport->gpios,
> -							UART_GPIO_CTS)) ||
> -		    !IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(sciport->gpios,
> -							UART_GPIO_RTS))) {
> +		if (mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_CTS) ||
> +		    mctrl_gpio_to_gpiod(sciport->gpios, UART_GPIO_RTS)) {
>  			dev_err(&dev->dev, "Conflicting RTS/CTS config\n");
>  			return -EINVAL;
>  		}
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/3] serial: mxs-auart: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14  9:29   ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
@ 2019-08-19 12:26     ` Simon Horman
  0 siblings, 0 replies; 17+ messages in thread
From: Simon Horman @ 2019-08-19 12:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Pengutronix Kernel Team, linux-serial, Richard Genoud,
	Greg Kroah-Hartman, Sascha Hauer, Jiri Slaby, Frieder Schrempf,
	linux-renesas-soc, NXP Linux Team, Fabio Estevam,
	Uwe Kleine-König, Shawn Guo, linux-arm-kernel

On Wed, Aug 14, 2019 at 11:29:23AM +0200, Geert Uytterhoeven wrote:
> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> routine"), mctrl_gpio_init() returns failure if the assignment to any
> member of the gpio array results in an error pointer.
> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> !CONFIG_GPIOLIB case.
> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> returning an error value.  A simple NULL check is sufficient.
> 
> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Simon Horman <horms+renesas@verge.net.au>

> ---
>  drivers/tty/serial/mxs-auart.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/mxs-auart.c b/drivers/tty/serial/mxs-auart.c
> index 4c188f4079b3ea68..e3452597068292f9 100644
> --- a/drivers/tty/serial/mxs-auart.c
> +++ b/drivers/tty/serial/mxs-auart.c
> @@ -969,10 +969,8 @@ static int mxs_auart_dma_init(struct mxs_auart_port *s)
>  
>  }
>  
> -#define RTS_AT_AUART()	IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,	\
> -							UART_GPIO_RTS))
> -#define CTS_AT_AUART()	IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(s->gpios,	\
> -							UART_GPIO_CTS))
> +#define RTS_AT_AUART()	!mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_RTS)
> +#define CTS_AT_AUART()	!mctrl_gpio_to_gpiod(s->gpios, UART_GPIO_CTS)
>  static void mxs_auart_settermios(struct uart_port *u,
>  				 struct ktermios *termios,
>  				 struct ktermios *old)
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14 10:20       ` Geert Uytterhoeven
  2019-08-14 11:08         ` Uwe Kleine-König
@ 2019-08-20 15:11         ` Richard Genoud
  1 sibling, 0 replies; 17+ messages in thread
From: Richard Genoud @ 2019-08-20 15:11 UTC (permalink / raw)
  To: Geert Uytterhoeven, Uwe Kleine-König
  Cc: Alexandre Belloni, Pengutronix Kernel Team, Geert Uytterhoeven,
	open list:SERIAL DRIVERS, Richard Genoud, Greg Kroah-Hartman,
	Sascha Hauer, Frieder Schrempf, Linux-Renesas, Ludovic Desroches,
	NXP Linux Team, Fabio Estevam, Jiri Slaby, Shawn Guo, Linux ARM

Hi,
Le 14/08/2019 à 12:20, Geert Uytterhoeven a écrit :
> Hi Uwe,
> 
> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
>>> member of the gpio array results in an error pointer.
>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
>>> !CONFIG_GPIOLIB case.
>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
>>> returning an error value.  A simple NULL check is sufficient.
>>>
>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
>>>
>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>> ---
>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
>>> --- a/drivers/tty/serial/atmel_serial.c
>>> +++ b/drivers/tty/serial/atmel_serial.c
>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>>>
>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
>>>
>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
>>> -                                             UART_GPIO_CTS))) {
>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>>>               if (ret & TIOCM_CTS)
>>>                       status &= ~ATMEL_US_CTS;
>>>               else
>>>                       status |= ATMEL_US_CTS;
>>>       }
>>
>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
>> as expected (at least as expected by me). IMHO driving the hardware
>> function of the CTS pin shouldn't be conditional on the presence of a
>> cts-gpio. Is there a reason not to just drop the if completely?
> 
> The above code returns the hardware status if CTS is not a GPIO, and
> returns (overrides with) the GPIO status if CTS is a GPIO.
> Isn't that correct, or am I missing something?
Yes, that's correct.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-14 11:08         ` Uwe Kleine-König
@ 2019-08-20 15:47           ` Richard Genoud
  2019-08-21 15:27             ` Richard Genoud
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Genoud @ 2019-08-20 15:47 UTC (permalink / raw)
  To: Uwe Kleine-König, Geert Uytterhoeven
  Cc: Alexandre Belloni, Pengutronix Kernel Team, Geert Uytterhoeven,
	open list:SERIAL DRIVERS, Richard Genoud, Greg Kroah-Hartman,
	Sascha Hauer, Frieder Schrempf, Linux-Renesas, Ludovic Desroches,
	NXP Linux Team, Fabio Estevam, Jiri Slaby, Shawn Guo, Linux ARM

Le 14/08/2019 à 13:08, Uwe Kleine-König a écrit :
> On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
>> Hi Uwe,
>>
>> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
>> <u.kleine-koenig@pengutronix.de> wrote:
>>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
>>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
>>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
>>>> member of the gpio array results in an error pointer.
>>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
>>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
>>>> !CONFIG_GPIOLIB case.
>>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
>>>> returning an error value.  A simple NULL check is sufficient.
>>>>
>>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
>>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
>>>>
>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>>> ---
>>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>>>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>>>
>>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
>>>> --- a/drivers/tty/serial/atmel_serial.c
>>>> +++ b/drivers/tty/serial/atmel_serial.c
>>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>>>>
>>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
>>>>
>>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
>>>> -                                             UART_GPIO_CTS))) {
>>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>>>>               if (ret & TIOCM_CTS)
>>>>                       status &= ~ATMEL_US_CTS;
>>>>               else
>>>>                       status |= ATMEL_US_CTS;
>>>>       }
>>>
>>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
>>> as expected (at least as expected by me). IMHO driving the hardware
>>> function of the CTS pin shouldn't be conditional on the presence of a
>>> cts-gpio. Is there a reason not to just drop the if completely?
>>
>> The above code returns the hardware status if CTS is not a GPIO, and
>> returns (overrides with) the GPIO status if CTS is a GPIO.
>> Isn't that correct, or am I missing something?
> 
> I took a deeper look into this driver now. The task for
> atmel_get_lines_status() isn't to implement the get_mctrl() callback.
> 
> Instead this is called in the irqhandler to set ATMEL_US_RI in a
> "pending" value that then later in atmel_handle_status() is translated
> to a "ring" event that is handled there.
> 
> So the right cleanup would be to let atmel_get_lines_status() just be
> 
> 	return atmel_uart_readl(port, ATMEL_US_CSR);
> 
> . If something happend on the lines implemented as gpio the driver's irq
> function isn't called anyhow.

I'd like to give it a good test to be sure, and I'll get back to you.

Thanks,
Richard

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-20 15:47           ` Richard Genoud
@ 2019-08-21 15:27             ` Richard Genoud
  2019-08-21 16:04               ` Geert Uytterhoeven
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Genoud @ 2019-08-21 15:27 UTC (permalink / raw)
  To: Uwe Kleine-König, Geert Uytterhoeven
  Cc: Alexandre Belloni, Pengutronix Kernel Team, Geert Uytterhoeven,
	open list:SERIAL DRIVERS, Greg Kroah-Hartman, Sascha Hauer,
	Frieder Schrempf, Linux-Renesas, Ludovic Desroches,
	NXP Linux Team, Fabio Estevam, Jiri Slaby, Shawn Guo, Linux ARM

Le 20/08/2019 à 17:47, Richard Genoud a écrit :
> Le 14/08/2019 à 13:08, Uwe Kleine-König a écrit :
>> On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
>>> Hi Uwe,
>>>
>>> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
>>> <u.kleine-koenig@pengutronix.de> wrote:
>>>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
>>>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
>>>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
>>>>> member of the gpio array results in an error pointer.
>>>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
>>>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
>>>>> !CONFIG_GPIOLIB case.
>>>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
>>>>> returning an error value.  A simple NULL check is sufficient.
>>>>>
>>>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
>>>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
>>>>>
>>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>>>> ---
>>>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
>>>>>  1 file changed, 4 insertions(+), 8 deletions(-)
>>>>>
>>>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
>>>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
>>>>> --- a/drivers/tty/serial/atmel_serial.c
>>>>> +++ b/drivers/tty/serial/atmel_serial.c
>>>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
>>>>>
>>>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
>>>>>
>>>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
>>>>> -                                             UART_GPIO_CTS))) {
>>>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
>>>>>               if (ret & TIOCM_CTS)
>>>>>                       status &= ~ATMEL_US_CTS;
>>>>>               else
>>>>>                       status |= ATMEL_US_CTS;
>>>>>       }
>>>>
>>>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
>>>> as expected (at least as expected by me). IMHO driving the hardware
>>>> function of the CTS pin shouldn't be conditional on the presence of a
>>>> cts-gpio. Is there a reason not to just drop the if completely?
>>>
>>> The above code returns the hardware status if CTS is not a GPIO, and
>>> returns (overrides with) the GPIO status if CTS is a GPIO.
>>> Isn't that correct, or am I missing something?
>>
>> I took a deeper look into this driver now. The task for
>> atmel_get_lines_status() isn't to implement the get_mctrl() callback.
>>
>> Instead this is called in the irqhandler to set ATMEL_US_RI in a
>> "pending" value that then later in atmel_handle_status() is translated
>> to a "ring" event that is handled there.
>>
>> So the right cleanup would be to let atmel_get_lines_status() just be
>>
>> 	return atmel_uart_readl(port, ATMEL_US_CSR);
>>
>> . If something happend on the lines implemented as gpio the driver's irq
>> function isn't called anyhow.
> 
> I'd like to give it a good test to be sure, and I'll get back to you.

So, Uwe is right.
Since commit ce59e48fdbad ("serial: mctrl_gpio: implement interrupt handling"),
atmel_get_lines_status() can be completly killed and replaced by :
atmel_uart_readl(port, ATMEL_US_CSR);

Geert, do you want to send a patch for that, or should I do it ?


Thanks,
Richard

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/3] serial: atmel: Don't check for mctrl_gpio_to_gpiod() returning error
  2019-08-21 15:27             ` Richard Genoud
@ 2019-08-21 16:04               ` Geert Uytterhoeven
  0 siblings, 0 replies; 17+ messages in thread
From: Geert Uytterhoeven @ 2019-08-21 16:04 UTC (permalink / raw)
  To: Richard Genoud
  Cc: Alexandre Belloni, Pengutronix Kernel Team, Geert Uytterhoeven,
	open list:SERIAL DRIVERS, Greg Kroah-Hartman, Sascha Hauer,
	Uwe Kleine-König, Frieder Schrempf, Linux-Renesas,
	Ludovic Desroches, NXP Linux Team, Fabio Estevam, Jiri Slaby,
	Shawn Guo, Linux ARM

Hi Richard,

On Wed, Aug 21, 2019 at 5:27 PM Richard Genoud <richard.genoud@gmail.com> wrote:
> Le 20/08/2019 à 17:47, Richard Genoud a écrit :
> > Le 14/08/2019 à 13:08, Uwe Kleine-König a écrit :
> >> On Wed, Aug 14, 2019 at 12:20:33PM +0200, Geert Uytterhoeven wrote:
> >>> Hi Uwe,
> >>>
> >>> On Wed, Aug 14, 2019 at 11:36 AM Uwe Kleine-König
> >>> <u.kleine-koenig@pengutronix.de> wrote:
> >>>> On Wed, Aug 14, 2019 at 11:29:22AM +0200, Geert Uytterhoeven wrote:
> >>>>> Since commit 1d267ea6539f2663 ("serial: mctrl-gpio: simplify init
> >>>>> routine"), mctrl_gpio_init() returns failure if the assignment to any
> >>>>> member of the gpio array results in an error pointer.
> >>>>> Since commit c359522194593815 ("serial: mctrl_gpio: Avoid probe failures
> >>>>> in case of missing gpiolib"), mctrl_gpio_to_gpiod() returns NULL in the
> >>>>> !CONFIG_GPIOLIB case.
> >>>>> Hence there is no longer a need to check for mctrl_gpio_to_gpiod()
> >>>>> returning an error value.  A simple NULL check is sufficient.
> >>>>>
> >>>>> This follows the spirit of commit 445df7ff3fd1a0a9 ("serial: mctrl-gpio:
> >>>>> drop usages of IS_ERR_OR_NULL") in the mctrl-gpio core.
> >>>>>
> >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >>>>> ---
> >>>>>  drivers/tty/serial/atmel_serial.c | 12 ++++--------
> >>>>>  1 file changed, 4 insertions(+), 8 deletions(-)
> >>>>>
> >>>>> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> >>>>> index 19a85d6fe3d20541..e9620a81166b7dc1 100644
> >>>>> --- a/drivers/tty/serial/atmel_serial.c
> >>>>> +++ b/drivers/tty/serial/atmel_serial.c
> >>>>> @@ -303,32 +303,28 @@ static unsigned int atmel_get_lines_status(struct uart_port *port)
> >>>>>
> >>>>>       mctrl_gpio_get(atmel_port->gpios, &ret);
> >>>>>
> >>>>> -     if (!IS_ERR_OR_NULL(mctrl_gpio_to_gpiod(atmel_port->gpios,
> >>>>> -                                             UART_GPIO_CTS))) {
> >>>>> +     if (mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) {
> >>>>>               if (ret & TIOCM_CTS)
> >>>>>                       status &= ~ATMEL_US_CTS;
> >>>>>               else
> >>>>>                       status |= ATMEL_US_CTS;
> >>>>>       }
> >>>>
> >>>> The change is fine, but it seems the atmel driver doesn't use mctrl_gpio
> >>>> as expected (at least as expected by me). IMHO driving the hardware
> >>>> function of the CTS pin shouldn't be conditional on the presence of a
> >>>> cts-gpio. Is there a reason not to just drop the if completely?
> >>>
> >>> The above code returns the hardware status if CTS is not a GPIO, and
> >>> returns (overrides with) the GPIO status if CTS is a GPIO.
> >>> Isn't that correct, or am I missing something?
> >>
> >> I took a deeper look into this driver now. The task for
> >> atmel_get_lines_status() isn't to implement the get_mctrl() callback.
> >>
> >> Instead this is called in the irqhandler to set ATMEL_US_RI in a
> >> "pending" value that then later in atmel_handle_status() is translated
> >> to a "ring" event that is handled there.
> >>
> >> So the right cleanup would be to let atmel_get_lines_status() just be
> >>
> >>      return atmel_uart_readl(port, ATMEL_US_CSR);
> >>
> >> . If something happend on the lines implemented as gpio the driver's irq
> >> function isn't called anyhow.
> >
> > I'd like to give it a good test to be sure, and I'll get back to you.
>
> So, Uwe is right.
> Since commit ce59e48fdbad ("serial: mctrl_gpio: implement interrupt handling"),
> atmel_get_lines_status() can be completly killed and replaced by :
> atmel_uart_readl(port, ATMEL_US_CSR);
>
> Geert, do you want to send a patch for that, or should I do it ?

Feel free to send a  patch.
I don't have the Atmel hardware  anyway.
Thanks!

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, back to index

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14  9:27 [PATCH 0/3] serial: Don't check for mctrl_gpio_to_gpiod() returning error Geert Uytterhoeven
2019-08-14  9:27 ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
2019-08-14  9:27 ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
2019-08-14  9:27 ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
2019-08-14  9:29 ` [PATCH 0/3] serial: " Geert Uytterhoeven
2019-08-14  9:29   ` [PATCH 1/3] serial: atmel: " Geert Uytterhoeven
2019-08-14  9:35     ` Uwe Kleine-König
2019-08-14 10:20       ` Geert Uytterhoeven
2019-08-14 11:08         ` Uwe Kleine-König
2019-08-20 15:47           ` Richard Genoud
2019-08-21 15:27             ` Richard Genoud
2019-08-21 16:04               ` Geert Uytterhoeven
2019-08-20 15:11         ` Richard Genoud
2019-08-14  9:29   ` [PATCH 2/3] serial: mxs-auart: " Geert Uytterhoeven
2019-08-19 12:26     ` Simon Horman
2019-08-14  9:29   ` [PATCH 3/3] serial: sh-sci: " Geert Uytterhoeven
2019-08-19  9:51     ` Simon Horman

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox