summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2001-02-01 05:56:15 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2001-02-01 05:56:15 +0000
commitdf55735c0a02f94b736b8b773a8a76a64296836c (patch)
treea73f1dd7932e52e2df5bf82ebf59df09d796c584 /sys/dev
parent8e8d908c6c5754fd0205eb089e6c5822f92d4473 (diff)
Fix the wsmux_setmax() function. By the time wsmuxattach() runs (through hook
in ioconf.c created by the wsmux pseudo-device), an input device may have already attached itself as a mux. We don't want to whack these pointers. Net result: the PS/2 mouse on my laptop is now properly mux'd. Right now I have my laptop's builtin keyboard and builtin mouse (ps/2), plus I have attached a separate USB keyboard and USB mouse. All four devices are accepting input at the same time. If I want to go mobile, I can unhook the USB devices and my builtin devices will still work without changing X settings. Very cool.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/wscons/wsmux.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c
index c771a393242..eb7afb05428 100644
--- a/sys/dev/wscons/wsmux.c
+++ b/sys/dev/wscons/wsmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmux.c,v 1.3 2000/11/13 15:35:17 aaron Exp $ */
+/* $OpenBSD: wsmux.c,v 1.4 2001/02/01 05:56:14 aaron Exp $ */
/* $NetBSD: wsmux.c,v 1.9 2000/05/28 10:33:14 takemura Exp $ */
/*
@@ -110,20 +110,31 @@ wsmux_setmax(n)
int n;
{
int i;
+ struct wsmux_softc **wsmuxdevs_tmp = NULL;
if (n >= nwsmux) {
- i = nwsmux;
- nwsmux = n + 1;
- if (nwsmux != 0) {
- if (wsmuxdevs)
- free(wsmuxdevs, M_DEVBUF);
+ if (wsmuxdevs != NULL) {
+ wsmuxdevs_tmp = malloc(nwsmux * sizeof(*wsmuxdevs_tmp),
+ M_DEVBUF, M_NOWAIT);
+ if (wsmuxdevs_tmp == 0)
+ panic("wsmux_setmax: no mem\n");
+ for (i = 0; i < nwsmux; i++)
+ wsmuxdevs_tmp[i] = wsmuxdevs[i];
+ free(wsmuxdevs, M_DEVBUF);
}
- wsmuxdevs = malloc(nwsmux * sizeof (*wsmuxdevs),
- M_DEVBUF, M_NOWAIT);
+
+ wsmuxdevs = malloc(n + 1 * sizeof(*wsmuxdevs),
+ M_DEVBUF, M_NOWAIT);
if (wsmuxdevs == 0)
panic("wsmux_setmax: no memory\n");
- for (; i < nwsmux; i++)
+ for (; i < n + 1; i++)
wsmuxdevs[i] = 0;
+ if (wsmuxdevs_tmp != NULL) {
+ for (i = 0; i < nwsmux; i++)
+ wsmuxdevs[i] = wsmuxdevs_tmp[i];
+ free(wsmuxdevs_tmp, M_DEVBUF);
+ }
+ nwsmux = n + 1;
}
}