All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] tty/serial: termbits cleanups
@ 2022-05-13  8:29 Ilpo Järvinen
  2022-05-13  8:29 ` [PATCH v2 1/5] tty: remove CMSPAR ifdefs Ilpo Järvinen
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold; +Cc: Ilpo Järvinen

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

v2:
- Make shortlog simpler
- Note when in the history ifdefs became unnecessary
- Balance braces
- Remove extra parenthesis from the same lines

Ilpo Järvinen (5):
  tty: remove CMSPAR ifdefs
  tty: remove BOTHER ifdefs
  tty: remove IBSHIFT ifdefs
  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                 |  5 ++---
 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          | 35 +++++++----------------------
 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, 16 insertions(+), 73 deletions(-)

-- 
2.30.2


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

* [PATCH v2 1/5] tty: remove CMSPAR ifdefs
  2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
@ 2022-05-13  8:29 ` Ilpo Järvinen
  2022-05-13  8:29   ` Ilpo Järvinen
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold, Arnd Bergmann, Jiri Slaby,
	David S. Miller, Oliver Neukum, linux-kernel, sparclinux,
	linux-usb
  Cc: Ilpo Järvinen

CMSPAR is defined by all architectures since commit 6bf08cb246b5
("[PATCH] Add CMSPAR to termbits.h for powerpc and alpha").

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 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(-)

diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index 78baba55a8b5..c20f2cb784e8 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -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
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 533d02b38e02..afb2d373dd47 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -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);
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 5591f18f2ea9..78b6dedc43e6 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -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;
 }
diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
index 444f233ebd1f..046b624e5f71 100644
--- a/drivers/tty/serial/jsm/jsm_cls.c
+++ b/drivers/tty/serial/jsm/jsm_cls.c
@@ -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;
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index 110696cdaa1d..0cf586c10688 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -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;
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c
index c31389114b86..fff50b5b82eb 100644
--- a/drivers/tty/serial/sunsu.c
+++ b/drivers/tty/serial/sunsu.c
@@ -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
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 3aa7f0a3ad71..d26ecd15be60 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -7,14 +7,6 @@
  *
  */
 
-/*
- * CMSPAR, some architectures can't have space and mark parity.
- */
-
-#ifndef CMSPAR
-#define CMSPAR			0
-#endif
-
 /*
  * Major and minor numbers.
  */
diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c
index c0e4df87ff22..39eaa7b97c40 100644
--- a/drivers/usb/serial/ark3116.c
+++ b/drivers/usb/serial/ark3116.c
@@ -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;
 
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c
index 06aad0d727dd..332fb92ae575 100644
--- a/drivers/usb/serial/whiteheat.c
+++ b/drivers/usb/serial/whiteheat.c
@@ -30,10 +30,6 @@
 #include <linux/usb/ezusb.h>
 #include "whiteheat.h"			/* WhiteHEAT specific commands */
 
-#ifndef CMSPAR
-#define CMSPAR 0
-#endif
-
 /*
  * Version Information
  */
-- 
2.30.2


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

* [PATCH v2 2/5] tty: remove BOTHER ifdefs
  2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
@ 2022-05-13  8:29   ` Ilpo Järvinen
  2022-05-13  8:29   ` Ilpo Järvinen
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold, Jiri Slaby, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-arm-kernel, linux-kernel
  Cc: Ilpo Järvinen

BOTHER is defined by all architectures since commit d0ffb805b729
("arch/alpha, termios: implement BOTHER, IBSHIFT and termios2").

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/mxser.c        |  5 ++---
 drivers/tty/tty_baudrate.c | 20 +++++---------------
 drivers/tty/tty_ioctl.c    |  2 --
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 6ebd3e4ed859..70b982b2c6b2 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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;
@@ -539,9 +538,9 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 			quot /= newspd;
 
 		mxser_set_must_enum_value(info->ioaddr, quot);
-	} else
-#endif
+	} else {
 		mxser_set_must_enum_value(info->ioaddr, 0);
+	}
 
 	return 0;
 }
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index d903e111dbcb..07bbbfee5635 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -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);
 
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 63181925ec1a..adae687f654b 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -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;
-- 
2.30.2


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

* [PATCH v2 2/5] tty: remove BOTHER ifdefs
@ 2022-05-13  8:29   ` Ilpo Järvinen
  0 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold, Jiri Slaby, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team, linux-arm-kernel, linux-kernel
  Cc: Ilpo Järvinen

BOTHER is defined by all architectures since commit d0ffb805b729
("arch/alpha, termios: implement BOTHER, IBSHIFT and termios2").

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/mxser.c        |  5 ++---
 drivers/tty/tty_baudrate.c | 20 +++++---------------
 drivers/tty/tty_ioctl.c    |  2 --
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 6ebd3e4ed859..70b982b2c6b2 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -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;
@@ -539,9 +538,9 @@ static int mxser_set_baud(struct tty_struct *tty, speed_t newspd)
 			quot /= newspd;
 
 		mxser_set_must_enum_value(info->ioaddr, quot);
-	} else
-#endif
+	} else {
 		mxser_set_must_enum_value(info->ioaddr, 0);
+	}
 
 	return 0;
 }
diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index d903e111dbcb..07bbbfee5635 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -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);
 
diff --git a/drivers/tty/tty_ioctl.c b/drivers/tty/tty_ioctl.c
index 63181925ec1a..adae687f654b 100644
--- a/drivers/tty/tty_ioctl.c
+++ b/drivers/tty/tty_ioctl.c
@@ -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;
-- 
2.30.2


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

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

* [PATCH v2 3/5] tty: remove IBSHIFT ifdefs
  2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
  2022-05-13  8:29 ` [PATCH v2 1/5] tty: remove CMSPAR ifdefs Ilpo Järvinen
  2022-05-13  8:29   ` Ilpo Järvinen
@ 2022-05-13  8:29 ` Ilpo Järvinen
  2022-05-13  8:29 ` [PATCH v2 4/5] serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS Ilpo Järvinen
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

IBSHIFT is defined by all architectures since commit d0ffb805b729
("arch/alpha, termios: implement BOTHER, IBSHIFT and termios2").

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/tty_baudrate.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/tty_baudrate.c b/drivers/tty/tty_baudrate.c
index 07bbbfee5635..3cd99ed7c710 100644
--- a/drivers/tty/tty_baudrate.c
+++ b/drivers/tty/tty_baudrate.c
@@ -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
@@ -192,14 +185,12 @@ void tty_termios_encode_baud_rate(struct ktermios *termios,
 			/* For the case input == output don't set IBAUD bits
 			 * if the user didn't do so.
 			 */
-			if (ofound == i && !ibinput)
+			if (ofound == i && !ibinput) {
 				ifound  = i;
-#ifdef IBSHIFT
-			else {
+			} else {
 				ifound = i;
 				termios->c_cflag |= (baud_bits[i] << IBSHIFT);
 			}
-#endif
 		}
 	} while (++i < n_baud_table);
 
-- 
2.30.2


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

* [PATCH v2 4/5] serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS
  2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
                   ` (2 preceding siblings ...)
  2022-05-13  8:29 ` [PATCH v2 3/5] tty: remove IBSHIFT ifdefs Ilpo Järvinen
@ 2022-05-13  8:29 ` Ilpo Järvinen
  2022-05-13  8:29 ` [PATCH v2 5/5] serial: jsm: Use B0 instead of 0 Ilpo Järvinen
  2022-05-13  8:34 ` [PATCH v2 0/5] tty/serial: termbits cleanups Johan Hovold
  5 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold, Jiri Slaby, linux-kernel
  Cc: 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.

Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/fsl_lpuart.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index 75b3c36c13bc..d3bb46cb7185 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -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;
-- 
2.30.2


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

* [PATCH v2 5/5] serial: jsm: Use B0 instead of 0
  2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
                   ` (3 preceding siblings ...)
  2022-05-13  8:29 ` [PATCH v2 4/5] serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS Ilpo Järvinen
@ 2022-05-13  8:29 ` Ilpo Järvinen
  2022-05-13  8:34 ` [PATCH v2 0/5] tty/serial: termbits cleanups Johan Hovold
  5 siblings, 0 replies; 8+ messages in thread
From: Ilpo Järvinen @ 2022-05-13  8:29 UTC (permalink / raw)
  To: linux-serial, Greg KH, Johan Hovold, Jiri Slaby, linux-kernel
  Cc: Ilpo Järvinen

Use B0 to check zero baudrate rather than literal 0.

While at it, remove extra parenthesis around CBAUD.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/jsm/jsm_cls.c | 2 +-
 drivers/tty/serial/jsm/jsm_neo.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/jsm/jsm_cls.c b/drivers/tty/serial/jsm/jsm_cls.c
index 046b624e5f71..3fd57ac3ad81 100644
--- a/drivers/tty/serial/jsm/jsm_cls.c
+++ b/drivers/tty/serial/jsm/jsm_cls.c
@@ -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;
diff --git a/drivers/tty/serial/jsm/jsm_neo.c b/drivers/tty/serial/jsm/jsm_neo.c
index 0cf586c10688..0c78f66276cd 100644
--- a/drivers/tty/serial/jsm/jsm_neo.c
+++ b/drivers/tty/serial/jsm/jsm_neo.c
@@ -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;
 
-- 
2.30.2


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

* Re: [PATCH v2 0/5] tty/serial: termbits cleanups
  2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
                   ` (4 preceding siblings ...)
  2022-05-13  8:29 ` [PATCH v2 5/5] serial: jsm: Use B0 instead of 0 Ilpo Järvinen
@ 2022-05-13  8:34 ` Johan Hovold
  5 siblings, 0 replies; 8+ messages in thread
From: Johan Hovold @ 2022-05-13  8:34 UTC (permalink / raw)
  To: Ilpo Järvinen; +Cc: linux-serial, Greg KH

On Fri, May 13, 2022 at 11:29:01AM +0300, Ilpo Järvinen wrote:
> A few simple cleanups that I've come across while playing with the
> termbits.
> 
> v2:
> - Make shortlog simpler
> - Note when in the history ifdefs became unnecessary
> - Balance braces
> - Remove extra parenthesis from the same lines

Thanks for the update.
 
> Ilpo Järvinen (5):
>   tty: remove CMSPAR ifdefs
>   tty: remove BOTHER ifdefs
>   tty: remove IBSHIFT ifdefs
>   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                 |  5 ++---
>  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          | 35 +++++++----------------------
>  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, 16 insertions(+), 73 deletions(-)

For the series:

Reviewed-by: Johan Hovold <johan@kernel.org>

Johan

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

end of thread, other threads:[~2022-05-13  8:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-13  8:29 [PATCH v2 0/5] tty/serial: termbits cleanups Ilpo Järvinen
2022-05-13  8:29 ` [PATCH v2 1/5] tty: remove CMSPAR ifdefs Ilpo Järvinen
2022-05-13  8:29 ` [PATCH v2 2/5] tty: remove BOTHER ifdefs Ilpo Järvinen
2022-05-13  8:29   ` Ilpo Järvinen
2022-05-13  8:29 ` [PATCH v2 3/5] tty: remove IBSHIFT ifdefs Ilpo Järvinen
2022-05-13  8:29 ` [PATCH v2 4/5] serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS Ilpo Järvinen
2022-05-13  8:29 ` [PATCH v2 5/5] serial: jsm: Use B0 instead of 0 Ilpo Järvinen
2022-05-13  8:34 ` [PATCH v2 0/5] tty/serial: termbits cleanups Johan Hovold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.