diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2016-01-11 01:40:54 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-01-27 18:01:44 -0500 |
commit | fdfb719e93b55a50f90da2059dc450e7c0c48e8f (patch) | |
tree | 5317736293b5c7c16673df42d4542b78a70831aa | |
parent | 582e20a03b9bcbddaeaffb38800323ddcc4a9173 (diff) |
tty: Remove chars_in_buffer() line discipline method
The chars_in_buffer() line discipline method serves no functional
purpose, other than as a (dubious) debugging aid for mostly bit-rotting
drivers. Despite being documented as an optional method, every caller
is unconditionally executed (although conditionally compiled).
Furthermore, direct tty->ldisc access without an ldisc ref is unsafe.
Lastly, N_TTY's chars_in_buffer() has warned of removal since 3.12.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | Documentation/serial/tty.txt | 3 | ||||
-rw-r--r-- | drivers/tty/amiserial.c | 6 | ||||
-rw-r--r-- | drivers/tty/cyclades.c | 8 | ||||
-rw-r--r-- | drivers/tty/n_gsm.c | 16 | ||||
-rw-r--r-- | drivers/tty/n_tty.c | 23 | ||||
-rw-r--r-- | drivers/tty/rocket.c | 6 | ||||
-rw-r--r-- | drivers/tty/serial/crisv10.c | 12 | ||||
-rw-r--r-- | include/linux/tty_ldisc.h | 7 |
8 files changed, 13 insertions, 68 deletions
diff --git a/Documentation/serial/tty.txt b/Documentation/serial/tty.txt index bc3842dc323a..798cba82c762 100644 --- a/Documentation/serial/tty.txt +++ b/Documentation/serial/tty.txt | |||
@@ -72,9 +72,6 @@ flush_buffer() - (optional) May be called at any point between | |||
72 | open and close, and instructs the line discipline | 72 | open and close, and instructs the line discipline |
73 | to empty its input buffer. | 73 | to empty its input buffer. |
74 | 74 | ||
75 | chars_in_buffer() - (optional) Report the number of bytes in the input | ||
76 | buffer. | ||
77 | |||
78 | set_termios() - (optional) Called on termios structure changes. | 75 | set_termios() - (optional) Called on termios structure changes. |
79 | The caller passes the old termios data and the | 76 | The caller passes the old termios data and the |
80 | current data is in the tty. Called under the | 77 | current data is in the tty. Called under the |
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 2caaf5a2516d..6ba5681b6385 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -965,8 +965,7 @@ static void rs_throttle(struct tty_struct * tty) | |||
965 | struct serial_state *info = tty->driver_data; | 965 | struct serial_state *info = tty->driver_data; |
966 | unsigned long flags; | 966 | unsigned long flags; |
967 | #ifdef SERIAL_DEBUG_THROTTLE | 967 | #ifdef SERIAL_DEBUG_THROTTLE |
968 | printk("throttle %s: %d....\n", tty_name(tty), | 968 | printk("throttle %s ....\n", tty_name(tty)); |
969 | tty->ldisc.chars_in_buffer(tty)); | ||
970 | #endif | 969 | #endif |
971 | 970 | ||
972 | if (serial_paranoia_check(info, tty->name, "rs_throttle")) | 971 | if (serial_paranoia_check(info, tty->name, "rs_throttle")) |
@@ -988,8 +987,7 @@ static void rs_unthrottle(struct tty_struct * tty) | |||
988 | struct serial_state *info = tty->driver_data; | 987 | struct serial_state *info = tty->driver_data; |
989 | unsigned long flags; | 988 | unsigned long flags; |
990 | #ifdef SERIAL_DEBUG_THROTTLE | 989 | #ifdef SERIAL_DEBUG_THROTTLE |
991 | printk("unthrottle %s: %d....\n", tty_name(tty), | 990 | printk("unthrottle %s ....\n", tty_name(tty)); |
992 | tty->ldisc.chars_in_buffer(tty)); | ||
993 | #endif | 991 | #endif |
994 | 992 | ||
995 | if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) | 993 | if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) |
diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c index abbed201dc74..a48e7e66b970 100644 --- a/drivers/tty/cyclades.c +++ b/drivers/tty/cyclades.c | |||
@@ -2852,8 +2852,8 @@ static void cy_throttle(struct tty_struct *tty) | |||
2852 | unsigned long flags; | 2852 | unsigned long flags; |
2853 | 2853 | ||
2854 | #ifdef CY_DEBUG_THROTTLE | 2854 | #ifdef CY_DEBUG_THROTTLE |
2855 | printk(KERN_DEBUG "cyc:throttle %s: %ld...ttyC%d\n", tty_name(tty), | 2855 | printk(KERN_DEBUG "cyc:throttle %s ...ttyC%d\n", tty_name(tty), |
2856 | tty->ldisc.chars_in_buffer(tty), info->line); | 2856 | info->line); |
2857 | #endif | 2857 | #endif |
2858 | 2858 | ||
2859 | if (serial_paranoia_check(info, tty->name, "cy_throttle")) | 2859 | if (serial_paranoia_check(info, tty->name, "cy_throttle")) |
@@ -2891,8 +2891,8 @@ static void cy_unthrottle(struct tty_struct *tty) | |||
2891 | unsigned long flags; | 2891 | unsigned long flags; |
2892 | 2892 | ||
2893 | #ifdef CY_DEBUG_THROTTLE | 2893 | #ifdef CY_DEBUG_THROTTLE |
2894 | printk(KERN_DEBUG "cyc:unthrottle %s: %ld...ttyC%d\n", | 2894 | printk(KERN_DEBUG "cyc:unthrottle %s ...ttyC%d\n", |
2895 | tty_name(tty), tty_chars_in_buffer(tty), info->line); | 2895 | tty_name(tty), info->line); |
2896 | #endif | 2896 | #endif |
2897 | 2897 | ||
2898 | if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) | 2898 | if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) |
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index c3fe026d3168..e3cc27749344 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c | |||
@@ -2304,21 +2304,6 @@ static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
2304 | } | 2304 | } |
2305 | 2305 | ||
2306 | /** | 2306 | /** |
2307 | * gsmld_chars_in_buffer - report available bytes | ||
2308 | * @tty: tty device | ||
2309 | * | ||
2310 | * Report the number of characters buffered to be delivered to user | ||
2311 | * at this instant in time. | ||
2312 | * | ||
2313 | * Locking: gsm lock | ||
2314 | */ | ||
2315 | |||
2316 | static ssize_t gsmld_chars_in_buffer(struct tty_struct *tty) | ||
2317 | { | ||
2318 | return 0; | ||
2319 | } | ||
2320 | |||
2321 | /** | ||
2322 | * gsmld_flush_buffer - clean input queue | 2307 | * gsmld_flush_buffer - clean input queue |
2323 | * @tty: terminal device | 2308 | * @tty: terminal device |
2324 | * | 2309 | * |
@@ -2830,7 +2815,6 @@ static struct tty_ldisc_ops tty_ldisc_packet = { | |||
2830 | .open = gsmld_open, | 2815 | .open = gsmld_open, |
2831 | .close = gsmld_close, | 2816 | .close = gsmld_close, |
2832 | .flush_buffer = gsmld_flush_buffer, | 2817 | .flush_buffer = gsmld_flush_buffer, |
2833 | .chars_in_buffer = gsmld_chars_in_buffer, | ||
2834 | .read = gsmld_read, | 2818 | .read = gsmld_read, |
2835 | .write = gsmld_write, | 2819 | .write = gsmld_write, |
2836 | .ioctl = gsmld_ioctl, | 2820 | .ioctl = gsmld_ioctl, |
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index b280abaad91b..90eca2605fbf 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -381,28 +381,6 @@ static void n_tty_flush_buffer(struct tty_struct *tty) | |||
381 | } | 381 | } |
382 | 382 | ||
383 | /** | 383 | /** |
384 | * n_tty_chars_in_buffer - report available bytes | ||
385 | * @tty: tty device | ||
386 | * | ||
387 | * Report the number of characters buffered to be delivered to user | ||
388 | * at this instant in time. | ||
389 | * | ||
390 | * Locking: exclusive termios_rwsem | ||
391 | */ | ||
392 | |||
393 | static ssize_t n_tty_chars_in_buffer(struct tty_struct *tty) | ||
394 | { | ||
395 | ssize_t n; | ||
396 | |||
397 | WARN_ONCE(1, "%s is deprecated and scheduled for removal.", __func__); | ||
398 | |||
399 | down_write(&tty->termios_rwsem); | ||
400 | n = chars_in_buffer(tty); | ||
401 | up_write(&tty->termios_rwsem); | ||
402 | return n; | ||
403 | } | ||
404 | |||
405 | /** | ||
406 | * is_utf8_continuation - utf8 multibyte check | 384 | * is_utf8_continuation - utf8 multibyte check |
407 | * @c: byte to check | 385 | * @c: byte to check |
408 | * | 386 | * |
@@ -2525,7 +2503,6 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { | |||
2525 | .open = n_tty_open, | 2503 | .open = n_tty_open, |
2526 | .close = n_tty_close, | 2504 | .close = n_tty_close, |
2527 | .flush_buffer = n_tty_flush_buffer, | 2505 | .flush_buffer = n_tty_flush_buffer, |
2528 | .chars_in_buffer = n_tty_chars_in_buffer, | ||
2529 | .read = n_tty_read, | 2506 | .read = n_tty_read, |
2530 | .write = n_tty_write, | 2507 | .write = n_tty_write, |
2531 | .ioctl = n_tty_ioctl, | 2508 | .ioctl = n_tty_ioctl, |
diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c index 802eac7e561b..f624b93a237f 100644 --- a/drivers/tty/rocket.c +++ b/drivers/tty/rocket.c | |||
@@ -1360,8 +1360,7 @@ static void rp_throttle(struct tty_struct *tty) | |||
1360 | struct r_port *info = tty->driver_data; | 1360 | struct r_port *info = tty->driver_data; |
1361 | 1361 | ||
1362 | #ifdef ROCKET_DEBUG_THROTTLE | 1362 | #ifdef ROCKET_DEBUG_THROTTLE |
1363 | printk(KERN_INFO "throttle %s: %d....\n", tty->name, | 1363 | printk(KERN_INFO "throttle %s ....\n", tty->name); |
1364 | tty->ldisc.chars_in_buffer(tty)); | ||
1365 | #endif | 1364 | #endif |
1366 | 1365 | ||
1367 | if (rocket_paranoia_check(info, "rp_throttle")) | 1366 | if (rocket_paranoia_check(info, "rp_throttle")) |
@@ -1377,8 +1376,7 @@ static void rp_unthrottle(struct tty_struct *tty) | |||
1377 | { | 1376 | { |
1378 | struct r_port *info = tty->driver_data; | 1377 | struct r_port *info = tty->driver_data; |
1379 | #ifdef ROCKET_DEBUG_THROTTLE | 1378 | #ifdef ROCKET_DEBUG_THROTTLE |
1380 | printk(KERN_INFO "unthrottle %s: %d....\n", tty->name, | 1379 | printk(KERN_INFO "unthrottle %s ....\n", tty->name); |
1381 | tty->ldisc.chars_in_buffer(tty)); | ||
1382 | #endif | 1380 | #endif |
1383 | 1381 | ||
1384 | if (rocket_paranoia_check(info, "rp_unthrottle")) | 1382 | if (rocket_paranoia_check(info, "rp_unthrottle")) |
diff --git a/drivers/tty/serial/crisv10.c b/drivers/tty/serial/crisv10.c index f13f2ebd215b..e98aef797065 100644 --- a/drivers/tty/serial/crisv10.c +++ b/drivers/tty/serial/crisv10.c | |||
@@ -2968,7 +2968,7 @@ static int rs_raw_write(struct tty_struct *tty, | |||
2968 | 2968 | ||
2969 | local_save_flags(flags); | 2969 | local_save_flags(flags); |
2970 | DFLOW(DEBUG_LOG(info->line, "write count %i ", count)); | 2970 | DFLOW(DEBUG_LOG(info->line, "write count %i ", count)); |
2971 | DFLOW(DEBUG_LOG(info->line, "ldisc %i\n", tty->ldisc.chars_in_buffer(tty))); | 2971 | DFLOW(DEBUG_LOG(info->line, "ldisc\n")); |
2972 | 2972 | ||
2973 | 2973 | ||
2974 | /* The local_irq_disable/restore_flags pairs below are needed | 2974 | /* The local_irq_disable/restore_flags pairs below are needed |
@@ -3161,10 +3161,9 @@ rs_throttle(struct tty_struct * tty) | |||
3161 | { | 3161 | { |
3162 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3162 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
3163 | #ifdef SERIAL_DEBUG_THROTTLE | 3163 | #ifdef SERIAL_DEBUG_THROTTLE |
3164 | printk("throttle %s: %lu....\n", tty_name(tty), | 3164 | printk("throttle %s ....\n", tty_name(tty)); |
3165 | (unsigned long)tty->ldisc.chars_in_buffer(tty)); | ||
3166 | #endif | 3165 | #endif |
3167 | DFLOW(DEBUG_LOG(info->line,"rs_throttle %lu\n", tty->ldisc.chars_in_buffer(tty))); | 3166 | DFLOW(DEBUG_LOG(info->line,"rs_throttle\n")); |
3168 | 3167 | ||
3169 | /* Do RTS before XOFF since XOFF might take some time */ | 3168 | /* Do RTS before XOFF since XOFF might take some time */ |
3170 | if (tty->termios.c_cflag & CRTSCTS) { | 3169 | if (tty->termios.c_cflag & CRTSCTS) { |
@@ -3181,10 +3180,9 @@ rs_unthrottle(struct tty_struct * tty) | |||
3181 | { | 3180 | { |
3182 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; | 3181 | struct e100_serial *info = (struct e100_serial *)tty->driver_data; |
3183 | #ifdef SERIAL_DEBUG_THROTTLE | 3182 | #ifdef SERIAL_DEBUG_THROTTLE |
3184 | printk("unthrottle %s: %lu....\n", tty_name(tty), | 3183 | printk("unthrottle %s ....\n", tty_name(tty)); |
3185 | (unsigned long)tty->ldisc.chars_in_buffer(tty)); | ||
3186 | #endif | 3184 | #endif |
3187 | DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc %d\n", tty->ldisc.chars_in_buffer(tty))); | 3185 | DFLOW(DEBUG_LOG(info->line,"rs_unthrottle ldisc\n")); |
3188 | DFLOW(DEBUG_LOG(info->line,"rs_unthrottle flip.count: %i\n", tty->flip.count)); | 3186 | DFLOW(DEBUG_LOG(info->line,"rs_unthrottle flip.count: %i\n", tty->flip.count)); |
3189 | /* Do RTS before XOFF since XOFF might take some time */ | 3187 | /* Do RTS before XOFF since XOFF might take some time */ |
3190 | if (tty->termios.c_cflag & CRTSCTS) { | 3188 | if (tty->termios.c_cflag & CRTSCTS) { |
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h index 00c9d688d7b7..6101ab8dc148 100644 --- a/include/linux/tty_ldisc.h +++ b/include/linux/tty_ldisc.h | |||
@@ -25,12 +25,6 @@ | |||
25 | * buffers of any input characters it may have queued to be | 25 | * buffers of any input characters it may have queued to be |
26 | * delivered to the user mode process. | 26 | * delivered to the user mode process. |
27 | * | 27 | * |
28 | * ssize_t (*chars_in_buffer)(struct tty_struct *tty); | ||
29 | * | ||
30 | * This function returns the number of input characters the line | ||
31 | * discipline may have queued up to be delivered to the user mode | ||
32 | * process. | ||
33 | * | ||
34 | * ssize_t (*read)(struct tty_struct * tty, struct file * file, | 28 | * ssize_t (*read)(struct tty_struct * tty, struct file * file, |
35 | * unsigned char * buf, size_t nr); | 29 | * unsigned char * buf, size_t nr); |
36 | * | 30 | * |
@@ -188,7 +182,6 @@ struct tty_ldisc_ops { | |||
188 | int (*open)(struct tty_struct *); | 182 | int (*open)(struct tty_struct *); |
189 | void (*close)(struct tty_struct *); | 183 | void (*close)(struct tty_struct *); |
190 | void (*flush_buffer)(struct tty_struct *tty); | 184 | void (*flush_buffer)(struct tty_struct *tty); |
191 | ssize_t (*chars_in_buffer)(struct tty_struct *tty); | ||
192 | ssize_t (*read)(struct tty_struct *tty, struct file *file, | 185 | ssize_t (*read)(struct tty_struct *tty, struct file *file, |
193 | unsigned char __user *buf, size_t nr); | 186 | unsigned char __user *buf, size_t nr); |
194 | ssize_t (*write)(struct tty_struct *tty, struct file *file, | 187 | ssize_t (*write)(struct tty_struct *tty, struct file *file, |