hal/hald/linux2/addons addon-pmu.c,1.6,1.7

David Zeuthen david at kemper.freedesktop.org
Wed Feb 22 13:57:05 PST 2006


Update of /cvs/hal/hal/hald/linux2/addons
In directory kemper:/tmp/cvs-serv6540/hald/linux2/addons

Modified Files:
	addon-pmu.c 
Log Message:
2006-02-22  David Zeuthen  <davidz at redhat.com>

        * hald/linux2/addons/addon-pmu.c (main): Attached patch makes the
        addon-pmu work in blocking mode (thus open /dev/adb
        blocking). I've been running a little daemon on my system for some
        years that also does this without any problems, so it should be
        fine and makes the code somewhat nice imho. I've also removed some
        old dead code, don't think there is much use in keeping it around
        right? Patch from Sjoerd Simons <sjoerd at luon.net>.



Index: addon-pmu.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/addons/addon-pmu.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- addon-pmu.c	22 Feb 2006 21:10:06 -0000	1.6
+++ addon-pmu.c	22 Feb 2006 21:57:03 -0000	1.7
@@ -66,23 +66,8 @@
 
 	dbus_error_init (&error);
 
-#if 0
-	{
-		DBusConnection *conn;
-		if ((conn = dbus_bus_get (DBUS_BUS_SYSTEM, &error)) == NULL)
-			goto out;
-		
-		if ((ctx = libhal_ctx_new ()) == NULL)
-			goto out;
-		if (!libhal_ctx_set_dbus_connection (ctx, conn))
-			goto out;
-		if (!libhal_ctx_init (ctx, &error))
-			goto out;
-	}
-#else
 	if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
 		goto out;
-#endif
 
 	/* initial state */
 	if ((strstate = getenv ("HAL_PROP_BUTTON_STATE_VALUE")) == NULL) {
@@ -94,7 +79,7 @@
 	else
 		state = FALSE;
 
-	if ((fd = open ("/dev/adb", O_RDWR | O_NONBLOCK)) < 0) {
+	if ((fd = open ("/dev/adb", O_RDWR)) < 0) {
                 dbg ("Cannot open /dev/adb");
                 goto out;
 	}
@@ -108,14 +93,9 @@
 		buf[1] = PMU_GET_COVER;
 
 		n = write (fd, buf, 2);
-
-		usleep (100 * 1000);
-
 		if (n == 2) {
 			rd = read (fd, buf, sizeof (buf));
 			if (rd <= 0) {
-				if (errno == EAGAIN)
-					goto tryagain;
 				dbg ("Error reading from fd; read returned %d; err=%s", errno, strerror (errno));
 				goto out;
 			}
@@ -146,8 +126,7 @@
 
 			
 		}
-	tryagain:
-		usleep (900 * 1000);
+		usleep (1000 * 1000);
 	}
 
 




More information about the hal-commit mailing list