Skip to content

Commit 98602c0

Browse files
committed
tty: create internal tty.h file
There are a number of functions and #defines in include/linux/tty.h that do not belong there as they are private to the tty core code. Create an initial drivers/tty/tty.h file and copy the odd "tty logging" macros into it to seed the file with some initial things that we know nothing outside of the tty core should be calling. Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Cc: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20210408125134.3016837-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0a360e8 commit 98602c0

File tree

8 files changed

+27
-12
lines changed

8 files changed

+27
-12
lines changed

drivers/tty/n_tty.c

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include <linux/module.h>
5050
#include <linux/ratelimit.h>
5151
#include <linux/vmalloc.h>
52+
#include "tty.h"
5253

5354
/*
5455
* Until this number of characters is queued in the xmit buffer, select will

drivers/tty/pty.c

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/file.h>
3030
#include <linux/ioctl.h>
3131
#include <linux/compat.h>
32+
#include "tty.h"
3233

3334
#undef TTY_DEBUG_HANGUP
3435
#ifdef TTY_DEBUG_HANGUP

drivers/tty/tty.h

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/*
3+
* TTY core internal functions
4+
*/
5+
6+
#ifndef _TTY_INTERNAL_H
7+
#define _TTY_INTERNAL_H
8+
9+
#define tty_msg(fn, tty, f, ...) \
10+
fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__)
11+
12+
#define tty_debug(tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__)
13+
#define tty_info(tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__)
14+
#define tty_notice(tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__)
15+
#define tty_warn(tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__)
16+
#define tty_err(tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__)
17+
18+
#define tty_info_ratelimited(tty, f, ...) \
19+
tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__)
20+
21+
#endif

drivers/tty/tty_io.c

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108

109109
#include <linux/kmod.h>
110110
#include <linux/nsproxy.h>
111+
#include "tty.h"
111112

112113
#undef TTY_DEBUG_HANGUP
113114
#ifdef TTY_DEBUG_HANGUP

drivers/tty/tty_jobctrl.c

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/tty.h>
1212
#include <linux/fcntl.h>
1313
#include <linux/uaccess.h>
14+
#include "tty.h"
1415

1516
static int is_ignored(int sig)
1617
{

drivers/tty/tty_ldisc.c

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/seq_file.h>
2020
#include <linux/uaccess.h>
2121
#include <linux/ratelimit.h>
22+
#include "tty.h"
2223

2324
#undef LDISC_DEBUG_HANGUP
2425

drivers/tty/tty_port.c

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/delay.h>
1919
#include <linux/module.h>
2020
#include <linux/serdev.h>
21+
#include "tty.h"
2122

2223
static int tty_port_default_receive_buf(struct tty_port *port,
2324
const unsigned char *p,

include/linux/tty.h

-12
Original file line numberDiff line numberDiff line change
@@ -772,16 +772,4 @@ static inline void proc_tty_register_driver(struct tty_driver *d) {}
772772
static inline void proc_tty_unregister_driver(struct tty_driver *d) {}
773773
#endif
774774

775-
#define tty_msg(fn, tty, f, ...) \
776-
fn("%s %s: " f, tty_driver_name(tty), tty_name(tty), ##__VA_ARGS__)
777-
778-
#define tty_debug(tty, f, ...) tty_msg(pr_debug, tty, f, ##__VA_ARGS__)
779-
#define tty_info(tty, f, ...) tty_msg(pr_info, tty, f, ##__VA_ARGS__)
780-
#define tty_notice(tty, f, ...) tty_msg(pr_notice, tty, f, ##__VA_ARGS__)
781-
#define tty_warn(tty, f, ...) tty_msg(pr_warn, tty, f, ##__VA_ARGS__)
782-
#define tty_err(tty, f, ...) tty_msg(pr_err, tty, f, ##__VA_ARGS__)
783-
784-
#define tty_info_ratelimited(tty, f, ...) \
785-
tty_msg(pr_info_ratelimited, tty, f, ##__VA_ARGS__)
786-
787775
#endif

0 commit comments

Comments
 (0)