diff options
author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2003-11-13 21:25:12 +0000 |
---|---|---|
committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2003-11-13 21:25:12 +0000 |
commit | 49271db4a7f3d9e66aa5333df9f43fed6849573a (patch) | |
tree | f55cdade47a906dca7228f0859528d75674b2915 /usr.sbin/moused/moused.c | |
parent | 10e2a7db13c7719d21510160013c522257a3ceb2 (diff) | |
download | src-49271db4a7f3d9e66aa5333df9f43fed6849573a.tar.gz src-49271db4a7f3d9e66aa5333df9f43fed6849573a.zip |
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
Notes
Notes:
svn path=/head/; revision=122630
Diffstat (limited to 'usr.sbin/moused/moused.c')
-rw-r--r-- | usr.sbin/moused/moused.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/usr.sbin/moused/moused.c b/usr.sbin/moused/moused.c index 2cbfba3e5c1c..e1c848efa3da 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); |