hal/hald/linux2 acpi.c,1.25,1.26

David Zeuthen david at freedesktop.org
Mon Aug 1 17:45:34 PDT 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv15699/hald/linux2

Modified Files:
	acpi.c 
Log Message:
2005-08-01  David Zeuthen  <davidz at redhat.com>

        * hald/linux2/acpi.c (acpi_poll): Only poll if the battery is actually
        present. Patch from Danny Kukawka <danny.kukawka at web.de>.
        (battery_refresh_poll): Be a little bit more
        careful and don't segfault if battery.reporting_unit doesn't exist



Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- acpi.c	1 Aug 2005 17:19:05 -0000	1.25
+++ acpi.c	2 Aug 2005 00:45:32 -0000	1.26
@@ -72,7 +72,7 @@
 
 	path = hal_device_property_get_string (d, "linux.acpi_path");
 	if (path == NULL)
-		return;
+		goto out;
 
 	hal_util_set_bool_elem_from_file (d, "battery.rechargeable.is_charging", path, 
 					  "state", "charging state", 0, "charging", TRUE);
@@ -97,12 +97,16 @@
 	/* get all the data we know */
 	reporting_unit = hal_device_property_get_string (d, 
 					"battery.reporting.unit");
+	if (reporting_unit == NULL)
+		goto out;
+
 	reporting_current = hal_device_property_get_int (d, 
 					"battery.reporting.current");
 	reporting_lastfull = hal_device_property_get_int (d, 
 					"battery.reporting.last_full");
 	reporting_rate = hal_device_property_get_int (d, 
 					"battery.reporting.rate");
+
 	/* 
 	 * we are converting the unknown units into mWh because of ACPI's nature
 	 * of not having a standard "energy" unit. 
@@ -157,6 +161,8 @@
 					     d->udi,
 					     mwh_current,
 					     mwh_lastfull));
+out:
+	;
 }
 
 static gboolean
@@ -486,7 +492,8 @@
 		HalDevice *d;
 		
 		d = HAL_DEVICE (i->data);
-		if (hal_device_has_property (d, "linux.acpi_type")) {
+		if (hal_device_has_property (d, "linux.acpi_type") &&
+		    hal_device_property_get_bool (d, "battery.present")) {
 			hal_util_grep_discard_existing_data ();
 			device_property_atomic_update_begin ();
 			battery_refresh_poll (d);




More information about the hal-commit mailing list