diff --git a/sys/alpha/tlsb/zs_tlsb.c b/sys/alpha/tlsb/zs_tlsb.c index d2f89db3033f..0852724f0d3e 100644 --- a/sys/alpha/tlsb/zs_tlsb.c +++ b/sys/alpha/tlsb/zs_tlsb.c @@ -228,6 +228,7 @@ zs_cnattach(vm_offset_t base, vm_offset_t offset) zs_console_addr = (caddr_t) ALPHA_PHYS_TO_K0SEG(base + offset); sprintf(zs_consdev.cn_name, "zs0"); + zs_consdev.cn_unit = 0; zs_consdev.cn_pri = CN_NORMAL; make_dev(&zs_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "zs0"); cnadd(&zs_consdev); @@ -238,7 +239,7 @@ int zs_cngetc(struct consdev *cp) { int s = spltty(); - int c = zs_getc(zs_console_addr, minor(cp->cn_dev)); + int c = zs_getc(zs_console_addr, cp->cn_unit); splx(s); return c; } @@ -247,7 +248,7 @@ int zs_cncheckc(struct consdev *cp) { int s = spltty(); - int c = zs_maygetc(zs_console_addr, minor(cp->cn_dev)); + int c = zs_maygetc(zs_console_addr, cp->cn_unit); splx(s); return c; } @@ -256,7 +257,7 @@ void zs_cnputc(struct consdev *cp, int c) { int s = spltty(); - zs_putc(zs_console_addr, minor(cp->cn_dev), c); + zs_putc(zs_console_addr, cp->cn_unit, c); splx(s); } diff --git a/sys/dev/ofw/ofw_console.c b/sys/dev/ofw/ofw_console.c index b835dd13f038..920733a61d91 100644 --- a/sys/dev/ofw/ofw_console.c +++ b/sys/dev/ofw/ofw_console.c @@ -92,15 +92,16 @@ cn_drvinit(void *unused) { phandle_t options; char output[32]; + dev_t dev; - if (ofw_consdev.cn_dev != NULL) { + if (ofw_consdev.cn_pri != CN_DEAD) { if ((options = OF_finddevice("/options")) == -1 || OF_getprop(options, "output-device", output, sizeof(output)) == -1) return; - make_dev(&ofw_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "%s", + dev = make_dev(&ofw_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "%s", output); - make_dev_alias(ofw_consdev.cn_dev, "ofwcons"); + make_dev_alias(dev, "ofwcons"); } } @@ -275,7 +276,6 @@ ofw_cons_probe(struct consdev *cp) return; } - cp->cn_dev = NULL; cp->cn_pri = CN_INTERNAL; } diff --git a/sys/dev/sab/sab.c b/sys/dev/sab/sab.c index 4d86a5b53d7a..2eeb7f080490 100644 --- a/sys/dev/sab/sab.c +++ b/sys/dev/sab/sab.c @@ -1111,7 +1111,7 @@ sab_cnprobe(struct consdev *cn) cn->cn_pri = CN_DEAD; else { cn->cn_pri = CN_REMOTE; - cn->cn_dev = sc->sc_si; + strcpy(cn->cn_name, devtoname(sc->sc_si)); cn->cn_tp = sc->sc_tty; } } diff --git a/sys/dev/zs/zs.c b/sys/dev/zs/zs.c index c797b4ba6940..f3687ff68438 100644 --- a/sys/dev/zs/zs.c +++ b/sys/dev/zs/zs.c @@ -869,7 +869,7 @@ zs_cnprobe(struct consdev *cn) cn->cn_pri = CN_DEAD; else { cn->cn_pri = CN_REMOTE; - cn->cn_dev = sc->sc_si; + strcpy(cn->cn_name, devtoname(sc->sc_si)); cn->cn_tp = sc->sc_tty; } } diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index 10aeaffe7cb2..a8221a46585f 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -208,11 +208,6 @@ cnadd(struct consdev *cn) if (cnd->cnd_cn != NULL) return (ENOMEM); cnd->cnd_cn = cn; - if (cn->cn_name[0] == '\0' && cn->cn_dev != NULL) { - strcpy(cn->cn_name, devtoname(cn->cn_dev)); - /* XXX: it is unclear if/where this print might output */ - printf("NOTE: console \"%s\" didn't set name\n", cn->cn_name); - } if (cn->cn_name[0] == '\0') { /* XXX: it is unclear if/where this print might output */ printf("WARNING: console at %p has no name\n", cn); diff --git a/sys/pc98/cbus/sio.c b/sys/pc98/cbus/sio.c index 620735c3cce0..2ca08cbd28ec 100644 --- a/sys/pc98/cbus/sio.c +++ b/sys/pc98/cbus/sio.c @@ -3963,6 +3963,18 @@ struct siocnstate { u_char mcr; }; +/* + * This is a function in order to not replicate "ttyd%d" more + * places than absolutely necessary. + */ +static void +siocnset(struct consdev *cd, int unit) +{ + + cd->cn_unit = unit; + sprintf(cd->cn_name, "ttyd%d", unit); +} + #ifndef __alpha__ static speed_t siocngetspeed(Port_t, u_long rclk); #endif @@ -4185,7 +4197,7 @@ siocnprobe(cp) splx(s); if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) { - cp->cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(cp, unit); cp->cn_pri = COM_FORCECONSOLE(flags) || boothowto & RB_SERIAL ? CN_REMOTE : CN_NORMAL; @@ -4197,7 +4209,7 @@ siocnprobe(cp) siogdbiobase = iobase; siogdbunit = unit; #if DDB > 0 - gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(&gdbconsdev, unit); gdb_arg = &gdbconsdev; gdb_getc = siocngetc; gdb_putc = siocnputc; @@ -4219,7 +4231,7 @@ siocnprobe(cp) printf("configuration file (currently sio only).\n"); siogdbiobase = siocniobase; siogdbunit = siocnunit; - gdbconsdev.cn_dev = makedev(CDEV_MAJOR, siocnunit); + siocnset(&gdbconsdev, siocnunit); gdb_arg = &gdbconsdev; gdb_getc = siocngetc; gdb_putc = siocnputc; @@ -4232,7 +4244,7 @@ static void siocninit(cp) struct consdev *cp; { - comconsole = DEV_TO_UNIT(cp->cn_dev); + comconsole = cp->cn_unit; } static void @@ -4263,7 +4275,7 @@ siocnattach(port, speed) siocnunit = unit; comdefaultrate = speed; sio_consdev.cn_pri = CN_NORMAL; - sio_consdev.cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(&sio_consdev, unit); s = spltty(); @@ -4307,7 +4319,7 @@ siogdbattach(port, speed) printf("sio%d: gdb debugging port\n", unit); siogdbunit = unit; #if DDB > 0 - gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(&gdbconsdev, unit); gdb_arg = &gdbconsdev; gdb_getc = siocngetc; gdb_putc = siocnputc; @@ -4343,14 +4355,12 @@ static int siocncheckc(struct consdev *cd) { int c; - dev_t dev; Port_t iobase; int s; struct siocnstate sp; speed_t speed; - dev = cd->cn_dev; - if (minor(dev) == siocnunit) { + if (cd->cn_unit == siocnunit) { iobase = siocniobase; speed = comdefaultrate; } else { @@ -4368,19 +4378,16 @@ siocncheckc(struct consdev *cd) return (c); } - static int siocngetc(struct consdev *cd) { int c; - dev_t dev; Port_t iobase; int s; struct siocnstate sp; speed_t speed; - dev = cd->cn_dev; - if (minor(dev) == siocnunit) { + if (cd->cn_unit == siocnunit) { iobase = siocniobase; speed = comdefaultrate; } else { @@ -4402,13 +4409,11 @@ siocnputc(struct consdev *cd, int c) { int need_unlock; int s; - dev_t dev; struct siocnstate sp; Port_t iobase; speed_t speed; - dev = cd->cn_dev; - if (minor(dev) == siocnunit) { + if (cd->cn_unit == siocnunit) { iobase = siocniobase; speed = comdefaultrate; } else { diff --git a/sys/pc98/pc98/sio.c b/sys/pc98/pc98/sio.c index 620735c3cce0..2ca08cbd28ec 100644 --- a/sys/pc98/pc98/sio.c +++ b/sys/pc98/pc98/sio.c @@ -3963,6 +3963,18 @@ struct siocnstate { u_char mcr; }; +/* + * This is a function in order to not replicate "ttyd%d" more + * places than absolutely necessary. + */ +static void +siocnset(struct consdev *cd, int unit) +{ + + cd->cn_unit = unit; + sprintf(cd->cn_name, "ttyd%d", unit); +} + #ifndef __alpha__ static speed_t siocngetspeed(Port_t, u_long rclk); #endif @@ -4185,7 +4197,7 @@ siocnprobe(cp) splx(s); if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) { - cp->cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(cp, unit); cp->cn_pri = COM_FORCECONSOLE(flags) || boothowto & RB_SERIAL ? CN_REMOTE : CN_NORMAL; @@ -4197,7 +4209,7 @@ siocnprobe(cp) siogdbiobase = iobase; siogdbunit = unit; #if DDB > 0 - gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(&gdbconsdev, unit); gdb_arg = &gdbconsdev; gdb_getc = siocngetc; gdb_putc = siocnputc; @@ -4219,7 +4231,7 @@ siocnprobe(cp) printf("configuration file (currently sio only).\n"); siogdbiobase = siocniobase; siogdbunit = siocnunit; - gdbconsdev.cn_dev = makedev(CDEV_MAJOR, siocnunit); + siocnset(&gdbconsdev, siocnunit); gdb_arg = &gdbconsdev; gdb_getc = siocngetc; gdb_putc = siocnputc; @@ -4232,7 +4244,7 @@ static void siocninit(cp) struct consdev *cp; { - comconsole = DEV_TO_UNIT(cp->cn_dev); + comconsole = cp->cn_unit; } static void @@ -4263,7 +4275,7 @@ siocnattach(port, speed) siocnunit = unit; comdefaultrate = speed; sio_consdev.cn_pri = CN_NORMAL; - sio_consdev.cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(&sio_consdev, unit); s = spltty(); @@ -4307,7 +4319,7 @@ siogdbattach(port, speed) printf("sio%d: gdb debugging port\n", unit); siogdbunit = unit; #if DDB > 0 - gdbconsdev.cn_dev = makedev(CDEV_MAJOR, unit); + siocnset(&gdbconsdev, unit); gdb_arg = &gdbconsdev; gdb_getc = siocngetc; gdb_putc = siocnputc; @@ -4343,14 +4355,12 @@ static int siocncheckc(struct consdev *cd) { int c; - dev_t dev; Port_t iobase; int s; struct siocnstate sp; speed_t speed; - dev = cd->cn_dev; - if (minor(dev) == siocnunit) { + if (cd->cn_unit == siocnunit) { iobase = siocniobase; speed = comdefaultrate; } else { @@ -4368,19 +4378,16 @@ siocncheckc(struct consdev *cd) return (c); } - static int siocngetc(struct consdev *cd) { int c; - dev_t dev; Port_t iobase; int s; struct siocnstate sp; speed_t speed; - dev = cd->cn_dev; - if (minor(dev) == siocnunit) { + if (cd->cn_unit == siocnunit) { iobase = siocniobase; speed = comdefaultrate; } else { @@ -4402,13 +4409,11 @@ siocnputc(struct consdev *cd, int c) { int need_unlock; int s; - dev_t dev; struct siocnstate sp; Port_t iobase; speed_t speed; - dev = cd->cn_dev; - if (minor(dev) == siocnunit) { + if (cd->cn_unit == siocnunit) { iobase = siocniobase; speed = comdefaultrate; } else { diff --git a/sys/sys/cons.h b/sys/sys/cons.h index e4ecfb2c946e..19f66f9967e6 100644 --- a/sys/sys/cons.h +++ b/sys/sys/cons.h @@ -67,7 +67,6 @@ struct consdev { cn_dbctl_t *cn_dbctl; /* debugger control interface */ struct tty *cn_tp; /* tty structure for console device */ - dev_t cn_dev; /* major/minor of device */ short cn_pri; /* pecking order; the higher the better */ void *cn_arg; /* drivers method argument */ int cn_unit; /* some drivers prefer this */