From 308e62c2229a4f0298e3deac88ed1ce4969b90d9 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 11 Feb 2021 23:53:42 +0000 Subject: [PATCH] Don't hardcode com(4)'s major number in exuart(4). ok kettenis@ --- sys/dev/fdt/exuart.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/sys/dev/fdt/exuart.c b/sys/dev/fdt/exuart.c index 3887a76cc9d..0ea1381b8ff 100644 --- a/sys/dev/fdt/exuart.c +++ b/sys/dev/fdt/exuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exuart.c,v 1.4 2021/02/05 00:42:25 patrick Exp $ */ +/* $OpenBSD: exuart.c,v 1.5 2021/02/11 23:53:42 patrick Exp $ */ /* * Copyright (c) 2005 Dale Rahn * @@ -108,6 +108,7 @@ int exuart_intr(void *); /* XXX - we imitate 'com' serial ports and take over their entry points */ /* XXX: These belong elsewhere */ +cdev_decl(com); cdev_decl(exuart); struct cfdriver exuart_cd = { @@ -874,8 +875,6 @@ exuart_sc(dev_t dev) void exuartcnprobe(struct consdev *cp) { - cp->cn_dev = makedev(12 /* XXX */, 0); - cp->cn_pri = CN_MIDPRI; } void @@ -890,13 +889,21 @@ exuartcnattach(bus_space_tag_t iot, bus_addr_t iobase, int rate, tcflag_t cflag) NULL, NULL, exuartcngetc, exuartcnputc, exuartcnpollc, NULL, NODEV, CN_MIDPRI }; + int maj; if (bus_space_map(iot, iobase, 0x100, 0, &exuartconsioh)) return ENOMEM; + /* Look for major of com(4) to replace. */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == comopen) + break; + if (maj == nchrdev) + return ENXIO; + cn_tab = &exuartcons; - cn_tab->cn_dev = makedev(12 /* XXX */, 0); - cdevsw[12] = exuartdev; /* KLUDGE */ + cn_tab->cn_dev = makedev(maj, 0); + cdevsw[maj] = exuartdev; /* KLUDGE */ exuartconsiot = iot; exuartconsaddr = iobase; -- 2.20.1