Introduce ttyread() and ttywrite() which do the canonical thing.

Use them in many tty drivers.

Reviewed by: julian, bde
This commit is contained in:
Poul-Henning Kamp 1999-09-28 11:45:31 +00:00
parent 340b1ef545
commit 1ab305ef60
23 changed files with 70 additions and 597 deletions

View File

@ -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,
@ -160,28 +158,6 @@ promclose(dev, flag, mode, p)
return 0;
}
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;

View File

@ -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,
@ -302,20 +300,6 @@ zsclose(dev_t dev, int flag, int mode, struct proc *p)
return 0;
}
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)
{

View File

@ -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,
@ -939,22 +937,6 @@ comhardclose(com)
splx(s);
}
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;

View File

@ -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,
@ -939,22 +937,6 @@ comhardclose(com)
splx(s);
}
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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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));
@ -1502,30 +1498,6 @@ rphardclose(struct rp_port *rp)
wakeup(TSA_CARR_ON(tp));
}
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)

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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,
@ -939,22 +937,6 @@ comhardclose(com)
splx(s);
}
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;

View File

@ -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));
}
/*****************************************************************************/

View File

@ -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,
@ -570,28 +568,6 @@ pcclose(Dev_t dev, int flag, int mode, struct proc *p)
return(0);
}
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)
{

View File

@ -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;

View File

@ -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));
@ -1502,30 +1498,6 @@ rphardclose(struct rp_port *rp)
wakeup(TSA_CARR_ON(tp));
}
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)

View File

@ -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;

View File

@ -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)
{

View File

@ -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));
}

View File

@ -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

View File

@ -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 *));