diff options
author | phk <phk@FreeBSD.org> | 2004-06-07 20:45:45 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2004-06-07 20:45:45 +0000 |
commit | bfb13da83136c5d9301591fe777eef0d80120494 (patch) | |
tree | 7b7bb3162ae4f20656b003b9c64c0b109c8d11d0 /sys/kern | |
parent | 635c1632db24421811a7cba130edd3d8f77b8255 (diff) | |
download | FreeBSD-src-bfb13da83136c5d9301591fe777eef0d80120494.zip FreeBSD-src-bfb13da83136c5d9301591fe777eef0d80120494.tar.gz |
Make linesw[] an array of pointers to linedesc instead of an array of
linedisc.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/tty.c | 6 | ||||
-rw-r--r-- | sys/kern/tty_conf.c | 118 |
2 files changed, 60 insertions, 64 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c index da7b696..d59599e 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1015,7 +1015,7 @@ ttioctl(struct tty *tp, u_long cmd, void *data, int flag) if (t != tp->t_line) { s = spltty(); ttyld_close(tp, flag); - error = (*linesw[t].l_open)(device, tp); + error = (*linesw[t]->l_open)(device, tp); if (error) { (void)ttyld_open(tp, device); splx(s); @@ -2772,9 +2772,9 @@ ttyldoptim(struct tty *tp) && (!(t->c_iflag & PARMRK) || (t->c_iflag & (IGNPAR | IGNBRK)) == (IGNPAR | IGNBRK)) && !(t->c_lflag & (ECHO | ICANON | IEXTEN | ISIG | PENDIN)) - && linesw[tp->t_line].l_rint == ttyinput) + && linesw[tp->t_line]->l_rint == ttyinput) tp->t_state |= TS_CAN_BYPASS_L_RINT; else tp->t_state &= ~TS_CAN_BYPASS_L_RINT; - return (linesw[tp->t_line].l_hotchar); + return (linesw[tp->t_line]->l_hotchar); } diff --git a/sys/kern/tty_conf.c b/sys/kern/tty_conf.c index dc20ad9..7a52c50 100644 --- a/sys/kern/tty_conf.c +++ b/sys/kern/tty_conf.c @@ -1,4 +1,5 @@ /*- + * Copyright (c) 2004 Poul-Henning Kamp. All rights reserved. * Copyright (c) 1982, 1986, 1991, 1993 * The Regents of the University of California. All rights reserved. * (c) UNIX System Laboratories, Inc. @@ -59,36 +60,51 @@ static l_start_t l_nostart; * Reconsider the removal of nullmodem anyway. It was too much like * ttymodem, but a completely null version might be useful. */ -#define NODISC(n) \ - { l_noopen, l_noclose, l_noread, l_nowrite, \ - l_nullioctl, l_norint, l_nostart, ttymodem } -struct linesw linesw[MAXLDISC] = -{ - /* 0- termios */ - { ttyopen, ttylclose, ttread, ttwrite, - l_nullioctl, ttyinput, ttstart, ttymodem }, - NODISC(1), /* 1- defunct */ - /* 2- NTTYDISC */ +static struct linesw nodisc = { + .l_open = l_noopen, + .l_close = l_noclose, + .l_read = l_noread, + .l_write = l_nowrite, + .l_ioctl = l_nullioctl, + .l_rint = l_norint, + .l_start = l_nostart, + .l_modem = ttymodem +}; + +static struct linesw termios_disc = { + .l_open = ttyopen, + .l_close = ttylclose, + .l_read = ttread, + .l_write = ttwrite, + .l_ioctl = l_nullioctl, + .l_rint = ttyinput, + .l_start = ttstart, + .l_modem = ttymodem +}; + #ifdef COMPAT_43 - { ttyopen, ttylclose, ttread, ttwrite, - l_nullioctl, ttyinput, ttstart, ttymodem }, +# define ntty_disc termios_disc #else - NODISC(2), +# define ntty_disc nodisc #endif - NODISC(3), /* loadable */ - NODISC(4), /* SLIPDISC */ - NODISC(5), /* PPPDISC */ - NODISC(6), /* NETGRAPHDISC */ - NODISC(7), /* loadable */ - NODISC(8), /* loadable */ + +struct linesw *linesw[MAXLDISC] = { + &termios_disc, /* 0 - termios */ + &nodisc, /* 1 - defunct */ + &ntty_disc, /* 2 - NTTYDISC */ + &nodisc, /* 3 - loadable */ + &nodisc, /* 4 - SLIPDISC */ + &nodisc, /* 5 - PPPDISC */ + &nodisc, /* 6 - NETGRAPHDISC */ + &nodisc, /* 7 - loadable */ + &nodisc, /* 8 - loadable */ }; int nlinesw = sizeof (linesw) / sizeof (linesw[0]); -static struct linesw nodisc = NODISC(0); - #define LOADABLE_LDISC 7 + /* * ldisc_register: Register a line discipline. * @@ -97,10 +113,9 @@ static struct linesw nodisc = NODISC(0); * * Returns: Index used or -1 on failure. */ + int -ldisc_register(discipline, linesw_p) - int discipline; - struct linesw *linesw_p; +ldisc_register(int discipline, struct linesw *linesw_p) { int slot = -1; @@ -110,13 +125,12 @@ ldisc_register(discipline, linesw_p) if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) { slot = i; } - } - else if (discipline >= 0 && discipline < MAXLDISC) { + } else if (discipline >= 0 && discipline < MAXLDISC) { slot = discipline; } if (slot != -1 && linesw_p) - linesw[slot] = *linesw_p; + linesw[slot] = linesw_p; return slot; } @@ -127,81 +141,63 @@ ldisc_register(discipline, linesw_p) * * discipline: Index for discipline to unload. */ + void -ldisc_deregister(discipline) - int discipline; +ldisc_deregister(int discipline) { - if (discipline < MAXLDISC) { - linesw[discipline] = nodisc; - } + + if (discipline < MAXLDISC) + linesw[discipline] = &nodisc; } +/* + * "no" and "null" versions of line discipline functions + */ + static int -l_noopen(dev, tp) - dev_t dev; - struct tty *tp; +l_noopen(dev_t dev, struct tty *tp) { return (ENODEV); } static int -l_noclose(tp, flag) - struct tty *tp; - int flag; +l_noclose(struct tty *tp, int flag) { return (ENODEV); } int -l_noread(tp, uio, flag) - struct tty *tp; - struct uio *uio; - int flag; +l_noread(struct tty *tp, struct uio *uio, int flag) { return (ENODEV); } int -l_nowrite(tp, uio, flag) - struct tty *tp; - struct uio *uio; - int flag; +l_nowrite(struct tty *tp, struct uio *uio, int flag) { return (ENODEV); } static int -l_norint(c, tp) - int c; - struct tty *tp; +l_norint(int c, struct tty *tp) { return (ENODEV); } static int -l_nostart(tp) - struct tty *tp; +l_nostart(struct tty *tp) { return (ENODEV); } -/* - * Do nothing specific version of line - * discipline specific ioctl command. - */ int -l_nullioctl(tp, cmd, data, flags, td) - struct tty *tp; - u_long cmd; - char *data; - int flags; - struct thread *td; +l_nullioctl(struct tty *tp, u_long cmd, char *data, int flags, struct thread *td) { return (ENOIOCTL); |