From 6f2fab737ba98cd2caa60b5c1be14cb9e9305317 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 13 Nov 2003 21:25:12 +0000 Subject: If the name of the mouse device starts with "/dev/ums", try to load the ums module, and allow for up to five attempts to open the device, with two-second pauses in between, to allow time for USB controllers and devices to probe and attach. My Gigabyte P4 Titan 848P motherboard has a total of 15 ports on four hubs hanging off four controllers, and needs at least half of that ten-second allowance to get ready. MFC after: 7 days --- usr.sbin/moused/moused.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 2cbfba3..e1c848e 100644 --- a/usr.sbin/moused/moused.c +++ b/usr.sbin/moused/moused.c @@ -501,6 +501,7 @@ main(int argc, char *argv[]) int c; int i; int j; + int retry; for (i = 0; i < MOUSE_MAXBUTTON; ++i) mstate[i] = &bstate[i]; @@ -751,14 +752,26 @@ main(int argc, char *argv[]) usage(); } + retry = 1; + if (strncmp(rodent.portname, "/dev/ums", 8) == 0) { + if (kldload("ums") == -1 && errno != EEXIST) + logerr(1, "unable to load USB mouse driver"); + retry = 5; + } + for (;;) { if (setjmp(env) == 0) { signal(SIGHUP, hup); signal(SIGINT , cleanup); signal(SIGQUIT, cleanup); signal(SIGTERM, cleanup); - if ((rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK, 0)) - == -1) + for (i = 0; i < retry; ++i) { + rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK); + if (rodent.mfd != -1 || errno != ENOENT) + break; + sleep(2); + } + if (rodent.mfd == -1) logerr(1, "unable to open %s", rodent.portname); if (r_identify() == MOUSE_PROTO_UNKNOWN) { logwarnx("cannot determine mouse type on %s", rodent.portname); -- cgit v1.1