hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Mon Jan 28 06:19:46 PST 2008


 hald/linux/acpi.c   |   13 +++++++++++++
 hald/linux/device.c |    7 +++++++
 hald/linux/device.h |    1 +
 3 files changed, 21 insertions(+)

New commits:
commit 4541abd23fd02118a1a7f8b825aed338d2a5d638
Author: Kyle McMartin <kmcmartin at redhat.com>
Date:   Mon Jan 28 15:19:39 2008 +0100

    fix hal see same battery twice from sysfs and proc
    
    I've turned on both ACPI_PROCFS_POWER and ACPI_SYSFS_POWER in Fedora
    rawhide. With both options set, hal sees two battery devices, when it
    should really only check the second if the first doesn't exist.
    
    Fix this up by only checking procfs if we don't find anything in
    sysfs.

diff --git a/hald/linux/acpi.c b/hald/linux/acpi.c
index cc97f15..a1f0fdd 100644
--- a/hald/linux/acpi.c
+++ b/hald/linux/acpi.c
@@ -944,10 +944,23 @@ acpi_synthesize_hotplug_events (void)
 	return TRUE;
 }
 
+static gboolean
+is_power_supply(ACPIDevHandler *h)
+{
+	if (h && (h->acpi_type == ACPI_TYPE_BATTERY) ||
+	     (h->acpi_type == ACPI_TYPE_AC_ADAPTER))
+		return TRUE;
+	return FALSE;
+}
+
 static HalDevice *
 acpi_generic_add (const gchar *acpi_path, HalDevice *parent, ACPIDevHandler *handler)
 {
 	HalDevice *d;
+
+	if (is_power_supply(handler) && _have_sysfs_power_supply)
+		return NULL;
+
 	d = hal_device_new ();
 	hal_device_property_set_string (d, "linux.acpi_path", acpi_path);
 	hal_device_property_set_int (d, "linux.acpi_type", handler->acpi_type);
diff --git a/hald/linux/device.c b/hald/linux/device.c
index b55da25..5615b43 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3232,6 +3232,11 @@ power_supply_refresh (HalDevice *d)
 	return TRUE;
 }
 
+/* don't bother looking for /proc/acpi batteries if they're in
+ * sysfs.
+ */
+gboolean _have_sysfs_power_supply = FALSE;
+
 static HalDevice *
 power_supply_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *physdev,
 		  const gchar *sysfs_path_in_devices)
@@ -3282,6 +3287,8 @@ power_supply_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *
 		refresh_ac_adapter (d);
 		hal_device_add_capability (d, "ac_adapter");
 	}
+
+	_have_sysfs_power_supply = TRUE;
 finish:
 	return d;
 }
diff --git a/hald/linux/device.h b/hald/linux/device.h
index 1bd7286..4a7fd92 100644
--- a/hald/linux/device.h
+++ b/hald/linux/device.h
@@ -52,5 +52,6 @@ HotplugEvent *dev_generate_remove_hotplug_event (HalDevice *d);
 extern gboolean _have_sysfs_lid_button;
 extern gboolean _have_sysfs_power_button;
 extern gboolean _have_sysfs_sleep_button;
+extern gboolean _have_sysfs_power_supply;
 
 #endif


More information about the hal-commit mailing list