Skip to contentSkip to conversation

tty/serial termbits cleanups

PATCH Superseded Ilpo Järvinen 2 participants 11 messages May 11, 2022 – May 13, 2022

Subsystems (9)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tty/serial termbits cleanups

A few simple cleanups that I've come across while playing with the termbits.

Ilpo Järvinen (5):
tty/termbits: remove #ifdef CMSPAR that is always defined tty/termbits: remove #ifdef BOTHER that is always defined tty/termbits: remove #ifdef IBSHIFT that is always defined
serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS
serial: jsm: Use B0 instead of 0

 drivers/char/pcmcia/synclink_cs.c   |  2 --
 drivers/tty/amiserial.c             |  2 --
 drivers/tty/mxser.c                 |  2 --
 drivers/tty/serial/8250/8250_port.c |  2 --
 drivers/tty/serial/fsl_lpuart.c     |  8 +++-----
 drivers/tty/serial/jsm/jsm_cls.c    |  8 +-------
 drivers/tty/serial/jsm/jsm_neo.c    |  8 +-------
 drivers/tty/serial/sunsu.c          |  2 --
 drivers/tty/tty_baudrate.c          | 31 ++++++-----------------------
 drivers/tty/tty_ioctl.c             |  2 --
 drivers/usb/class/cdc-acm.h         |  8 --------
 drivers/usb/serial/ark3116.c        |  3 +--
 drivers/usb/serial/whiteheat.c      |  4 ----
 13 files changed, 12 insertions(+), 70 deletions(-)
Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/5 tty/termbits: remove #ifdef CMSPAR that is always defined

CMSPAR is defined by all architectures.

---
 drivers/char/pcmcia/synclink_cs.c   | 2 --
 drivers/tty/amiserial.c             | 2 --
 drivers/tty/serial/8250/8250_port.c | 2 --
 drivers/tty/serial/jsm/jsm_cls.c    | 6 ------
 drivers/tty/serial/jsm/jsm_neo.c    | 6 ------
 drivers/tty/serial/sunsu.c          | 2 --
 drivers/usb/class/cdc-acm.h         | 8 --------
 drivers/usb/serial/ark3116.c        | 3 +--
 drivers/usb/serial/whiteheat.c      | 4 ----
 9 files changed, 1 insertion(+), 34 deletions(-)
drivers/char/pcmcia/synclink_cs.c +0 -2
index 78baba55a8b5..c20f2cb784e8 100644
@@ -1432,10 +1432,8 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty)
 			info->params.parity = ASYNC_PARITY_ODD;
 		else
 			info->params.parity = ASYNC_PARITY_EVEN;
-#ifdef CMSPAR
 		if (cflag & CMSPAR)
 			info->params.parity = ASYNC_PARITY_SPACE;
-#endif
 	}
 
 	/* calculate number of jiffies to transmit a full
drivers/tty/amiserial.c +0 -2
index 533d02b38e02..afb2d373dd47 100644
@@ -588,10 +588,8 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
 	}
 	if (!(cflag & PARODD))
 		cval |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
-#endif
 
 	/* Determine divisor based on baud rate */
 	baud = tty_get_baud_rate(tty);
drivers/tty/serial/8250/8250_port.c +0 -2
index 5591f18f2ea9..78b6dedc43e6 100644
@@ -2620,10 +2620,8 @@ static unsigned char serial8250_compute_lcr(struct uart_8250_port *up,
 	}
 	if (!(c_cflag & PARODD))
 		cval |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (c_cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
-#endif
 
 	return cval;
 }
drivers/tty/serial/jsm/jsm_cls.c +0 -6
index 444f233ebd1f..046b624e5f71 100644
@@ -723,14 +723,8 @@ static void cls_param(struct jsm_channel *ch)
 	if (!(ch->ch_c_cflag & PARODD))
 		lcr |= UART_LCR_EPAR;
 
-	/*
-	 * Not all platforms support mark/space parity,
-	 * so this will hide behind an ifdef.
-	 */
-#ifdef CMSPAR
 	if (ch->ch_c_cflag & CMSPAR)
 		lcr |= UART_LCR_SPAR;
-#endif
 
 	if (ch->ch_c_cflag & CSTOPB)
 		lcr |= UART_LCR_STOP;
drivers/tty/serial/jsm/jsm_neo.c +0 -6
index 110696cdaa1d..0cf586c10688 100644
@@ -997,14 +997,8 @@ static void neo_param(struct jsm_channel *ch)
 	if (!(ch->ch_c_cflag & PARODD))
 		lcr |= UART_LCR_EPAR;
 
-	/*
-	 * Not all platforms support mark/space parity,
-	 * so this will hide behind an ifdef.
-	 */
-#ifdef CMSPAR
 	if (ch->ch_c_cflag & CMSPAR)
 		lcr |= UART_LCR_SPAR;
-#endif
 
 	if (ch->ch_c_cflag & CSTOPB)
 		lcr |= UART_LCR_STOP;
drivers/tty/serial/sunsu.c +0 -2
index c31389114b86..fff50b5b82eb 100644
@@ -798,10 +798,8 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag,
 		cval |= UART_LCR_PARITY;
 	if (!(cflag & PARODD))
 		cval |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
-#endif
 
 	/*
 	 * Work around a bug in the Oxford Semiconductor 952 rev B
drivers/usb/class/cdc-acm.h +0 -8
index 3aa7f0a3ad71..d26ecd15be60 100644
@@ -7,14 +7,6 @@
  *
  */
 
-/*
- * CMSPAR, some architectures can't have space and mark parity.
- */
-
-#ifndef CMSPAR
-#define CMSPAR			0
-#endif
-
 /*
  * Major and minor numbers.
  */
drivers/usb/serial/ark3116.c +1 -2
index c0e4df87ff22..39eaa7b97c40 100644
@@ -208,10 +208,9 @@ static void ark3116_set_termios(struct tty_struct *tty,
 		lcr |= UART_LCR_PARITY;
 	if (!(cflag & PARODD))
 		lcr |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (cflag & CMSPAR)
 		lcr |= UART_LCR_SPAR;
-#endif
+
 	/* handshake control */
 	hcr = (cflag & CRTSCTS) ? 0x03 : 0x00;
 
drivers/usb/serial/whiteheat.c +0 -4
index 06aad0d727dd..332fb92ae575 100644
@@ -30,10 +30,6 @@
 #include <linux/usb/ezusb.h>
 #include "whiteheat.h"			/* WhiteHEAT specific commands */
 
-#ifndef CMSPAR
-#define CMSPAR 0
-#endif
-
 /*
  * Version Information
  */
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] tty/termbits: remove #ifdef CMSPAR that is always defined

Quoted 1 line · Ilpo Järvinen

CMSPAR is defined by all architectures.

For the sake of reviewers please say something about when this changed.

Also no need to be so verbose in your Subjects

tty: remove CMSPAR ifdefs

works just fine and is more in line with the prefix typically used for this subsystem.

Quoted 12 lines
---
 drivers/char/pcmcia/synclink_cs.c   | 2 --
 drivers/tty/amiserial.c             | 2 --
 drivers/tty/serial/8250/8250_port.c | 2 --
 drivers/tty/serial/jsm/jsm_cls.c    | 6 ------
 drivers/tty/serial/jsm/jsm_neo.c    | 6 ------
 drivers/tty/serial/sunsu.c          | 2 --
 drivers/usb/class/cdc-acm.h         | 8 --------
 drivers/usb/serial/ark3116.c        | 3 +--
 drivers/usb/serial/whiteheat.c      | 4 ----
 9 files changed, 1 insertion(+), 34 deletions(-)

The change itself looks good otherwise.

Quoted 138 lines
drivers/char/pcmcia/synclink_cs.c +0 -2
index 78baba55a8b5..c20f2cb784e8 100644
@@ -1432,10 +1432,8 @@ static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty)
 			info->params.parity = ASYNC_PARITY_ODD;
 		else
 			info->params.parity = ASYNC_PARITY_EVEN;
-#ifdef CMSPAR
 		if (cflag & CMSPAR)
 			info->params.parity = ASYNC_PARITY_SPACE;
-#endif
 	}
 
 	/* calculate number of jiffies to transmit a full
drivers/tty/amiserial.c +0 -2
index 533d02b38e02..afb2d373dd47 100644
@@ -588,10 +588,8 @@ static void change_speed(struct tty_struct *tty, struct serial_state *info,
 	}
 	if (!(cflag & PARODD))
 		cval |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
-#endif
 
 	/* Determine divisor based on baud rate */
 	baud = tty_get_baud_rate(tty);
drivers/tty/serial/8250/8250_port.c +0 -2
index 5591f18f2ea9..78b6dedc43e6 100644
@@ -2620,10 +2620,8 @@ static unsigned char serial8250_compute_lcr(struct uart_8250_port *up,
 	}
 	if (!(c_cflag & PARODD))
 		cval |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (c_cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
-#endif
 
 	return cval;
 }
drivers/tty/serial/jsm/jsm_cls.c +0 -6
index 444f233ebd1f..046b624e5f71 100644
@@ -723,14 +723,8 @@ static void cls_param(struct jsm_channel *ch)
 	if (!(ch->ch_c_cflag & PARODD))
 		lcr |= UART_LCR_EPAR;
 
-	/*
-	 * Not all platforms support mark/space parity,
-	 * so this will hide behind an ifdef.
-	 */
-#ifdef CMSPAR
 	if (ch->ch_c_cflag & CMSPAR)
 		lcr |= UART_LCR_SPAR;
-#endif
 
 	if (ch->ch_c_cflag & CSTOPB)
 		lcr |= UART_LCR_STOP;
drivers/tty/serial/jsm/jsm_neo.c +0 -6
index 110696cdaa1d..0cf586c10688 100644
@@ -997,14 +997,8 @@ static void neo_param(struct jsm_channel *ch)
 	if (!(ch->ch_c_cflag & PARODD))
 		lcr |= UART_LCR_EPAR;
 
-	/*
-	 * Not all platforms support mark/space parity,
-	 * so this will hide behind an ifdef.
-	 */
-#ifdef CMSPAR
 	if (ch->ch_c_cflag & CMSPAR)
 		lcr |= UART_LCR_SPAR;
-#endif
 
 	if (ch->ch_c_cflag & CSTOPB)
 		lcr |= UART_LCR_STOP;
drivers/tty/serial/sunsu.c +0 -2
index c31389114b86..fff50b5b82eb 100644
@@ -798,10 +798,8 @@ sunsu_change_speed(struct uart_port *port, unsigned int cflag,
 		cval |= UART_LCR_PARITY;
 	if (!(cflag & PARODD))
 		cval |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (cflag & CMSPAR)
 		cval |= UART_LCR_SPAR;
-#endif
 
 	/*
 	 * Work around a bug in the Oxford Semiconductor 952 rev B
drivers/usb/class/cdc-acm.h +0 -8
index 3aa7f0a3ad71..d26ecd15be60 100644
@@ -7,14 +7,6 @@
  *
  */
 
-/*
- * CMSPAR, some architectures can't have space and mark parity.
- */
-
-#ifndef CMSPAR
-#define CMSPAR			0
-#endif
-
 /*
  * Major and minor numbers.
  */
drivers/usb/serial/ark3116.c +1 -2
index c0e4df87ff22..39eaa7b97c40 100644
@@ -208,10 +208,9 @@ static void ark3116_set_termios(struct tty_struct *tty,
 		lcr |= UART_LCR_PARITY;
 	if (!(cflag & PARODD))
 		lcr |= UART_LCR_EPAR;
-#ifdef CMSPAR
 	if (cflag & CMSPAR)
 		lcr |= UART_LCR_SPAR;
-#endif
+
 	/* handshake control */
 	hcr = (cflag & CRTSCTS) ? 0x03 : 0x00;
 
drivers/usb/serial/whiteheat.c +0 -0
index 06aad0d727dd..332fb92ae575 100644

drivers/usb/serial/whiteheat.c line 35

Quoted 10 lines
drivers/usb/serial/whiteheat.c +0 -4
@@ -30,10 +30,6 @@
 #include <linux/usb/ezusb.h>
 #include "whiteheat.h"			/* WhiteHEAT specific commands */
 
-#ifndef CMSPAR
-#define CMSPAR 0
-#endif
-
 /*
  * Version Information
  */

Johan

#3 lore raw

PATCH 2/5 tty/termbits: remove #ifdef BOTHER that is always defined

In reply to Ilpo Järvinen

BOTHER is defined by all architectures.

---
 drivers/tty/mxser.c        |  2 --
 drivers/tty/tty_baudrate.c | 20 +++++---------------
 drivers/tty/tty_ioctl.c    |  2 --
 3 files changed, 5 insertions(+), 19 deletions(-)
drivers/tty/mxser.c +0 -2
index 6ebd3e4ed859..9ea7bd059d0f 100644
@@ -528,7 +528,6 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 	outb(quot >> 8, info->ioaddr + UART_DLM);	/* MS of divisor */
 	outb(cval, info->ioaddr + UART_LCR);	/* reset DLAB */
 
-#ifdef BOTHER
 	if (C_BAUD(tty) == BOTHER) {
 		quot = MXSER_BAUD_BASE % newspd;
 		quot *= 8;
@@ -540,7 +539,6 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 
 		mxser_set_must_enum_value(info->ioaddr, quot);
 	} else
-#endif
 		mxser_set_must_enum_value(info->ioaddr, 0);
 
 	return 0;
drivers/tty/tty_baudrate.c +5 -15
index d903e111dbcb..07bbbfee5635 100644
@@ -61,11 +61,10 @@ speed_t tty_termios_baud_rate(struct ktermios *termios)
 
 	cbaud = termios->c_cflag & CBAUD;
 
-#ifdef BOTHER
 	/* Magic token for arbitrary speed via c_ispeed/c_ospeed */
 	if (cbaud == BOTHER)
 		return termios->c_ospeed;
-#endif
+
 	if (cbaud & CBAUDEX) {
 		cbaud &= ~CBAUDEX;
 
@@ -97,11 +96,11 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
 
 	if (cbaud == B0)
 		return tty_termios_baud_rate(termios);
-#ifdef BOTHER
+
 	/* Magic token for arbitrary speed via c_ispeed*/
 	if (cbaud == BOTHER)
 		return termios->c_ispeed;
-#endif
+
 	if (cbaud & CBAUDEX) {
 		cbaud &= ~CBAUDEX;
 
@@ -157,7 +156,6 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 	if (((termios->c_cflag >> IBSHIFT) & CBAUD) != B0)
 		ibinput = 1;	/* An input speed was specified */
 #endif
-#ifdef BOTHER
 	/* If the user asked for a precise weird speed give a precise weird
 	 * answer. If they asked for a Bfoo speed they may have problems
 	 * digesting non-exact replies so fuzz a bit.
@@ -170,7 +168,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 	}
 	if (((termios->c_cflag >> IBSHIFT) & CBAUD) == BOTHER)
 		iclose = 0;
-#endif
+
 	termios->c_cflag &= ~CBAUD;
 #ifdef IBSHIFT
 	termios->c_cflag &= ~(CBAUD << IBSHIFT);
@@ -205,11 +203,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 		}
 	} while (++i < n_baud_table);
 
-	/*
-	 *	If we found no match then use BOTHER if provided or warn
-	 *	the user their platform maintainer needs to wake up if not.
-	 */
-#ifdef BOTHER
+	/* If we found no match then use BOTHER. */
 	if (ofound == -1)
 		termios->c_cflag |= BOTHER;
 	/* Set exact input bits only if the input and output differ or the
@@ -217,10 +211,6 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 	 */
 	if (ifound == -1 && (ibaud != obaud || ibinput))
 		termios->c_cflag |= (BOTHER << IBSHIFT);
-#else
-	if (ifound == -1 || ofound == -1)
-		pr_warn_once("tty: Unable to return correct speed data as your architecture needs updating.\n");
-#endif
 }
 EXPORT_SYMBOL_GPL(tty_termios_encode_baud_rate);
 
drivers/tty/tty_ioctl.c +0 -2
index 63181925ec1a..adae687f654b 100644
@@ -562,10 +562,8 @@ static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb)
 	termios.c_cc[VKILL] = tmp.sg_kill;
 	set_sgflags(&termios, tmp.sg_flags);
 	/* Try and encode into Bfoo format */
-#ifdef BOTHER
 	tty_termios_encode_baud_rate(&termios, termios.c_ispeed,
 						termios.c_ospeed);
-#endif
 	up_write(&tty->termios_rwsem);
 	tty_set_termios(tty, &termios);
 	return 0;
Signature · 1 line
2.30.2
maintainer
#4 lore raw

Re: [PATCH 2/5] tty/termbits: remove #ifdef BOTHER that is always defined

Quoted 1 line · Ilpo Järvinen

BOTHER is defined by all architectures.

This changed quite recently so please mention the commit in question.

No need for the verbose Subject here either.

Quoted 20 lines
---
 drivers/tty/mxser.c        |  2 --
 drivers/tty/tty_baudrate.c | 20 +++++---------------
 drivers/tty/tty_ioctl.c    |  2 --
 3 files changed, 5 insertions(+), 19 deletions(-)
drivers/tty/mxser.c +0 -1
index 6ebd3e4ed859..9ea7bd059d0f 100644
@@ -528,7 +528,6 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 	outb(quot >> 8, info->ioaddr + UART_DLM);	/* MS of divisor */
 	outb(cval, info->ioaddr + UART_LCR);	/* reset DLAB */
 
-#ifdef BOTHER
 	if (C_BAUD(tty) == BOTHER) {
 		quot = MXSER_BAUD_BASE % newspd;
 		quot *= 8;

drivers/tty/mxser.c static int mxser_set_baud(struct tty_struct *tty, speed_t newspd) · line 542

Quoted 5 lines
drivers/tty/mxser.c +0 -1
@@ -540,7 +539,6 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 
 		mxser_set_must_enum_value(info->ioaddr, quot);
 	} else
-#endif
 		mxser_set_must_enum_value(info->ioaddr, 0);

When removing the ifdef, please add the missing bracket to the else branch as per the coding standard.

Johan

#5 lore raw

PATCH 3/5 tty/termbits: remove #ifdef IBSHIFT that is always defined

In reply to Ilpo Järvinen

IBSHIFT is defined by all architectures.

---
 drivers/tty/tty_baudrate.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/tty/tty_baudrate.c +1 -10
index 07bbbfee5635..d10318956c97 100644
@@ -91,7 +91,6 @@ EXPORT_SYMBOL(tty_termios_baud_rate);
 
 speed_t tty_termios_input_baud_rate(struct ktermios *termios)
 {
-#ifdef IBSHIFT
 	unsigned int cbaud = (termios->c_cflag >> IBSHIFT) & CBAUD;
 
 	if (cbaud == B0)
@@ -110,9 +109,6 @@ speed_t tty_termios_input_baud_rate(struct ktermios *termios)
 			cbaud += 15;
 	}
 	return cbaud >= n_baud_table ? 0 : baud_table[cbaud];
-#else	/* IBSHIFT */
-	return tty_termios_baud_rate(termios);
-#endif	/* IBSHIFT */
 }
 EXPORT_SYMBOL(tty_termios_input_baud_rate);
 
@@ -152,10 +148,9 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 	termios->c_ispeed = ibaud;
 	termios->c_ospeed = obaud;
 
-#ifdef IBSHIFT
 	if (((termios->c_cflag >> IBSHIFT) & CBAUD) != B0)
 		ibinput = 1;	/* An input speed was specified */
-#endif
+
 	/* If the user asked for a precise weird speed give a precise weird
 	 * answer. If they asked for a Bfoo speed they may have problems
 	 * digesting non-exact replies so fuzz a bit.
@@ -170,9 +165,7 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 		iclose = 0;
 
 	termios->c_cflag &= ~CBAUD;
-#ifdef IBSHIFT
 	termios->c_cflag &= ~(CBAUD << IBSHIFT);
-#endif
 
 	/*
 	 *	Our goal is to find a close match to the standard baud rate
@@ -194,12 +187,10 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 			 */
 			if (ofound == i && !ibinput)
 				ifound  = i;
-#ifdef IBSHIFT
 			else {
 				ifound = i;
 				termios->c_cflag |= (baud_bits[i] << IBSHIFT);
 			}
-#endif
 		}
 	} while (++i < n_baud_table);
 
Signature · 1 line
2.30.2
maintainer
#6 lore raw

Re: [PATCH 3/5] tty/termbits: remove #ifdef IBSHIFT that is always defined

Quoted 1 line · Ilpo Järvinen

IBSHIFT is defined by all architectures.

This also changed recently so mention the commit in question.

Subject is overly verbose here too.

Quoted 11 lines
---
 drivers/tty/tty_baudrate.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/tty/tty_baudrate.c +0 -0
index 07bbbfee5635..d10318956c97 100644

drivers/tty/tty_baudrate.c void tty_termios_encode_baud_rate(struct ktermios *termios, · line 202

Quoted 9 lines
drivers/tty/tty_baudrate.c +0 -2
@@ -194,12 +187,10 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 			 */
 			if (ofound == i && !ibinput)
 				ifound  = i;
-#ifdef IBSHIFT
 			else {
 				ifound = i;
 				termios->c_cflag |= (baud_bits[i] << IBSHIFT);
 			}
-#endif

Please add the missing brackets to the if branch when removing the ifdef.

Johan

#7 lore raw

PATCH 4/5 serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS

In reply to Ilpo Järvinen

if (termios->c_cflag & CRTSCTS) guarantees that CRTSCTS is not ever set in the else block so clearing it is unnecessary.

While at it, remove also one pair of extra parenthesis.

---
 drivers/tty/serial/fsl_lpuart.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/tty/serial/fsl_lpuart.c +3 -5
index 75b3c36c13bc..d3bb46cb7185 100644
@@ -2110,12 +2110,10 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (sport->port.rs485.flags & SER_RS485_ENABLED)
 		termios->c_cflag &= ~CRTSCTS;
 
-	if (termios->c_cflag & CRTSCTS) {
-		modem |= (UARTMODIR_RXRTSE | UARTMODIR_TXCTSE);
-	} else {
-		termios->c_cflag &= ~CRTSCTS;
+	if (termios->c_cflag & CRTSCTS)
+		modem |= UARTMODIR_RXRTSE | UARTMODIR_TXCTSE;
+	else
 		modem &= ~(UARTMODIR_RXRTSE | UARTMODIR_TXCTSE);
-	}
 
 	if (termios->c_cflag & CSTOPB)
 		bd |= UARTBAUD_SBNS;
Signature · 1 line
2.30.2
maintainer Reviewed-by on v1 4/5
#8 lore raw

Re: [PATCH 4/5] serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS

Quoted 6 lines · Ilpo Järvinen

if (termios->c_cflag & CRTSCTS) guarantees that CRTSCTS is not ever set in the else block so clearing it is unnecessary.

While at it, remove also one pair of extra parenthesis.

#9 lore raw

PATCH 5/5 serial: jsm: Use B0 instead of 0

In reply to Ilpo Järvinen

Use B0 to check zero baudrate rather than literal 0.

---
 drivers/tty/serial/jsm/jsm_cls.c | 2 +-
 drivers/tty/serial/jsm/jsm_neo.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/jsm/jsm_cls.c +1 -1
index 046b624e5f71..ca05e84a7c90 100644
@@ -689,7 +689,7 @@ static void cls_param(struct jsm_channel *ch)
 	/*
 	 * If baud rate is zero, flush queues, and set mval to drop DTR.
 	 */
-	if ((ch->ch_c_cflag & (CBAUD)) == 0) {
+	if ((ch->ch_c_cflag & (CBAUD)) == B0) {
 		ch->ch_r_head = 0;
 		ch->ch_r_tail = 0;
 		ch->ch_e_head = 0;
drivers/tty/serial/jsm/jsm_neo.c +1 -1
index 0cf586c10688..95bebf2a73d3 100644
@@ -938,7 +938,7 @@ static void neo_param(struct jsm_channel *ch)
 	/*
 	 * If baud rate is zero, flush queues, and set mval to drop DTR.
 	 */
-	if ((ch->ch_c_cflag & (CBAUD)) == 0) {
+	if ((ch->ch_c_cflag & (CBAUD)) == B0) {
 		ch->ch_r_head = ch->ch_r_tail = 0;
 		ch->ch_e_head = ch->ch_e_tail = 0;
 
Signature · 1 line
2.30.2
maintainer
#10 lore raw

Re: [PATCH 5/5] serial: jsm: Use B0 instead of 0

Quoted 13 lines · Ilpo Järvinen

Use B0 to check zero baudrate rather than literal 0.

---
 drivers/tty/serial/jsm/jsm_cls.c | 2 +-
 drivers/tty/serial/jsm/jsm_neo.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/tty/serial/jsm/jsm_cls.c +0 -0
index 046b624e5f71..ca05e84a7c90 100644

drivers/tty/serial/jsm/jsm_cls.c static void cls_param(struct jsm_channel *ch) · line 692

Quoted 5 lines
drivers/tty/serial/jsm/jsm_cls.c +1 -1
@@ -689,7 +689,7 @@ static void cls_param(struct jsm_channel *ch)
 	/*
 	 * If baud rate is zero, flush queues, and set mval to drop DTR.
 	 */
-	if ((ch->ch_c_cflag & (CBAUD)) == 0) {
+	if ((ch->ch_c_cflag & (CBAUD)) == B0) {

Sure, why not. How about dropping the unnecessary parenthesis around CBAUD while at it?

Johan