various tty cleanups
Subsystems (2)
cover various tty cleanups
Hi Greg,
These patches are a mixture of dead declaration removals, uapi cleanup, and other miscellany.
This series depends on the 10-patch 'serial core fixes' series.
Regards,
Peter Hurley (9):
tty: Replace open-coded test with tty_hung_up_p()
tty: Call methods in modern style
tty: Remove defunct pcxe_open() declaration
tty: Remove defunct serial_console_init() declaration
serial: hp300: Remove obsolete comments
cris: Remove obsolete ASYNC_SPLIT_TERMIOS behavior
tty: Document defunct ASYNC_SPLIT_TERMIOS flag in uapi header
vt: Remove vt_get_kmsg_redirect() from uapi header
serial: 8250_em: Remove out-of-memory message
drivers/tty/serial/8250/8250_em.c | 4 +--- drivers/tty/serial/8250/8250_hp300.c | 4 ---- drivers/tty/serial/crisv10.c | 12 ------------ drivers/tty/serial/crisv10.h | 1 - drivers/tty/tty_io.c | 14 +++++++------- drivers/tty/tty_ioctl.c | 4 ++-- drivers/tty/vt/vt.c | 2 ++ include/linux/tty.h | 8 -------- include/uapi/linux/tty_flags.h | 2 +- include/uapi/linux/vt.h | 3 --- 10 files changed, 13 insertions(+), 41 deletions(-)
Signature · 1 line
2.1.3
PATCH 1/9 tty: Replace open-coded test with tty_hung_up_p()
tty_hung_up_p() is equivalent to the open-coded test in tty_open().
--- drivers/tty/tty_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/tty_io.c +1 -1
@@ -2129,7 +2129,7 @@ retry_open:/* * Need to reset f_op in case a hangup happened. */ -if (filp->f_op == &hung_up_tty_fops) +if (tty_hung_up_p (filp)) filp->f_op = &tty_fops; goto retry_open; }
Signature · 1 line
2.1.3
PATCH 2/9 tty: Call methods in modern style
In reply to Peter HurleyThe use of older function ptr calling style, (*fn)(), makes static analysis more error-prone; replace with modern fn() style.
--- drivers/tty/tty_io.c | 12 ++++++------ drivers/tty/tty_ioctl.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/tty/tty_io.c +6 -6
@@ -981,7 +981,7 @@ void __stop_tty(struct tty_struct *tty)return ; tty->stopped =1 ;if (tty->ops->stop) - (tty->ops->stop)(tty); + tty->ops->stop (tty); }void stop_tty (struct tty_struct *tty)
@@ -1012,7 +1012,7 @@ void __start_tty(struct tty_struct *tty)return ; tty->stopped =0 ;if (tty->ops->start) - (tty->ops->start)(tty); + tty->ops->start (tty);tty_wakeup (tty); }
@@ -1066,7 +1066,7 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,situation */ ld =tty_ldisc_ref_wait (tty);if (ld->ops->read) - i = (ld->ops->read)(tty, file, buf, count); + i = ld->ops->read (tty, file, buf, count);else i = -EIO ;tty_ldisc_deref (ld);
@@ -2182,7 +2182,7 @@ static unsigned int tty_poll(struct file *filp, poll_table *wait) ld =tty_ldisc_ref_wait (tty);if (ld->ops->poll) - ret = (ld->ops->poll)(tty, filp, wait); + ret = ld->ops->poll (tty, filp, wait);tty_ldisc_deref (ld);return ret; }
@@ -2905,7 +2905,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)break ; }if (tty->ops->ioctl) { - retval = (tty->ops->ioctl)(tty, cmd, arg); + retval = tty->ops->ioctl (tty, cmd, arg);if (retval != -ENOIOCTLCMD )return retval; }
@@ -2932,7 +2932,7 @@ static long tty_compat_ioctl(struct file *file, unsigned int cmd,return -EINVAL ;if (tty->ops->compat_ioctl) { - retval = (tty->ops->compat_ioctl)(tty, cmd, arg); + retval = tty->ops->compat_ioctl (tty, cmd, arg);if (retval != -ENOIOCTLCMD )return retval; }
drivers/tty/tty_ioctl.c +2 -2
@@ -550,14 +550,14 @@ int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)unset_locked_termios (&tty->termios, &old_termios, &tty->termios_locked);if (tty->ops->set_termios) - (*tty->ops->set_termios)(tty, &old_termios); + tty->ops->set_termios (tty, &old_termios);else tty_termios_copy_hw (&tty->termios, &old_termios); ld =tty_ldisc_ref (tty);if (ld !=NULL ) {if (ld->ops->set_termios) - (ld->ops->set_termios)(tty, &old_termios); + ld->ops->set_termios (tty, &old_termios);tty_ldisc_deref (ld); }up_write (&tty->termios_rwsem);
Signature · 1 line
2.1.3
Joe Perches
maintainerPATCH 1/1 checkpatch: Add --strict test for function pointer calling style
Peter Hurley wrote:
The use of older function ptr calling style, (*fn)(), makes static analysis more error-prone; replace with modern fn() style.
So make checkpatch emit a --strict test for that condition.
Update the unnecessary parentheses test for dereferencing objects at the same time and create a $fix mechanism too.
--- scripts/checkpatch.pl | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +21 -3
@@ -3838,9 +3838,27 @@ sub process { # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) { - CHK("UNNECESSARY_PARENTHESES", - "Unnecessary parentheses around $1\n" . $herecurr); - } + my $var = $1; + if (CHK("UNNECESSARY_PARENTHESES", + "Unnecessary parentheses around $var\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\(\s*\Q$var\E\s*\)/$var/; + } + } + +# check for unnecessary parentheses around function pointer uses +# ie: (foo->bar)(); should be foo->bar(); +# but not "if (foo->bar) (" to avoid some false positives + if ($line =~ /(\bif\s*|)(\(\s*$Ident\s*(?:$Member\s*)+\))[ \t]*\(/ && $1 !~ /^if/) { + my $var = $2; + if (CHK("UNNECESSARY_PARENTHESES", + "Unnecessary parentheses around function pointer $var\n" . $herecurr) && + $fix) { + my $var2 = deparenthesize($var); + $var2 =~ s/\s//g; + $fixed[$fixlinenr] =~ s/\Q$var\E/$var2/; + } + } #goto labels aren't indented, allow a single space however if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
Re: [PATCH] checkpatch: Add --strict test for function pointer calling style
Quoted 9 lines · Joe Perches
Peter Hurley wrote:
The use of older function ptr calling style, (*fn)(), makes static analysis more error-prone; replace with modern
fn()style.So make checkpatch emit a --strict test for that condition.
Update the unnecessary parentheses test for dereferencing objects at the same time and create a $fix mechanism too.
Cool.
perl's not my thing; how does it know not to trip up on
initcall_t *call; (*call)();
[which I verified it properly does not flag in drivers/tty/tty_io.c]
Regards,
Peter Hurley
Quoted 42 lines
Signed-off-by Joe Perches <[email protected]>--- scripts/checkpatch.pl | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)scripts/checkpatch.pl +21
-3@@ -3838,9 +3838,27 @@ sub process { # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) { - CHK("UNNECESSARY_PARENTHESES", - "Unnecessary parentheses around $1\n" . $herecurr); - } + my $var = $1; + if (CHK("UNNECESSARY_PARENTHESES", + "Unnecessary parentheses around $var\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\(\s*\Q$var\E\s*\)/$var/; + } + } + +# check for unnecessary parentheses around function pointer uses +# ie: (foo->bar)(); should be foo->bar(); +# but not "if (foo->bar) (" to avoid some false positives + if ($line =~ /(\bif\s*|)(\(\s*$Ident\s*(?:$Member\s*)+\))[ \t]*\(/ && $1 !~ /^if/) { + my $var = $2; + if (CHK("UNNECESSARY_PARENTHESES", + "Unnecessary parentheses around function pointer $var\n" . $herecurr) && + $fix) { + my $var2 = deparenthesize($var); + $var2 =~ s/\s//g; + $fixed[$fixlinenr] =~ s/\Q$var\E/$var2/; + } + } #goto labels aren't indented, allow a single space however if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
Joe Perches
maintainerRe: [PATCH] checkpatch: Add --strict test for function pointer calling style
Quoted 13 lines · Peter Hurley
Quoted 9 lines · Joe Perches
Peter Hurley wrote:
The use of older function ptr calling style, (*fn)(), makes static analysis more error-prone; replace with modern
fn()style.So make checkpatch emit a --strict test for that condition.
Update the unnecessary parentheses test for dereferencing objects at the same time and create a $fix mechanism too.
Cool.
Quoted 7 lines
perl's not my thing; how does it know not to trip up on
initcall_t *call; (*call)();[which I verified it properly does not flag in
drivers/tty/tty_io.c]
because the regex only matches "(foo->bar)("
It doesn't match (*foo->bar)("
and foo->bar could be any number of -> or . uses like
"(foo->bar.baz)("
or
"( foo -> bar . baz ) ("
PATCH 3/9 tty: Remove defunct pcxe_open() declaration
In reply to Peter Hurleypcxe_open() has no definition in mainline; remove declaration.
--- include/linux/tty.h | 4 ---- 1 file changed, 4 deletions(-)
include/linux/tty.h +0 -4
@@ -621,10 +621,6 @@ extern long n_tty_compat_ioctl_helper(struct tty_struct *tty, struct file *file,extern void serial_console_init (void ); -/* pcxx.c */ - -extern int pcxe_open (struct tty_struct *tty,struct file *filp); -/* vt.c */ extern int vt_ioctl(struct tty_struct *tty,
Signature · 1 line
2.1.3
PATCH 4/9 tty: Remove defunct serial_console_init() declaration
In reply to Peter Hurleyserial_console_init() is not defined by the tty core; remove declaration.
Note that the powerpc arch boot code contains a serial_console_init() declaration in arch/powerpc/boot/ops.h which is restricted to the powerpc arch boot.
--- include/linux/tty.h | 4 ---- 1 file changed, 4 deletions(-)
include/linux/tty.h +0 -4
@@ -617,10 +617,6 @@ extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,extern long n_tty_compat_ioctl_helper (struct tty_struct *tty,struct file *file,unsigned int cmd,unsigned long arg); -/* serial.c */ - -extern void serial_console_init (void ); -/* vt.c */ extern int vt_ioctl(struct tty_struct *tty,
Signature · 1 line
2.1.3
PATCH 5/9 serial: hp300: Remove obsolete comments
In reply to Peter Hurleysetup_serial_console() is obsolete and has been superseded by early_serial_setup() which is called at the end of the function.
The IA64 arch does not call this function; only the m68k arch setup calls this function.
--- drivers/tty/serial/8250/8250_hp300.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/tty/serial/8250/8250_hp300.c +0 -4
@@ -88,10 +88,6 @@ extern int hp300_uart_scode;/* * Parse the bootinfo to find descriptions for headless console and * debug serial ports and register them with the 8250 driver. -* This function should be called before serial_console_init() is called -* to make sure the serial console will be available for use. IA-64 kernel -* calls this function from setup_arch() after the EFI and ACPI tables have -* been parsed. */ int __init hp300_setup_serial_console (void ) {
Signature · 1 line
2.1.3
Re: [PATCH -next 5/9] serial: hp300: Remove obsolete comments
Quoted 7 lines · Peter Hurley
setup_serial_console()is obsolete and has been superseded byearly_serial_setup()which is called at the end of the function.The IA64 arch does not call this function; only the m68k arch setup calls this function.
Signed-off-by Peter Hurley <[email protected]>
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
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
PATCH 6/9 cris: Remove obsolete ASYNC_SPLIT_TERMIOS behavior
In reply to Peter HurleyASYNC_SPLIT_TERMIOS behavior is a remnant of the long-dead /dev/cuaXX callout device. Split termios handling was removed tree-wide in v2.5.71 by:
commit 99a21edebbfd8c29e39ee7fcc8a1ffa423657290
Author: Alexander Viro <[email protected]> Date: Wed Jun 11 07:41:28 2003 -0700
[PATCH] tty_driver refcounting
killed the last remnants of callout stuff - we don't need to mess with storing termios privately anymore.
which pre-dated the re-introduction into the cris serial driver in v2.6.7 by:
commit 311a5ffeda8ccb3f1f3840069f37234e043092d4
Author: Andrew Morton <[email protected]> Date: Mon May 31 18:52:29 2004 -0700
[PATCH] CRIS architecture update
From: "Mikael Starvik" <[email protected]>
- Lots of fixes from 2.4.
- Updated for 2.6.6.
- Added IDE driver
--- drivers/tty/serial/crisv10.c | 12 ------------ drivers/tty/serial/crisv10.h | 1 - 2 files changed, 13 deletions(-)
drivers/tty/serial/crisv10.c +0 -12
@@ -3676,12 +3676,6 @@ rs_close(struct tty_struct *tty, struct file * filp) } info->port.flags |=ASYNC_CLOSING ;/* -* Save the termios structure, since this port may have -* separate termios for callout and dialin. -*/ -if (info->port.flags &ASYNC_NORMAL_ACTIVE ) - info->normal_termios = tty->termios; -/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters. */
@@ -4076,11 +4070,6 @@ rs_open(struct tty_struct *tty, struct file * filp)return retval; } -if ((info->port.count ==1 ) && (info->port.flags &ASYNC_SPLIT_TERMIOS )) { - tty->termios = info->normal_termios; -change_speed (info); - } -#ifdef SERIAL_DEBUG_OPEN printk ("rs_open ttyS%d successful...\n" , info->line);#endif
@@ -4327,7 +4316,6 @@ static int __init rs_init(void) info->custom_divisor =0 ; info->x_char =0 ; info->event =0 ; - info->normal_termios = driver->init_termios; info->xmit.buf =NULL ; info->xmit.tail = info->xmit.head =0 ; info->first_recv_buffer = info->last_recv_buffer =NULL ;
drivers/tty/serial/crisv10.h +0 -1
@@ -98,7 +98,6 @@ struct e100_serial {struct work_struct work;struct async_icount icount;/* error-statistics etc.*/ -struct ktermios normal_termios;unsigned long char_time_usec;/* The time for 1 char, in usecs */ unsigned long flush_time_usec;/* How often we should flush */
Signature · 1 line
2.1.3
Re: [PATCH -next 6/9] cris: Remove obsolete ASYNC_SPLIT_TERMIOS behavior
Quoted 23 lines · Peter Hurley
ASYNC_SPLIT_TERMIOSbehavior is a remnant of the long-dead/dev/cuaXXcallout device. Split termios handling was removed tree-wide in v2.5.71 by:commit
99a21edebbfd8c29e39ee7fcc8a1ffa423657290Author: Alexander Viro <[email protected]> Date: Wed Jun 11 07:41:28 2003 -0700[PATCH]
tty_driverrefcountingkilled the last remnants of callout stuff - we don't need to mess with storing termios privately anymore.
which pre-dated the re-introduction into the cris serial driver in v2.6.7 by:
commit
311a5ffeda8ccb3f1f3840069f37234e043092d4Author: Andrew Morton <[email protected]> Date: Mon May 31 18:52:29 2004 -0700[PATCH] CRIS architecture update
From: "Mikael Starvik" <[email protected]>
Quoted 7 lines
- Lots of fixes from 2.4.
- Updated for 2.6.6.
- Added IDE driver
Cc Mikael Starvik <[email protected]>
Agreed.
Quoted 57 lines
Signed-off-by Peter Hurley <[email protected]>--- drivers/tty/serial/crisv10.c | 12 ------------ drivers/tty/serial/crisv10.h | 1 - 2 files changed, 13 deletions(-)drivers/tty/serial/crisv10.c +0
-12@@ -3676,12 +3676,6 @@ rs_close(struct tty_struct *tty, struct file * filp) } info->port.flags |=ASYNC_CLOSING ;/* -* Save the termios structure, since this port may have -* separate termios for callout and dialin. -*/ -if (info->port.flags &ASYNC_NORMAL_ACTIVE ) - info->normal_termios = tty->termios; -/* * Now we wait for the transmit buffer to clear; and we notify * the line discipline to only process XON/XOFF characters. */ @@ -4076,11 +4070,6 @@ rs_open(struct tty_struct *tty, struct file * filp)return retval; } -if ((info->port.count ==1 ) && (info->port.flags &ASYNC_SPLIT_TERMIOS )) { - tty->termios = info->normal_termios; -change_speed (info); - } -#ifdef SERIAL_DEBUG_OPEN printk ("rs_open ttyS%d successful...\n" , info->line);#endif @@ -4327,7 +4316,6 @@ static int __init rs_init(void) info->custom_divisor =0 ; info->x_char =0 ; info->event =0 ; - info->normal_termios = driver->init_termios; info->xmit.buf =NULL ; info->xmit.tail = info->xmit.head =0 ; info->first_recv_buffer = info->last_recv_buffer =NULL ;drivers/tty/serial/crisv10.h +0
-1@@ -98,7 +98,6 @@ struct e100_serial {struct work_struct work;struct async_icount icount;/* error-statistics etc.*/ -struct ktermios normal_termios;unsigned long char_time_usec;/* The time for 1 char, in usecs */ unsigned long flush_time_usec;/* How often we should flush */ Signature · 1 line
2.1.3
/^JN - Jesper Nilsson
Signature · 1 line
Jesper Nilsson -- [email protected]
PATCH 7/9 tty: Document defunct ASYNC_SPLIT_TERMIOS flag in uapi header
In reply to Peter HurleyThe last vestige of ASYNC_SPLIT_TERMIOS was removed by commit 'cris: Remove obsolete ASYNC_SPLIT_TERMIOS behavior'. Mark the flag as defunct in the uapi header.
--- include/uapi/linux/tty_flags.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/tty_flags.h +1 -1
@@ -14,7 +14,7 @@* on the callout port */ #define ASYNCB_FOURPORT 1/* Set OU1, OUT2 per AST Fourport settings */ #define ASYNCB_SAK 2/* Secure Attention Key (Orange book) */ -#define ASYNCB_SPLIT_TERMIOS 3/* Separate termios for dialin/callout */ +#define ASYNCB_SPLIT_TERMIOS 3/* [x] Separate termios for dialin/callout */ #define ASYNCB_SPD_HI 4/* Use 56000 instead of 38400 bps */ #define ASYNCB_SPD_VHI 5/* Use 115200 instead of 38400 bps */ #define ASYNCB_SKIP_TEST 6/* Skip UART test during autoconfiguration */
Signature · 1 line
2.1.3
PATCH 8/9 vt: Remove vt_get_kmsg_redirect() from uapi header
In reply to Peter Hurleyvt_get_kmsg_redirect() only has meaning to the console driver as an alias for calling vt_kmsg_redirect(). Move the macro definition to the only source file which uses it; remove from uapi/linux/vt.h
--- drivers/tty/vt/vt.c | 2 ++ include/uapi/linux/vt.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-)
drivers/tty/vt/vt.c +2 -0
@@ -2509,6 +2509,8 @@ int vt_kmsg_redirect(int new)return kmsg_con; } +#define vt_get_kmsg_redirect () vt_kmsg_redirect(-1) +/* * Console on virtual terminal *
include/uapi/linux/vt.h +0 -3
@@ -84,7 +84,4 @@ struct vt_setactivate {#define VT_SETACTIVATE 0x560F/* Activate and set the mode of a console */ - -#define vt_get_kmsg_redirect () vt_kmsg_redirect(-1) -#endif /* _UAPI_LINUX_VT_H */
Signature · 1 line
2.1.3
PATCH 9/9 serial: 8250_em: Remove out-of-memory message
In reply to Peter Hurleydevm_kzalloc() already warns if allocation fails; remove duplicate message.
--- drivers/tty/serial/8250/8250_em.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/tty/serial/8250/8250_em.c +1 -3
@@ -102,10 +102,8 @@ static int serial8250_em_probe(struct platform_device *pdev) } priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); -if (!priv) { -dev_err (&pdev->dev,"unable to allocate private data\n" ); +if (!priv)return -ENOMEM ; - } priv->sclk =devm_clk_get (&pdev->dev,"sclk" );if (IS_ERR (priv->sclk)) {
Signature · 1 line
2.1.3