From owner-svn-src-all@FreeBSD.ORG  Mon Oct  1 05:57:49 2012
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
Delivered-To: svn-src-all@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id AC88C1065670;
	Mon,  1 Oct 2012 05:57:49 +0000 (UTC)
	(envelope-from hselasky@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 9679F8FC1A;
	Mon,  1 Oct 2012 05:57:49 +0000 (UTC)
Received: from svn.freebsd.org (localhost [127.0.0.1])
	by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q915vnmv091451;
	Mon, 1 Oct 2012 05:57:49 GMT (envelope-from hselasky@svn.freebsd.org)
Received: (from hselasky@localhost)
	by svn.freebsd.org (8.14.4/8.14.4/Submit) id q915vnBt091448;
	Mon, 1 Oct 2012 05:57:49 GMT (envelope-from hselasky@svn.freebsd.org)
Message-Id: <201210010557.q915vnBt091448@svn.freebsd.org>
From: Hans Petter Selasky <hselasky@FreeBSD.org>
Date: Mon, 1 Oct 2012 05:57:49 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r241085 - in stable/8: etc usr.sbin/moused
X-BeenThere: svn-src-all@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: "SVN commit messages for the entire src tree \(except for &quot;
	user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 01 Oct 2012 05:57:49 -0000

Author: hselasky
Date: Mon Oct  1 05:57:48 2012
New Revision: 241085
URL: http://svn.freebsd.org/changeset/base/241085

Log:
  MFC r233090 and r240891:
  The UMS module is now loaded by rules in /etc/devd/usb.conf.
  Improve moused when used with USB mouse devices.

Modified:
  stable/8/etc/devd.conf
  stable/8/usr.sbin/moused/moused.c
Directory Properties:
  stable/8/etc/   (props changed)
  stable/8/usr.sbin/   (props changed)
  stable/8/usr.sbin/moused/   (props changed)

Modified: stable/8/etc/devd.conf
==============================================================================
--- stable/8/etc/devd.conf	Mon Oct  1 05:48:46 2012	(r241084)
+++ stable/8/etc/devd.conf	Mon Oct  1 05:57:48 2012	(r241085)
@@ -114,14 +114,22 @@ detach 100 {
 	action "/etc/rc.d/syscons setkeyboard /dev/kbd0";
 };
 
-attach 100 {
-	device-name "ums[0-9]+";
-	action "/etc/rc.d/moused quietstart $device-name";
+notify 100 {
+	match "system" "DEVFS";
+	match "subsystem" "CDEV";
+	match "type" "CREATE";
+	match "cdev" "ums[0-9]+";
+
+	action "/etc/rc.d/moused quietstart $cdev";
 };
 
-detach 100 {
-        device-name "ums[0-9]+";
-        action "/etc/rc.d/moused stop $device-name";
+notify 100 {
+	match "system" "DEVFS";
+	match "subsystem" "CDEV";
+	match "type" "DESTROY";
+	match "cdev" "ums[0-9]+";
+
+	action "/etc/rc.d/moused stop $cdev";
 };
 
 # Firmware download into the ActiveWire board. After the firmware download is

Modified: stable/8/usr.sbin/moused/moused.c
==============================================================================
--- stable/8/usr.sbin/moused/moused.c	Mon Oct  1 05:48:46 2012	(r241084)
+++ stable/8/usr.sbin/moused/moused.c	Mon Oct  1 05:57:48 2012	(r241085)
@@ -408,6 +408,7 @@ static struct rodentparam {
     int cfd;			/* /dev/consolectl file descriptor */
     int mremsfd;		/* mouse remote server file descriptor */
     int mremcfd;		/* mouse remote client file descriptor */
+    int is_removable;		/* set if device is removable, like USB */
     long clickthreshold;	/* double click speed in msec */
     long button2timeout;	/* 3 button emulation timeout */
     mousehw_t hw;		/* mouse device hardware information */
@@ -434,6 +435,7 @@ static struct rodentparam {
     .cfd = -1,
     .mremsfd = -1,
     .mremcfd = -1,
+    .is_removable = 0,
     .clickthreshold = DFLT_CLICKTHRESHOLD,
     .button2timeout = DFLT_BUTTON2TIMEOUT,
     .accelx = 1.0,
@@ -564,15 +566,12 @@ static void	mremote_clientchg(int add);
 static int	kidspad(u_char rxc, mousestatus_t *act);
 static int	gtco_digipad(u_char, mousestatus_t *);
 
-static int	usbmodule(void);
-
 int
 main(int argc, char *argv[])
 {
     int c;
     int	i;
     int	j;
-    static int retry;
 
     for (i = 0; i < MOUSE_MAXBUTTON; ++i)
 	mstate[i] = &bstate[i];
@@ -878,11 +877,8 @@ main(int argc, char *argv[])
 	usage();
     }
 
-    retry = 1;
-    if (strncmp(rodent.portname, "/dev/ums", 8) == 0) {
-	if (usbmodule() != 0)
-	    retry = 5;
-    }
+    if (strncmp(rodent.portname, "/dev/ums", 8) == 0)
+	rodent.is_removable = 1;
 
     for (;;) {
 	if (setjmp(env) == 0) {
@@ -891,13 +887,8 @@ main(int argc, char *argv[])
 	    signal(SIGQUIT, cleanup);
 	    signal(SIGTERM, cleanup);
 	    signal(SIGUSR1, pause_mouse);
-	    for (i = 0; i < retry; ++i) {
-		if (i > 0)
-		    sleep(2);
-		rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
-		if (rodent.mfd != -1 || errno != ENOENT)
-		    break;
-	    }
+
+	    rodent.mfd = open(rodent.portname, O_RDWR | O_NONBLOCK);
 	    if (rodent.mfd == -1)
 		logerr(1, "unable to open %s", rodent.portname);
 	    if (r_identify() == MOUSE_PROTO_UNKNOWN) {
@@ -947,18 +938,14 @@ main(int argc, char *argv[])
 	if (rodent.cfd != -1)
 	    close(rodent.cfd);
 	rodent.mfd = rodent.cfd = -1;
+	if (rodent.is_removable)
+		exit(0);
     }
     /* NOT REACHED */
 
     exit(0);
 }
 
-static int
-usbmodule(void)
-{
-    return (kld_isloaded("uhub/ums") || kld_load("ums") != -1);
-}
-
 /*
  * Function to calculate linear acceleration.
  *