Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pty: prepare for tty->ops changes

We are about to change the tty layer to avoid keeping private copies of all
the methods in each tty. We have to update the pty layer first as it
currently patches the ioctl method according to the tty type. Use multiple
tty operations sets instead.

Signed-off-by: Alan Cox <alan@redhat.com>
Acked-by: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
3e8e88ca f2545a75

+26 -3
+26 -3
drivers/char/pty.c
··· 254 254 static int legacy_count = CONFIG_LEGACY_PTY_COUNT; 255 255 module_param(legacy_count, int, 0); 256 256 257 + static const struct tty_operations pty_ops_bsd = { 258 + .open = pty_open, 259 + .close = pty_close, 260 + .write = pty_write, 261 + .write_room = pty_write_room, 262 + .flush_buffer = pty_flush_buffer, 263 + .chars_in_buffer = pty_chars_in_buffer, 264 + .unthrottle = pty_unthrottle, 265 + .set_termios = pty_set_termios, 266 + .ioctl = pty_bsd_ioctl, 267 + }; 268 + 257 269 static void __init legacy_pty_init(void) 258 270 { 259 271 if (legacy_count <= 0) ··· 296 284 pty_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW; 297 285 pty_driver->other = pty_slave_driver; 298 286 tty_set_operations(pty_driver, &pty_ops); 299 - pty_driver->ioctl = pty_bsd_ioctl; 300 287 301 288 pty_slave_driver->owner = THIS_MODULE; 302 289 pty_slave_driver->driver_name = "pty_slave"; ··· 388 377 return -ENOIOCTLCMD; 389 378 } 390 379 380 + static const struct tty_operations pty_unix98_ops = { 381 + .open = pty_open, 382 + .close = pty_close, 383 + .write = pty_write, 384 + .write_room = pty_write_room, 385 + .flush_buffer = pty_flush_buffer, 386 + .chars_in_buffer = pty_chars_in_buffer, 387 + .unthrottle = pty_unthrottle, 388 + .set_termios = pty_set_termios, 389 + .ioctl = pty_unix98_ioctl 390 + }; 391 + 392 + 391 393 static void __init unix98_pty_init(void) 392 394 { 393 395 ptm_driver = alloc_tty_driver(NR_UNIX98_PTY_MAX); ··· 427 403 ptm_driver->flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW | 428 404 TTY_DRIVER_DYNAMIC_DEV | TTY_DRIVER_DEVPTS_MEM; 429 405 ptm_driver->other = pts_driver; 430 - tty_set_operations(ptm_driver, &pty_ops); 431 - ptm_driver->ioctl = pty_unix98_ioctl; 406 + tty_set_operations(ptm_driver, &pty_unix98_ops); 432 407 433 408 pts_driver->owner = THIS_MODULE; 434 409 pts_driver->driver_name = "pty_slave";