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 /sys/dev | |
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
Diffstat (limited to 'sys/dev')
-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 |
8 files changed, 13 insertions, 235 deletions
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 |