aboutsummaryrefslogtreecommitdiff
blob: 70e7767789a69d2b4733e01fb4c33dd93b96cfe6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
From 6c4bc8a7d166b952143fd1817b58baf5cc792536 Mon Sep 17 00:00:00 2001
From: Danny Kukawka <danny.kukawka@web.de>
Date: Mon, 11 Aug 2008 11:39:18 +0200
Subject: [PATCH 11/48] fix PMU battery and AC handling with power_supply

Fixed PMU battery and AC handling if they are exposed via the
power_supply interface. This prevents double the battery and AC
devices by handling the proc and sysfs interfaces.

Should fix fd.o bug #15482.
---
 hald/linux/pmu.c |   21 ++++++++++++++-------
 1 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/hald/linux/pmu.c b/hald/linux/pmu.c
index 71f94cf..6870d50 100644
--- a/hald/linux/pmu.c
+++ b/hald/linux/pmu.c
@@ -39,6 +39,7 @@
 
 #include "hotplug.h"
 #include "osspec_linux.h"
+#include "device.h"
 
 #include "pmu.h"
 
@@ -357,16 +358,18 @@ pmu_synthesize_hotplug_events (void)
 		pmu_synthesize_item ("/proc/pmu/info", PMU_TYPE_LAPTOP_PANEL);
 	}
 
-	/* setup timer for things that we need to poll */
+	if (!_have_sysfs_power_supply) {
+	  	/* setup timer for things that we need to poll */
 #ifdef HAVE_GLIB_2_14
-	g_timeout_add_seconds (PMU_POLL_INTERVAL,
-                               pmu_poll,
-                               NULL);
+		g_timeout_add_seconds (PMU_POLL_INTERVAL,
+                	               pmu_poll,
+                        	       NULL);
 #else
-	g_timeout_add (1000 * PMU_POLL_INTERVAL,
-		       pmu_poll,
-		       NULL);
+		g_timeout_add (1000 * PMU_POLL_INTERVAL,
+			       pmu_poll,
+			       NULL);
 #endif
+	}
 
 out:
 	return ret;
@@ -376,6 +379,10 @@ static HalDevice *
 pmu_generic_add (const gchar *pmu_path, HalDevice *parent, PMUDevHandler *handler)
 {
 	HalDevice *d;
+
+	if (((handler->pmu_type == PMU_TYPE_BATTERY) || (handler->pmu_type == PMU_TYPE_AC_ADAPTER)) && _have_sysfs_power_supply)
+		return NULL;
+
 	d = hal_device_new ();
 	hal_device_property_set_string (d, "linux.pmu_path", pmu_path);
 	hal_device_property_set_int (d, "linux.pmu_type", handler->pmu_type);
-- 
1.6.1.2