rpms/hal/OLPC-3 hal-battery-poll.patch, NONE, 1.1 hal.spec, 1.158, 1.159

Daniel Drake dsd at fedoraproject.org
Tue Sep 2 16:14:41 UTC 2008


Author: dsd

Update of /cvs/pkgs/rpms/hal/OLPC-3
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv21920

Modified Files:
	hal.spec 
Added Files:
	hal-battery-poll.patch 
Log Message:
Add patch to disable battery polling

hal-battery-poll.patch:

--- NEW FILE hal-battery-poll.patch ---
>From 3143949531e84213170039cbf6f0190c5060587c Mon Sep 17 00:00:00 2001
From: Daniel Drake <dsd at laptop.org>
Date: Mon, 4 Aug 2008 12:10:37 -0400
Subject: [PATCH] Don't poll batteries which provide notifications

Commit 7430beeb6c6f introduced mandatory polling for all batteries.
However, OLPC's battery does not require this - it provides interrupts
when battery charge level changes, and these notifications make it to
userspace and are successfully handled by HAL.

This patch makes HAL understand the "battery.change_notifications"
attribute which can be specified by fdi files. When true, HAL will not poll
the battery.

This is useful for OLPC because checking battery status is quite a heavy
operation and affects performance of some of our audio applications.
---
 hald/linux/device.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 72bff9c..9a88c97 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -77,6 +77,7 @@ gboolean _have_sysfs_lid_button = FALSE;
 gboolean _have_sysfs_power_button = FALSE;
 gboolean _have_sysfs_sleep_button = FALSE;
 gboolean _have_sysfs_power_supply = FALSE; 
+static gboolean battery_poll_running = FALSE;
 
 #define POWER_SUPPLY_BATTERY_POLL_INTERVAL 30  /* in seconds */
 #define DOCK_STATION_UNDOCK_POLL_INTERVAL 300  /* in milliseconds */
@@ -3381,6 +3382,7 @@ power_supply_battery_poll (gpointer data) {
 	GSList *i;
 	GSList *battery_devices;
 	HalDevice *d;
+	gboolean battery_polled = FALSE;
 
 	/* for now do it only for primary batteries and extend if neede for the other types */
 	battery_devices = hal_device_store_match_multiple_key_value_string (hald_get_gdl (),
@@ -3390,19 +3392,29 @@ power_supply_battery_poll (gpointer data) {
 	if (battery_devices) {
 		for (i = battery_devices; i != NULL; i = g_slist_next (i)) {
 			const char *subsys;
+			gboolean need_poll;
 
 			d = HAL_DEVICE (i->data);
+			/* we don't need to poll battery systems that provide change notifications */
+			need_poll = !hal_device_property_get_bool (d, "battery.change_notifications");
+			HAL_INFO(("need poll? %d", need_poll));
+			if (!need_poll)
+				continue;
+
 			subsys = hal_device_property_get_string (d, "info.subsystem");
 			if (subsys && (strcmp(subsys, "power_supply") == 0)) {
 				hal_util_grep_discard_existing_data();
 				device_property_atomic_update_begin ();
 				refresh_battery_fast(d);
 				device_property_atomic_update_end ();
+				battery_polled = TRUE;
 			}
 		}		
 	}
 	g_slist_free (battery_devices);
-	return TRUE;
+	battery_poll_running = battery_polled;
+	HAL_INFO(("$$$$$ BATTERY POLL HANDLER RETURNING %d", battery_polled));
+	return battery_polled;
 }
 
 static HalDevice *
@@ -3449,16 +3461,18 @@ power_supply_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *
 		hal_device_add_capability (d, "battery");
 
 		/* setup timer for things that we need to poll */
+		if (!battery_poll_running) {
 #ifdef HAVE_GLIB_2_14
-		g_timeout_add_seconds (POWER_SUPPLY_BATTERY_POLL_INTERVAL,
+			g_timeout_add_seconds (POWER_SUPPLY_BATTERY_POLL_INTERVAL,
+                                               power_supply_battery_poll,
+                                               NULL);
+#else
+			g_timeout_add (1000 * POWER_SUPPLY_BATTERY_POLL_INTERVAL,
                                        power_supply_battery_poll,
                                        NULL);
-#else
-		g_timeout_add (1000 * POWER_SUPPLY_BATTERY_POLL_INTERVAL,
-                               power_supply_battery_poll,
-                               NULL);
 #endif
-
+			battery_poll_running = TRUE;
+		}
 	}
 
 	if (is_ac_adapter == TRUE) {
-- 
1.5.5.1



Index: hal.spec
===================================================================
RCS file: /cvs/pkgs/rpms/hal/OLPC-3/hal.spec,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -r1.158 -r1.159
--- hal.spec	12 Jun 2008 14:37:34 -0000	1.158
+++ hal.spec	2 Sep 2008 16:14:11 -0000	1.159
@@ -26,12 +26,13 @@
 Summary: Hardware Abstraction Layer
 Name: hal
 Version: 0.5.11
-Release: 2%{?dist}
+Release: 2%{?dist}.1
 URL: http://www.freedesktop.org/Software/hal
 Source0: http://hal.freedesktop.org/releases/%{name}-%{version}.tar.gz
 Patch1: hal-0.5.10-set-property-direct.patch
 Patch2: hal-change-priority.patch
 Patch3: hal-cloexec.patch
+Patch4: hal-battery-poll.patch
 License: AFL or GPLv2
 Group: System Environment/Libraries
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 
@@ -128,6 +129,7 @@
 %patch1 -p1 -b .direct
 %patch2 -p1 -b .priority
 %patch3 -p1 -b .selinux-leak
+%patch4 -p1
 
 %build
 autoreconf
@@ -272,6 +274,9 @@
 %{_datadir}/gtk-doc/html/libhal-storage/*
 
 %changelog
+* Tue Sep  2 2008 Daniel Drake <dsd at laptop.org> - 0.5.11-2.1
+- Add patch to disable battery polling
+
 * Thu Jun 12 2008 Richard Hughes <rhughes at redhat.com> - 0.5.11-2
 - Fix unmounting of USB drives when using SELinux due to a leaking file
   descriptor (#447195)




More information about the fedora-extras-commits mailing list