summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hald/linux/acpi.c13
-rw-r--r--hald/linux/device.c7
-rw-r--r--hald/linux/device.h1
3 files changed, 21 insertions, 0 deletions
diff --git a/hald/linux/acpi.c b/hald/linux/acpi.c
index cc97f155..a1f0fdd9 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 b55da255..5615b438 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 1bd72868..4a7fd920 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