diff options
author | Kyle McMartin <kmcmartin@redhat.com> | 2008-01-28 15:19:39 +0100 |
---|---|---|
committer | Danny Kukawka <danny.kukawka@web.de> | 2008-01-28 15:19:39 +0100 |
commit | 4541abd23fd02118a1a7f8b825aed338d2a5d638 (patch) | |
tree | 156dc48e78e4b3d6ecbe7371596f77125a579ac8 | |
parent | e3eb726da49a8cdc9e93905777a6e2d71ae878b3 (diff) |
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.
-rw-r--r-- | hald/linux/acpi.c | 13 | ||||
-rw-r--r-- | hald/linux/device.c | 7 | ||||
-rw-r--r-- | hald/linux/device.h | 1 |
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 |