tty/serial: termbits cleanups
Subsystems (9)
v2 cover tty/serial: termbits cleanups
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(-)
Signature · 1 line
2.30.2
PATCH v2 1/5 tty: remove CMSPAR ifdefs
CMSPAR is defined by all architectures since commit 6bf08cb246b5 ("[PATCH] Add CMSPAR to termbits.h for powerpc and alpha").
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 2/5 tty: remove BOTHER ifdefs
In reply to Ilpo JärvinenBOTHER is defined by all architectures since commit d0ffb805b729 ("arch/alpha, termios: implement BOTHER, IBSHIFT and termios2").
--- drivers/tty/mxser.c | 5 ++--- drivers/tty/tty_baudrate.c | 20 +++++--------------- drivers/tty/tty_ioctl.c | 2 -- 3 files changed, 7 insertions(+), 20 deletions(-)
drivers/tty/mxser.c +2 -3
@@ -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 ; }
drivers/tty/tty_baudrate.c +5 -15
@@ -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
@@ -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
PATCH v2 3/5 tty: remove IBSHIFT ifdefs
In reply to Ilpo JärvinenIBSHIFT is defined by all architectures since commit d0ffb805b729 ("arch/alpha, termios: implement BOTHER, IBSHIFT and termios2").
--- drivers/tty/tty_baudrate.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/tty/tty_baudrate.c +3 -12
@@ -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);
Signature · 1 line
2.30.2
PATCH v2 4/5 serial: fsl_lpuart: Remove unnecessary clearing for CRTSCTS
In reply to Ilpo Järvinenif (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
@@ -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
PATCH v2 5/5 serial: jsm: Use B0 instead of 0
In reply to Ilpo JärvinenUse B0 to check zero baudrate rather than literal 0.
While at it, remove extra parenthesis around CBAUD.
--- 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
@@ -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
@@ -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
Quoted 8 lines · 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
Thanks for the update.
Quoted 7 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
Quoted 14 lines
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:
Johan