linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] serial: max310x: Properly set flags in AutoCTS mode
@ 2019-08-30  9:58 Christoph Vogtländer
  2019-09-04  7:30 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Vogtländer @ 2019-08-30  9:58 UTC (permalink / raw)
  Cc: Greg Kroah-Hartman, Jiri Slaby, linux-serial, linux-kernel,
	Christoph Vogtländer

Commit 391f93f2ec9f ("serial: core: Rework hw-assisted flow control
support") has changed the way the AutoCTS mode is handled.

According to that change, serial drivers which enable H/W AutoCTS mode must
set UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF to prevent the
serial core from inadvertently disabling RX or TX. This patch adds proper
handling of UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF flags.

Signed-off-by: Christoph Vogtländer <c.vogtlaender@sigma-surface-science.com>
---
 drivers/tty/serial/max310x.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 0e24235..fb5a7e0 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -859,15 +859,23 @@ static void max310x_set_termios(struct uart_port *port,
 /* Configure flow control */
 max310x_port_write(port, MAX310X_XON1_REG, termios->c_cc[VSTART]);
 max310x_port_write(port, MAX310X_XOFF1_REG, termios->c_cc[VSTOP]);
-if (termios->c_cflag & CRTSCTS)
+
+port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF);
+
+if (termios->c_cflag & CRTSCTS) {
+/* Enable AUTORTS and AUTOCTS */
+port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS;
 flow |= MAX310X_FLOWCTRL_AUTOCTS_BIT |
 MAX310X_FLOWCTRL_AUTORTS_BIT;
+}
 if (termios->c_iflag & IXON)
 flow |= MAX310X_FLOWCTRL_SWFLOW3_BIT |
 MAX310X_FLOWCTRL_SWFLOWEN_BIT;
-if (termios->c_iflag & IXOFF)
+if (termios->c_iflag & IXOFF) {
+port->status |= UPSTAT_AUTOXOFF;
 flow |= MAX310X_FLOWCTRL_SWFLOW1_BIT |
 MAX310X_FLOWCTRL_SWFLOWEN_BIT;
+}
 max310x_port_write(port, MAX310X_FLOWCTRL_REG, flow);

 /* Get baud rate generator configuration */
--
2.7.4


Sigma Surface Science GmbH, Idsteiner Str. 78, 65232 Taunusstein. Amtsgericht Wiesbaden, HRB 27422. Geschäftsführer: Norbert Nold

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

* Re: [PATCH] serial: max310x: Properly set flags in AutoCTS mode
  2019-08-30  9:58 [PATCH] serial: max310x: Properly set flags in AutoCTS mode Christoph Vogtländer
@ 2019-09-04  7:30 ` Greg Kroah-Hartman
  2019-09-04 12:11   ` Christoph Vogtländer
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2019-09-04  7:30 UTC (permalink / raw)
  To: Christoph Vogtländer; +Cc: Jiri Slaby, linux-serial, linux-kernel

On Fri, Aug 30, 2019 at 09:58:34AM +0000, Christoph Vogtländer wrote:
> Commit 391f93f2ec9f ("serial: core: Rework hw-assisted flow control
> support") has changed the way the AutoCTS mode is handled.
> 
> According to that change, serial drivers which enable H/W AutoCTS mode must
> set UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF to prevent the
> serial core from inadvertently disabling RX or TX. This patch adds proper
> handling of UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF flags.
> 
> Signed-off-by: Christoph Vogtländer <c.vogtlaender@sigma-surface-science.com>
> ---
>  drivers/tty/serial/max310x.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
> index 0e24235..fb5a7e0 100644
> --- a/drivers/tty/serial/max310x.c
> +++ b/drivers/tty/serial/max310x.c
> @@ -859,15 +859,23 @@ static void max310x_set_termios(struct uart_port *port,
>  /* Configure flow control */
>  max310x_port_write(port, MAX310X_XON1_REG, termios->c_cc[VSTART]);
>  max310x_port_write(port, MAX310X_XOFF1_REG, termios->c_cc[VSTOP]);
> -if (termios->c_cflag & CRTSCTS)
> +
> +port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF);
> +
> +if (termios->c_cflag & CRTSCTS) {
> +/* Enable AUTORTS and AUTOCTS */
> +port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS;
>  flow |= MAX310X_FLOWCTRL_AUTOCTS_BIT |
>  MAX310X_FLOWCTRL_AUTORTS_BIT;
> +}
>  if (termios->c_iflag & IXON)
>  flow |= MAX310X_FLOWCTRL_SWFLOW3_BIT |
>  MAX310X_FLOWCTRL_SWFLOWEN_BIT;
> -if (termios->c_iflag & IXOFF)
> +if (termios->c_iflag & IXOFF) {
> +port->status |= UPSTAT_AUTOXOFF;
>  flow |= MAX310X_FLOWCTRL_SWFLOW1_BIT |
>  MAX310X_FLOWCTRL_SWFLOWEN_BIT;
> +}
>  max310x_port_write(port, MAX310X_FLOWCTRL_REG, flow);
> 
>  /* Get baud rate generator configuration */
> --
> 2.7.4

Your email client ate all of the leading spaces and tabs and spit out a
patch that is impossible to apply :(

Please fix that up and resend.

thanks,

greg k-h

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

* [PATCH] serial: max310x: Properly set flags in AutoCTS mode
  2019-09-04  7:30 ` Greg Kroah-Hartman
@ 2019-09-04 12:11   ` Christoph Vogtländer
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Vogtländer @ 2019-09-04 12:11 UTC (permalink / raw)
  Cc: c.vogtlaender, Greg Kroah-Hartman, Jiri Slaby, linux-serial,
	linux-kernel

Commit 391f93f2ec9f ("serial: core: Rework hw-assisted flow control
support") has changed the way the AutoCTS mode is handled.

According to that change, serial drivers which enable H/W AutoCTS mode must
set UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF to prevent the
serial core from inadvertently disabling RX or TX. This patch adds proper
handling of UPSTAT_AUTORTS, UPSTAT_AUTOCTS and UPSTAT_AUTOXOFF flags.

Signed-off-by: Christoph Vogtländer <c.vogtlaender@sigma-surface-science.com>
---
 drivers/tty/serial/max310x.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index 0e24235..fb5a7e0 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -859,15 +859,23 @@ static void max310x_set_termios(struct uart_port *port,
 	/* Configure flow control */
 	max310x_port_write(port, MAX310X_XON1_REG, termios->c_cc[VSTART]);
 	max310x_port_write(port, MAX310X_XOFF1_REG, termios->c_cc[VSTOP]);
-	if (termios->c_cflag & CRTSCTS)
+
+	port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS | UPSTAT_AUTOXOFF);
+
+	if (termios->c_cflag & CRTSCTS) {
+		/* Enable AUTORTS and AUTOCTS */
+		port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS;
 		flow |= MAX310X_FLOWCTRL_AUTOCTS_BIT |
 			MAX310X_FLOWCTRL_AUTORTS_BIT;
+	}
 	if (termios->c_iflag & IXON)
 		flow |= MAX310X_FLOWCTRL_SWFLOW3_BIT |
 			MAX310X_FLOWCTRL_SWFLOWEN_BIT;
-	if (termios->c_iflag & IXOFF)
+	if (termios->c_iflag & IXOFF) {
+		port->status |= UPSTAT_AUTOXOFF;
 		flow |= MAX310X_FLOWCTRL_SWFLOW1_BIT |
 			MAX310X_FLOWCTRL_SWFLOWEN_BIT;
+	}
 	max310x_port_write(port, MAX310X_FLOWCTRL_REG, flow);
 
 	/* Get baud rate generator configuration */
-- 
2.7.4


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

end of thread, other threads:[~2019-09-04 12:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30  9:58 [PATCH] serial: max310x: Properly set flags in AutoCTS mode Christoph Vogtländer
2019-09-04  7:30 ` Greg Kroah-Hartman
2019-09-04 12:11   ` Christoph Vogtländer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).