mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
fb0255fb29
Here is the big tty/serial driver pull request for 4.15-rc1. Lots of serial driver updates in here, some small vt cleanups, and a raft of SPDX and license boilerplate cleanups, messing up the diffstat a bit. Nothing major, with no realy functional changes except better hardware support for some platforms. All of these have been in linux-next for a while with no reported issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> -----BEGIN PGP SIGNATURE----- iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCWgnD+w8cZ3JlZ0Brcm9h aC5jb20ACgkQMUfUDdst+ynAmgCfSSr/9qiCE0vfP5eVYjddzxfWyZ4AoMbKORZC 5x2KVW0Btrbs3WmnD7ZU =PSea -----END PGP SIGNATURE----- Merge tag 'tty-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty Pull tty/serial updates from Greg KH: "Here is the big tty/serial driver pull request for 4.15-rc1. Lots of serial driver updates in here, some small vt cleanups, and a raft of SPDX and license boilerplate cleanups, messing up the diffstat a bit. Nothing major, with no realy functional changes except better hardware support for some platforms. All of these have been in linux-next for a while with no reported issues" * tag 'tty-4.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (110 commits) tty: ehv_bytechan: fix spelling mistake tty: serial: meson: allow baud-rates lower than 9600 serial: 8250_fintek: Fix crash with baud rate B0 serial: 8250_fintek: Disable delays for ports != 0 serial: 8250_fintek: Return -EINVAL on invalid configuration tty: Remove redundant license text tty: serdev: Remove redundant license text tty: hvc: Remove redundant license text tty: serial: Remove redundant license text tty: add SPDX identifiers to all remaining files in drivers/tty/ tty: serial: jsm: remove redundant pointer ts tty: serial: jsm: add space before the open parenthesis '(' tty: serial: jsm: fix coding style tty: serial: jsm: delete space between function name and '(' tty: serial: jsm: add blank line after declarations tty: serial: jsm: change the type of local variable tty: serial: imx: remove dead code imx_dma_rxint tty: serial: imx: disable ageing timer interrupt if dma in use serial: 8250: fix potential deadlock in rs485-mode serial: m32r_sio: Drop redundant .data assignment ...
192 lines
4.7 KiB
C
192 lines
4.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* proc_tty.c -- handles /proc/tty
|
|
*
|
|
* Copyright 1997, Theodore Ts'o
|
|
*/
|
|
|
|
#include <linux/uaccess.h>
|
|
#include <linux/module.h>
|
|
#include <linux/init.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/time.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/stat.h>
|
|
#include <linux/tty.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/bitops.h>
|
|
#include "internal.h"
|
|
|
|
/*
|
|
* The /proc/tty directory inodes...
|
|
*/
|
|
static struct proc_dir_entry *proc_tty_driver;
|
|
|
|
/*
|
|
* This is the handler for /proc/tty/drivers
|
|
*/
|
|
static void show_tty_range(struct seq_file *m, struct tty_driver *p,
|
|
dev_t from, int num)
|
|
{
|
|
seq_printf(m, "%-20s ", p->driver_name ? p->driver_name : "unknown");
|
|
seq_printf(m, "/dev/%-8s ", p->name);
|
|
if (p->num > 1) {
|
|
seq_printf(m, "%3d %d-%d ", MAJOR(from), MINOR(from),
|
|
MINOR(from) + num - 1);
|
|
} else {
|
|
seq_printf(m, "%3d %7d ", MAJOR(from), MINOR(from));
|
|
}
|
|
switch (p->type) {
|
|
case TTY_DRIVER_TYPE_SYSTEM:
|
|
seq_puts(m, "system");
|
|
if (p->subtype == SYSTEM_TYPE_TTY)
|
|
seq_puts(m, ":/dev/tty");
|
|
else if (p->subtype == SYSTEM_TYPE_SYSCONS)
|
|
seq_puts(m, ":console");
|
|
else if (p->subtype == SYSTEM_TYPE_CONSOLE)
|
|
seq_puts(m, ":vtmaster");
|
|
break;
|
|
case TTY_DRIVER_TYPE_CONSOLE:
|
|
seq_puts(m, "console");
|
|
break;
|
|
case TTY_DRIVER_TYPE_SERIAL:
|
|
seq_puts(m, "serial");
|
|
break;
|
|
case TTY_DRIVER_TYPE_PTY:
|
|
if (p->subtype == PTY_TYPE_MASTER)
|
|
seq_puts(m, "pty:master");
|
|
else if (p->subtype == PTY_TYPE_SLAVE)
|
|
seq_puts(m, "pty:slave");
|
|
else
|
|
seq_puts(m, "pty");
|
|
break;
|
|
default:
|
|
seq_printf(m, "type:%d.%d", p->type, p->subtype);
|
|
}
|
|
seq_putc(m, '\n');
|
|
}
|
|
|
|
static int show_tty_driver(struct seq_file *m, void *v)
|
|
{
|
|
struct tty_driver *p = list_entry(v, struct tty_driver, tty_drivers);
|
|
dev_t from = MKDEV(p->major, p->minor_start);
|
|
dev_t to = from + p->num;
|
|
|
|
if (&p->tty_drivers == tty_drivers.next) {
|
|
/* pseudo-drivers first */
|
|
seq_printf(m, "%-20s /dev/%-8s ", "/dev/tty", "tty");
|
|
seq_printf(m, "%3d %7d ", TTYAUX_MAJOR, 0);
|
|
seq_puts(m, "system:/dev/tty\n");
|
|
seq_printf(m, "%-20s /dev/%-8s ", "/dev/console", "console");
|
|
seq_printf(m, "%3d %7d ", TTYAUX_MAJOR, 1);
|
|
seq_puts(m, "system:console\n");
|
|
#ifdef CONFIG_UNIX98_PTYS
|
|
seq_printf(m, "%-20s /dev/%-8s ", "/dev/ptmx", "ptmx");
|
|
seq_printf(m, "%3d %7d ", TTYAUX_MAJOR, 2);
|
|
seq_puts(m, "system\n");
|
|
#endif
|
|
#ifdef CONFIG_VT
|
|
seq_printf(m, "%-20s /dev/%-8s ", "/dev/vc/0", "vc/0");
|
|
seq_printf(m, "%3d %7d ", TTY_MAJOR, 0);
|
|
seq_puts(m, "system:vtmaster\n");
|
|
#endif
|
|
}
|
|
|
|
while (MAJOR(from) < MAJOR(to)) {
|
|
dev_t next = MKDEV(MAJOR(from)+1, 0);
|
|
show_tty_range(m, p, from, next - from);
|
|
from = next;
|
|
}
|
|
if (from != to)
|
|
show_tty_range(m, p, from, to - from);
|
|
return 0;
|
|
}
|
|
|
|
/* iterator */
|
|
static void *t_start(struct seq_file *m, loff_t *pos)
|
|
{
|
|
mutex_lock(&tty_mutex);
|
|
return seq_list_start(&tty_drivers, *pos);
|
|
}
|
|
|
|
static void *t_next(struct seq_file *m, void *v, loff_t *pos)
|
|
{
|
|
return seq_list_next(v, &tty_drivers, pos);
|
|
}
|
|
|
|
static void t_stop(struct seq_file *m, void *v)
|
|
{
|
|
mutex_unlock(&tty_mutex);
|
|
}
|
|
|
|
static const struct seq_operations tty_drivers_op = {
|
|
.start = t_start,
|
|
.next = t_next,
|
|
.stop = t_stop,
|
|
.show = show_tty_driver
|
|
};
|
|
|
|
static int tty_drivers_open(struct inode *inode, struct file *file)
|
|
{
|
|
return seq_open(file, &tty_drivers_op);
|
|
}
|
|
|
|
static const struct file_operations proc_tty_drivers_operations = {
|
|
.open = tty_drivers_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release,
|
|
};
|
|
|
|
/*
|
|
* This function is called by tty_register_driver() to handle
|
|
* registering the driver's /proc handler into /proc/tty/driver/<foo>
|
|
*/
|
|
void proc_tty_register_driver(struct tty_driver *driver)
|
|
{
|
|
struct proc_dir_entry *ent;
|
|
|
|
if (!driver->driver_name || driver->proc_entry ||
|
|
!driver->ops->proc_fops)
|
|
return;
|
|
|
|
ent = proc_create_data(driver->driver_name, 0, proc_tty_driver,
|
|
driver->ops->proc_fops, driver);
|
|
driver->proc_entry = ent;
|
|
}
|
|
|
|
/*
|
|
* This function is called by tty_unregister_driver()
|
|
*/
|
|
void proc_tty_unregister_driver(struct tty_driver *driver)
|
|
{
|
|
struct proc_dir_entry *ent;
|
|
|
|
ent = driver->proc_entry;
|
|
if (!ent)
|
|
return;
|
|
|
|
remove_proc_entry(ent->name, proc_tty_driver);
|
|
|
|
driver->proc_entry = NULL;
|
|
}
|
|
|
|
/*
|
|
* Called by proc_root_init() to initialize the /proc/tty subtree
|
|
*/
|
|
void __init proc_tty_init(void)
|
|
{
|
|
if (!proc_mkdir("tty", NULL))
|
|
return;
|
|
proc_mkdir("tty/ldisc", NULL); /* Preserved: it's userspace visible */
|
|
/*
|
|
* /proc/tty/driver/serial reveals the exact character counts for
|
|
* serial links which is just too easy to abuse for inferring
|
|
* password lengths and inter-keystroke timings during password
|
|
* entry.
|
|
*/
|
|
proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR|S_IXUSR, NULL);
|
|
proc_create("tty/ldiscs", 0, NULL, &tty_ldiscs_proc_fops);
|
|
proc_create("tty/drivers", 0, NULL, &proc_tty_drivers_operations);
|
|
}
|