diff options
author | phk <phk@FreeBSD.org> | 1999-09-28 11:45:31 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1999-09-28 11:45:31 +0000 |
commit | 5e9f92ecf757c8f55ddae7d0dcec108fef05954d (patch) | |
tree | 98fbe8a4cc58070df6f9fb9ad41348c78b444f78 | |
parent | 9f4fe5b99e561702e8ee5934290097d4ef487e94 (diff) | |
download | FreeBSD-src-5e9f92ecf757c8f55ddae7d0dcec108fef05954d.zip FreeBSD-src-5e9f92ecf757c8f55ddae7d0dcec108fef05954d.tar.gz |
Introduce ttyread() and ttywrite() which do the canonical thing.
Use them in many tty drivers.
Reviewed by: julian, bde
-rw-r--r-- | sys/alpha/alpha/promcons.c | 28 | ||||
-rw-r--r-- | sys/alpha/tlsb/zs_tlsb.c | 20 | ||||
-rw-r--r-- | sys/dev/cy/cy.c | 20 | ||||
-rw-r--r-- | sys/dev/cy/cy_isa.c | 20 | ||||
-rw-r--r-- | sys/dev/dgb/dgb.c | 56 | ||||
-rw-r--r-- | sys/dev/dgb/dgm.c | 52 | ||||
-rw-r--r-- | sys/dev/rc/rc.c | 30 | ||||
-rw-r--r-- | sys/dev/rp/rp.c | 30 | ||||
-rw-r--r-- | sys/dev/si/si.c | 26 | ||||
-rw-r--r-- | sys/dev/syscons/syscons.c | 14 | ||||
-rw-r--r-- | sys/gnu/i386/isa/dgb.c | 56 | ||||
-rw-r--r-- | sys/gnu/i386/isa/dgm.c | 52 | ||||
-rw-r--r-- | sys/i386/isa/cx.c | 28 | ||||
-rw-r--r-- | sys/i386/isa/cy.c | 20 | ||||
-rw-r--r-- | sys/i386/isa/istallion.c | 16 | ||||
-rw-r--r-- | sys/i386/isa/pcvt/pcvt_drv.c | 28 | ||||
-rw-r--r-- | sys/i386/isa/rc.c | 30 | ||||
-rw-r--r-- | sys/i386/isa/rp.c | 30 | ||||
-rw-r--r-- | sys/i386/isa/si.c | 26 | ||||
-rw-r--r-- | sys/i386/isa/stallion.c | 40 | ||||
-rw-r--r-- | sys/kern/tty.c | 29 | ||||
-rw-r--r-- | sys/pc98/pc98/syscons.c | 14 | ||||
-rw-r--r-- | sys/sys/tty.h | 2 |
23 files changed, 70 insertions, 597 deletions
diff --git a/sys/alpha/alpha/promcons.c b/sys/alpha/alpha/promcons.c index 14305fb..8b4d3b1 100644 --- a/sys/alpha/alpha/promcons.c +++ b/sys/alpha/alpha/promcons.c @@ -61,16 +61,14 @@ static d_open_t promopen; static d_close_t promclose; -static d_read_t promread; -static d_write_t promwrite; static d_ioctl_t promioctl; #define CDEV_MAJOR 97 static struct cdevsw prom_cdevsw = { /* open */ promopen, /* close */ promclose, - /* read */ promread, - /* write */ promwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ promioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -161,28 +159,6 @@ promclose(dev, flag, mode, p) } int -promread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = &prom_tty[minor(dev)]; - - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -promwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = &prom_tty[minor(dev)]; - - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - -int promioctl(dev, cmd, data, flag, p) dev_t dev; u_long cmd; diff --git a/sys/alpha/tlsb/zs_tlsb.c b/sys/alpha/tlsb/zs_tlsb.c index 9c3944b..e13f196 100644 --- a/sys/alpha/tlsb/zs_tlsb.c +++ b/sys/alpha/tlsb/zs_tlsb.c @@ -64,16 +64,14 @@ struct zs_softc { static d_open_t zsopen; static d_close_t zsclose; -static d_read_t zsread; -static d_write_t zswrite; static d_ioctl_t zsioctl; #define CDEV_MAJOR 98 static struct cdevsw zs_cdevsw = { /* open */ zsopen, /* close */ zsclose, - /* read */ zsread, - /* write */ zswrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ zsioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -303,20 +301,6 @@ zsclose(dev_t dev, int flag, int mode, struct proc *p) } static int -zsread(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = &ZS_SOFTC(minor(dev))->tty; - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -static int -zswrite(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = &ZS_SOFTC(minor(dev))->tty; - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - -static int zsioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { struct tty *tp = &ZS_SOFTC(minor(dev))->tty; diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 472544a..041b4dd 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -132,7 +132,6 @@ #define sioopen cyopen #define siopoll cypoll #define sioprobe cyprobe -#define sioread cyread #define siosettimeout cysettimeout #define siosetwater cysetwater #define comstop cystop @@ -367,7 +366,6 @@ struct isa_driver siodriver = { static d_open_t sioopen; static d_close_t sioclose; -static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; @@ -375,7 +373,7 @@ static d_ioctl_t sioioctl; static struct cdevsw sio_cdevsw = { /* open */ sioopen, /* close */ sioclose, - /* read */ sioread, + /* read */ ttyread, /* write */ siowrite, /* ioctl */ sioioctl, /* poll */ ttypoll, @@ -940,22 +938,6 @@ comhardclose(com) } static int -sioread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - tp = com_addr(MINOR_TO_UNIT(mynor))->tp; - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -static int siowrite(dev, uio, flag) dev_t dev; struct uio *uio; diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c index 472544a..041b4dd 100644 --- a/sys/dev/cy/cy_isa.c +++ b/sys/dev/cy/cy_isa.c @@ -132,7 +132,6 @@ #define sioopen cyopen #define siopoll cypoll #define sioprobe cyprobe -#define sioread cyread #define siosettimeout cysettimeout #define siosetwater cysetwater #define comstop cystop @@ -367,7 +366,6 @@ struct isa_driver siodriver = { static d_open_t sioopen; static d_close_t sioclose; -static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; @@ -375,7 +373,7 @@ static d_ioctl_t sioioctl; static struct cdevsw sio_cdevsw = { /* open */ sioopen, /* close */ sioclose, - /* read */ sioread, + /* read */ ttyread, /* write */ siowrite, /* ioctl */ sioioctl, /* poll */ ttypoll, @@ -940,22 +938,6 @@ comhardclose(com) } static int -sioread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - tp = com_addr(MINOR_TO_UNIT(mynor))->tp; - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -static int siowrite(dev, uio, flag) dev_t dev; struct uio *uio; diff --git a/sys/dev/dgb/dgb.c b/sys/dev/dgb/dgb.c index ea7b548..481eaf6 100644 --- a/sys/dev/dgb/dgb.c +++ b/sys/dev/dgb/dgb.c @@ -204,16 +204,14 @@ struct isa_driver dgbdriver = { static d_open_t dgbopen; static d_close_t dgbclose; -static d_read_t dgbread; -static d_write_t dgbwrite; static d_ioctl_t dgbioctl; #define CDEV_MAJOR 58 static struct cdevsw dgb_cdevsw = { /* open */ dgbopen, /* close */ dgbclose, - /* read */ dgbread, - /* write */ dgbwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ dgbioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -1198,55 +1196,7 @@ static void dgb_pause(chan) void *chan; { -wakeup((caddr_t)chan); -} - - -static int -dgbread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgb_softc[unit].ttys[pnum]; - - error=linesw[tp->t_line].l_read(tp, uio, flag); - DPRINT4(DB_RD,"dgb%d: port%d: read() returns %d\n",unit,pnum,error); - return error; -} - -static int -dgbwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgb_softc[unit].ttys[pnum]; - - error=linesw[tp->t_line].l_write(tp, uio, flag); - DPRINT4(DB_WR,"dgb%d: port%d: write() returns %d\n",unit,pnum,error); - return error; + wakeup((caddr_t)chan); } static void diff --git a/sys/dev/dgb/dgm.c b/sys/dev/dgb/dgm.c index 4a2ec53..3732302 100644 --- a/sys/dev/dgb/dgm.c +++ b/sys/dev/dgb/dgm.c @@ -208,16 +208,14 @@ struct isa_driver dgmdriver = { static d_open_t dgmopen; static d_close_t dgmclose; -static d_read_t dgmread; -static d_write_t dgmwrite; static d_ioctl_t dgmioctl; #define CDEV_MAJOR 101 static struct cdevsw dgm_cdevsw = { /* open */ dgmopen, /* close */ dgmclose, - /* read */ dgmread, - /* write */ dgmwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ dgmioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -1005,52 +1003,6 @@ wakeup((caddr_t)chan); } -static int -dgmread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgm_softc[unit].ttys[pnum]; - error=linesw[tp->t_line].l_read(tp, uio, flag); - DPRINT4(DB_RD,"dgm%d: port%d: read() returns %d\n",unit,pnum,error); - return error; -} - -static int -dgmwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgm_softc[unit].ttys[pnum]; - - error=linesw[tp->t_line].l_write(tp, uio, flag); - DPRINT4(DB_WR,"dgm%d: port%d: write() returns %d\n",unit,pnum,error); - return error; -} - static void dgmpoll(unit_c) void *unit_c; diff --git a/sys/dev/rc/rc.c b/sys/dev/rc/rc.c index 91b735e..f437eec 100644 --- a/sys/dev/rc/rc.c +++ b/sys/dev/rc/rc.c @@ -87,16 +87,14 @@ struct isa_driver rcdriver = { static d_open_t rcopen; static d_close_t rcclose; -static d_read_t rcread; -static d_write_t rcwrite; static d_ioctl_t rcioctl; #define CDEV_MAJOR 63 static struct cdevsw rc_cdevsw = { /* open */ rcopen, /* close */ rcclose, - /* read */ rcread, - /* write */ rcwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ rcioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -865,30 +863,6 @@ register struct rc_chans *rc; (void) splx(s); } -/* Read from line */ -static int -rcread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = rc_chans[GET_UNIT(dev)].rc_tp; - - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -/* Write to line */ -static int -rcwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = rc_chans[GET_UNIT(dev)].rc_tp; - - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - /* Reset the bastard */ static void rc_hwreset(unit, nec, chipid) register int unit, nec; diff --git a/sys/dev/rp/rp.c b/sys/dev/rp/rp.c index 5a4cceb..bc846d5 100644 --- a/sys/dev/rp/rp.c +++ b/sys/dev/rp/rp.c @@ -794,7 +794,6 @@ static char driver_name[] = "rp"; static d_open_t rpopen; static d_close_t rpclose; -static d_read_t rpread; static d_write_t rpwrite; static d_ioctl_t rpioctl; @@ -802,7 +801,7 @@ static d_ioctl_t rpioctl; static struct cdevsw rp_cdevsw = { /* open */ rpopen, /* close */ rpclose, - /* read */ rpread, + /* read */ ttyread, /* write */ rpwrite, /* ioctl */ rpioctl, /* poll */ ttypoll, @@ -856,9 +855,6 @@ static int rpparam __P((struct tty *, struct termios *)); static void rpstart __P((struct tty *)); static void rpstop __P((struct tty *, int)); static void rphardclose __P((struct rp_port *)); -#define rpmap nomap -#define rpreset noreset -#define rpstrategy nostrategy static void rp_disc_optim __P((struct tty *tp, struct termios *t, struct rp_port *rp)); @@ -1504,30 +1500,6 @@ rphardclose(struct rp_port *rp) static int -rpread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct rp_port *rp; - struct tty *tp; - int unit, mynor, umynor, port, error = 0; /* SG */ - - umynor = (((minor(dev) >> 16) -1) * 32); /* SG */ - port = (minor(dev) & 0x1f); /* SG */ - mynor = (port + umynor); /* SG */ - unit = minor_to_unit[mynor]; /* SG */ - - if(IS_CONTROL(dev)) - return(ENODEV); - rp = rp_addr(unit) + port; - tp = rp->rp_tty; - error = (*linesw[tp->t_line].l_read)(tp, uio, flag); - return(error); -} - -static -int rpwrite(dev, uio, flag) dev_t dev; struct uio *uio; diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index 79097ca..1de0aae 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -169,7 +169,6 @@ DATA_SET(eisadriver_set, si_eisa_driver); static d_open_t siopen; static d_close_t siclose; -static d_read_t siread; static d_write_t siwrite; static d_ioctl_t siioctl; @@ -177,7 +176,7 @@ static d_ioctl_t siioctl; static struct cdevsw si_cdevsw = { /* open */ siopen, /* close */ siclose, - /* read */ siread, + /* read */ ttyread, /* write */ siwrite, /* ioctl */ siioctl, /* poll */ ttypoll, @@ -1389,29 +1388,6 @@ sidtrwakeup(chan) splx(oldspl); } -/* - * User level stuff - read and write - */ -static int -siread(dev, uio, flag) - register dev_t dev; - struct uio *uio; - int flag; -{ - register struct tty *tp; - int mynor = minor(dev); - - if (IS_SPECIAL(mynor)) { - DPRINT((0, DBG_ENTRY|DBG_FAIL|DBG_READ, "siread(CONTROLDEV!!)\n")); - return(ENODEV); - } - tp = MINOR2TP(mynor); - DPRINT((TP2PP(tp), DBG_ENTRY|DBG_READ, - "siread(%s,%x,%x)\n", devtoname(dev), uio, flag)); - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - - static int siwrite(dev, uio, flag) dev_t dev; diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index 4cff39f..552aacd 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -205,7 +205,6 @@ CONS_DRIVER(sc, sccnprobe, sccninit, sccnterm, sccngetc, sccncheckc, sccnputc); static d_open_t scopen; static d_close_t scclose; static d_read_t scread; -static d_write_t scwrite; static d_ioctl_t scioctl; static d_mmap_t scmmap; @@ -213,7 +212,7 @@ static struct cdevsw sc_cdevsw = { /* open */ scopen, /* close */ scclose, /* read */ scread, - /* write */ scwrite, + /* write */ ttywrite, /* ioctl */ scioctl, /* poll */ ttypoll, /* mmap */ scmmap, @@ -579,18 +578,9 @@ scclose(dev_t dev, int flag, int mode, struct proc *p) int scread(dev_t dev, struct uio *uio, int flag) { - struct tty *tp = dev->si_tty; sc_touch_scrn_saver(); - return((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -scwrite(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = dev->si_tty; - - return((*linesw[tp->t_line].l_write)(tp, uio, flag)); + return(ttyread(dev, uio, flag)); } static int diff --git a/sys/gnu/i386/isa/dgb.c b/sys/gnu/i386/isa/dgb.c index ea7b548..481eaf6 100644 --- a/sys/gnu/i386/isa/dgb.c +++ b/sys/gnu/i386/isa/dgb.c @@ -204,16 +204,14 @@ struct isa_driver dgbdriver = { static d_open_t dgbopen; static d_close_t dgbclose; -static d_read_t dgbread; -static d_write_t dgbwrite; static d_ioctl_t dgbioctl; #define CDEV_MAJOR 58 static struct cdevsw dgb_cdevsw = { /* open */ dgbopen, /* close */ dgbclose, - /* read */ dgbread, - /* write */ dgbwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ dgbioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -1198,55 +1196,7 @@ static void dgb_pause(chan) void *chan; { -wakeup((caddr_t)chan); -} - - -static int -dgbread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgb_softc[unit].ttys[pnum]; - - error=linesw[tp->t_line].l_read(tp, uio, flag); - DPRINT4(DB_RD,"dgb%d: port%d: read() returns %d\n",unit,pnum,error); - return error; -} - -static int -dgbwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgb_softc[unit].ttys[pnum]; - - error=linesw[tp->t_line].l_write(tp, uio, flag); - DPRINT4(DB_WR,"dgb%d: port%d: write() returns %d\n",unit,pnum,error); - return error; + wakeup((caddr_t)chan); } static void diff --git a/sys/gnu/i386/isa/dgm.c b/sys/gnu/i386/isa/dgm.c index 4a2ec53..3732302 100644 --- a/sys/gnu/i386/isa/dgm.c +++ b/sys/gnu/i386/isa/dgm.c @@ -208,16 +208,14 @@ struct isa_driver dgmdriver = { static d_open_t dgmopen; static d_close_t dgmclose; -static d_read_t dgmread; -static d_write_t dgmwrite; static d_ioctl_t dgmioctl; #define CDEV_MAJOR 101 static struct cdevsw dgm_cdevsw = { /* open */ dgmopen, /* close */ dgmclose, - /* read */ dgmread, - /* write */ dgmwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ dgmioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -1005,52 +1003,6 @@ wakeup((caddr_t)chan); } -static int -dgmread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgm_softc[unit].ttys[pnum]; - error=linesw[tp->t_line].l_read(tp, uio, flag); - DPRINT4(DB_RD,"dgm%d: port%d: read() returns %d\n",unit,pnum,error); - return error; -} - -static int -dgmwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - int error, unit, pnum; - - mynor=minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - - unit=MINOR_TO_UNIT(mynor); - pnum=MINOR_TO_PORT(mynor); - - tp=&dgm_softc[unit].ttys[pnum]; - - error=linesw[tp->t_line].l_write(tp, uio, flag); - DPRINT4(DB_WR,"dgm%d: port%d: write() returns %d\n",unit,pnum,error); - return error; -} - static void dgmpoll(unit_c) void *unit_c; diff --git a/sys/i386/isa/cx.c b/sys/i386/isa/cx.c index 1eeb42e..9240be5 100644 --- a/sys/i386/isa/cx.c +++ b/sys/i386/isa/cx.c @@ -85,8 +85,6 @@ static struct tty cx_tty [NCX*NCHAN]; /* tty data */ static d_open_t cxopen; static d_close_t cxclose; -static d_read_t cxread; -static d_write_t cxwrite; static d_ioctl_t cxioctl; #define CDEV_MAJOR 42 @@ -94,8 +92,8 @@ static d_ioctl_t cxioctl; struct cdevsw cx_cdevsw = { /* open */ cxopen, /* close */ cxclose, - /* read */ cxread, - /* write */ cxwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ cxioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -287,28 +285,6 @@ int cxclose (dev_t dev, int flag, int mode, struct proc *p) return (0); } -int cxread (dev_t dev, struct uio *uio, int flag) -{ - int unit = UNIT (dev); - struct tty *tp; - - if (unit == UNIT_CTL) - return (EIO); - tp = cxchan[unit]->ttyp; - return ((*linesw[tp->t_line].l_read) (tp, uio, flag)); -} - -int cxwrite (dev_t dev, struct uio *uio, int flag) -{ - int unit = UNIT (dev); - struct tty *tp; - - if (unit == UNIT_CTL) - return (EIO); - tp = cxchan[unit]->ttyp; - return ((*linesw[tp->t_line].l_write) (tp, uio, flag)); -} - int cxioctl (dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { int unit = UNIT (dev); diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c index 472544a..041b4dd 100644 --- a/sys/i386/isa/cy.c +++ b/sys/i386/isa/cy.c @@ -132,7 +132,6 @@ #define sioopen cyopen #define siopoll cypoll #define sioprobe cyprobe -#define sioread cyread #define siosettimeout cysettimeout #define siosetwater cysetwater #define comstop cystop @@ -367,7 +366,6 @@ struct isa_driver siodriver = { static d_open_t sioopen; static d_close_t sioclose; -static d_read_t sioread; static d_write_t siowrite; static d_ioctl_t sioioctl; @@ -375,7 +373,7 @@ static d_ioctl_t sioioctl; static struct cdevsw sio_cdevsw = { /* open */ sioopen, /* close */ sioclose, - /* read */ sioread, + /* read */ ttyread, /* write */ siowrite, /* ioctl */ sioioctl, /* poll */ ttypoll, @@ -940,22 +938,6 @@ comhardclose(com) } static int -sioread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int mynor; - struct tty *tp; - - mynor = minor(dev); - if (mynor & CONTROL_MASK) - return (ENODEV); - tp = com_addr(MINOR_TO_UNIT(mynor))->tp; - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -static int siowrite(dev, uio, flag) dev_t dev; struct uio *uio; diff --git a/sys/i386/isa/istallion.c b/sys/i386/isa/istallion.c index c0c7f9f..88d6149 100644 --- a/sys/i386/isa/istallion.c +++ b/sys/i386/isa/istallion.c @@ -1076,11 +1076,9 @@ STATIC int stliclose(dev_t dev, int flag, int mode, struct proc *p) return(0); } -/*****************************************************************************/ STATIC int stliread(dev_t dev, struct uio *uiop, int flag) { - stliport_t *portp; #if DEBUG printf("stliread(dev=%s,uiop=%p,flag=%x)\n", devtoname(dev), @@ -1089,11 +1087,8 @@ STATIC int stliread(dev_t dev, struct uio *uiop, int flag) if (minor(dev) & STL_MEMDEV) return(stli_memrw(dev, uiop, flag)); - - portp = stli_dev2port(dev); - if (portp == (stliport_t *) NULL) - return(ENODEV); - return((*linesw[portp->tty.t_line].l_read)(&portp->tty, uiop, flag)); + else + return(ttyread(dev, uiop, flag)); } /*****************************************************************************/ @@ -1136,11 +1131,8 @@ STATIC int stliwrite(dev_t dev, struct uio *uiop, int flag) if (minor(dev) & STL_MEMDEV) return(stli_memrw(dev, uiop, flag)); - - portp = stli_dev2port(dev); - if (portp == (stliport_t *) NULL) - return(ENODEV); - return((*linesw[portp->tty.t_line].l_write)(&portp->tty, uiop, flag)); + else + return(ttywrite(dev, uiop, flag)); } /*****************************************************************************/ diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c index 601be1a..1d3936d 100644 --- a/sys/i386/isa/pcvt/pcvt_drv.c +++ b/sys/i386/isa/pcvt/pcvt_drv.c @@ -120,8 +120,6 @@ CONS_DRIVER(pc, pccnprobe, pccninit, pccnterm, pccngetc, pccncheckc, pccnputc); static d_open_t pcopen; static d_close_t pcclose; -static d_read_t pcread; -static d_write_t pcwrite; static d_ioctl_t pcioctl; static d_mmap_t pcmmap; @@ -129,8 +127,8 @@ static d_mmap_t pcmmap; static struct cdevsw pc_cdevsw = { /* open */ pcopen, /* close */ pcclose, - /* read */ pcread, - /* write */ pcwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ pcioctl, /* poll */ ttypoll, /* mmap */ pcmmap, @@ -571,28 +569,6 @@ pcclose(Dev_t dev, int flag, int mode, struct proc *p) } int -pcread(Dev_t dev, struct uio *uio, int flag) -{ - register struct tty *tp; - - if((tp = get_pccons(dev)) == NULL) - return ENXIO; - - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -pcwrite(Dev_t dev, struct uio *uio, int flag) -{ - register struct tty *tp; - - if((tp = get_pccons(dev)) == NULL) - return ENXIO; - - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - -int pcioctl(Dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { register int error; diff --git a/sys/i386/isa/rc.c b/sys/i386/isa/rc.c index 91b735e..f437eec 100644 --- a/sys/i386/isa/rc.c +++ b/sys/i386/isa/rc.c @@ -87,16 +87,14 @@ struct isa_driver rcdriver = { static d_open_t rcopen; static d_close_t rcclose; -static d_read_t rcread; -static d_write_t rcwrite; static d_ioctl_t rcioctl; #define CDEV_MAJOR 63 static struct cdevsw rc_cdevsw = { /* open */ rcopen, /* close */ rcclose, - /* read */ rcread, - /* write */ rcwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ rcioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -865,30 +863,6 @@ register struct rc_chans *rc; (void) splx(s); } -/* Read from line */ -static int -rcread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = rc_chans[GET_UNIT(dev)].rc_tp; - - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -/* Write to line */ -static int -rcwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct tty *tp = rc_chans[GET_UNIT(dev)].rc_tp; - - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - /* Reset the bastard */ static void rc_hwreset(unit, nec, chipid) register int unit, nec; diff --git a/sys/i386/isa/rp.c b/sys/i386/isa/rp.c index 5a4cceb..bc846d5 100644 --- a/sys/i386/isa/rp.c +++ b/sys/i386/isa/rp.c @@ -794,7 +794,6 @@ static char driver_name[] = "rp"; static d_open_t rpopen; static d_close_t rpclose; -static d_read_t rpread; static d_write_t rpwrite; static d_ioctl_t rpioctl; @@ -802,7 +801,7 @@ static d_ioctl_t rpioctl; static struct cdevsw rp_cdevsw = { /* open */ rpopen, /* close */ rpclose, - /* read */ rpread, + /* read */ ttyread, /* write */ rpwrite, /* ioctl */ rpioctl, /* poll */ ttypoll, @@ -856,9 +855,6 @@ static int rpparam __P((struct tty *, struct termios *)); static void rpstart __P((struct tty *)); static void rpstop __P((struct tty *, int)); static void rphardclose __P((struct rp_port *)); -#define rpmap nomap -#define rpreset noreset -#define rpstrategy nostrategy static void rp_disc_optim __P((struct tty *tp, struct termios *t, struct rp_port *rp)); @@ -1504,30 +1500,6 @@ rphardclose(struct rp_port *rp) static int -rpread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - struct rp_port *rp; - struct tty *tp; - int unit, mynor, umynor, port, error = 0; /* SG */ - - umynor = (((minor(dev) >> 16) -1) * 32); /* SG */ - port = (minor(dev) & 0x1f); /* SG */ - mynor = (port + umynor); /* SG */ - unit = minor_to_unit[mynor]; /* SG */ - - if(IS_CONTROL(dev)) - return(ENODEV); - rp = rp_addr(unit) + port; - tp = rp->rp_tty; - error = (*linesw[tp->t_line].l_read)(tp, uio, flag); - return(error); -} - -static -int rpwrite(dev, uio, flag) dev_t dev; struct uio *uio; diff --git a/sys/i386/isa/si.c b/sys/i386/isa/si.c index 79097ca..1de0aae 100644 --- a/sys/i386/isa/si.c +++ b/sys/i386/isa/si.c @@ -169,7 +169,6 @@ DATA_SET(eisadriver_set, si_eisa_driver); static d_open_t siopen; static d_close_t siclose; -static d_read_t siread; static d_write_t siwrite; static d_ioctl_t siioctl; @@ -177,7 +176,7 @@ static d_ioctl_t siioctl; static struct cdevsw si_cdevsw = { /* open */ siopen, /* close */ siclose, - /* read */ siread, + /* read */ ttyread, /* write */ siwrite, /* ioctl */ siioctl, /* poll */ ttypoll, @@ -1389,29 +1388,6 @@ sidtrwakeup(chan) splx(oldspl); } -/* - * User level stuff - read and write - */ -static int -siread(dev, uio, flag) - register dev_t dev; - struct uio *uio; - int flag; -{ - register struct tty *tp; - int mynor = minor(dev); - - if (IS_SPECIAL(mynor)) { - DPRINT((0, DBG_ENTRY|DBG_FAIL|DBG_READ, "siread(CONTROLDEV!!)\n")); - return(ENODEV); - } - tp = MINOR2TP(mynor); - DPRINT((TP2PP(tp), DBG_ENTRY|DBG_READ, - "siread(%s,%x,%x)\n", devtoname(dev), uio, flag)); - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - - static int siwrite(dev, uio, flag) dev_t dev; diff --git a/sys/i386/isa/stallion.c b/sys/i386/isa/stallion.c index 76e9119..4194878 100644 --- a/sys/i386/isa/stallion.c +++ b/sys/i386/isa/stallion.c @@ -438,8 +438,6 @@ static int stlattach(struct isa_device *idp); STATIC d_open_t stlopen; STATIC d_close_t stlclose; -STATIC d_read_t stlread; -STATIC d_write_t stlwrite; STATIC d_ioctl_t stlioctl; /* @@ -532,8 +530,8 @@ COMPAT_PCI_DRIVER (stlpci, stlpcidriver); static struct cdevsw stl_cdevsw = { /* open */ stlopen, /* close */ stlclose, - /* read */ stlread, - /* write */ stlwrite, + /* read */ ttyread, + /* write */ ttywrite, /* ioctl */ stlioctl, /* poll */ ttypoll, /* mmap */ nommap, @@ -898,23 +896,6 @@ STATIC int stlclose(dev_t dev, int flag, int mode, struct proc *p) /*****************************************************************************/ -STATIC int stlread(dev_t dev, struct uio *uiop, int flag) -{ - stlport_t *portp; - -#if DEBUG - printf("stlread(dev=%s,uiop=%p,flag=%x)\n", devtoname(dev), - (void *) uiop, flag); -#endif - - portp = stl_dev2port(dev); - if (portp == (stlport_t *) NULL) - return(ENODEV); - return((*linesw[portp->tty.t_line].l_read)(&portp->tty, uiop, flag)); -} - -/*****************************************************************************/ - #if VFREEBSD >= 220 STATIC void stl_stop(struct tty *tp, int rw) @@ -942,23 +923,6 @@ STATIC int stlstop(struct tty *tp, int rw) /*****************************************************************************/ -STATIC int stlwrite(dev_t dev, struct uio *uiop, int flag) -{ - stlport_t *portp; - -#if DEBUG - printf("stlwrite(dev=%s,uiop=%p,flag=%x)\n", devtoname(dev), - (void *) uiop, flag); -#endif - - portp = stl_dev2port(dev); - if (portp == (stlport_t *) NULL) - return(ENODEV); - return((*linesw[portp->tty.t_line].l_write)(&portp->tty, uiop, flag)); -} - -/*****************************************************************************/ - STATIC int stlioctl(dev_t dev, unsigned long cmd, caddr_t data, int flag, struct proc *p) { diff --git a/sys/kern/tty.c b/sys/kern/tty.c index e014e31..f311f76 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2440,5 +2440,34 @@ nottystop(tp, rw) struct tty *tp; int rw; { + return; } + +int +ttyread(dev, uio, flag) + dev_t dev; + struct uio *uio; + int flag; +{ + struct tty *tp; + + tp = dev->si_tty; + if (tp == NULL) + return (ENODEV); + return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); +} + +int +ttywrite(dev, uio, flag) + dev_t dev; + struct uio *uio; + int flag; +{ + struct tty *tp; + + tp = dev->si_tty; + if (tp == NULL) + return (ENODEV); + return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); +} diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c index 1e6f4e6..b3e2123 100644 --- a/sys/pc98/pc98/syscons.c +++ b/sys/pc98/pc98/syscons.c @@ -204,7 +204,6 @@ CONS_DRIVER(sc, sccnprobe, sccninit, sccnterm, sccngetc, sccncheckc, sccnputc); static d_open_t scopen; static d_close_t scclose; static d_read_t scread; -static d_write_t scwrite; static d_ioctl_t scioctl; static d_mmap_t scmmap; @@ -212,7 +211,7 @@ static struct cdevsw sc_cdevsw = { /* open */ scopen, /* close */ scclose, /* read */ scread, - /* write */ scwrite, + /* write */ ttywrite, /* ioctl */ scioctl, /* poll */ ttypoll, /* mmap */ scmmap, @@ -574,18 +573,9 @@ scclose(dev_t dev, int flag, int mode, struct proc *p) int scread(dev_t dev, struct uio *uio, int flag) { - struct tty *tp = dev->si_tty; sc_touch_scrn_saver(); - return((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -scwrite(dev_t dev, struct uio *uio, int flag) -{ - struct tty *tp = dev->si_tty; - - return((*linesw[tp->t_line].l_write)(tp, uio, flag)); + return(ttyread(dev, uio, flag)); } static int diff --git a/sys/sys/tty.h b/sys/sys/tty.h index 083ea2a..42ee9da 100644 --- a/sys/sys/tty.h +++ b/sys/sys/tty.h @@ -265,10 +265,12 @@ int ttyinput __P((int c, struct tty *tp)); int ttylclose __P((struct tty *tp, int flag)); int ttymodem __P((struct tty *tp, int flag)); int ttyopen __P((dev_t device, struct tty *tp)); +int ttyread __P((dev_t dev, struct uio *uio, int flag)); void ttyregister __P((struct tty *tp)); int ttysleep __P((struct tty *tp, void *chan, int pri, char *wmesg, int timeout)); int ttywait __P((struct tty *tp)); +int ttywrite __P((dev_t dev, struct uio *uio, int flag)); struct tty *ttymalloc __P((struct tty *tp)); void ttyfree __P((struct tty *)); |