hal/hald/linux2 osspec.c,1.35,1.36

Richard Hughes hughsient at freedesktop.org
Fri Dec 2 09:06:55 PST 2005


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

Modified Files:
	osspec.c 
Log Message:
Add the new keys power_management.can_suspend and  power_management.can_hibernate

Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- osspec.c	15 Nov 2005 03:54:28 -0000	1.35
+++ osspec.c	2 Dec 2005 17:06:53 -0000	1.36
@@ -661,6 +661,40 @@
 	computer_probing_helper_done (d);
 }
 
+static void
+set_suspend_hibernate_keys (HalDevice *d)
+{
+	int can_suspend;
+	int can_hibernate;
+	unsigned int len;
+	char *poweroptions;
+	FILE *fp;
+
+	can_suspend = FALSE;
+	can_hibernate = FALSE;
+	fp = fopen ("/sys/power/state", "r");
+	if (fp == NULL) {
+		HAL_WARNING (("Could not open /sys/power/state"));
+		goto out;
+	}
+	poweroptions = NULL;
+	len = 0;
+	getline (&poweroptions, &len, fp);
+	fclose (fp);
+	if (poweroptions == NULL) {
+		HAL_WARNING (("Contents of /sys/power/state invalid"));
+		goto out;
+	}
+	if (strstr (poweroptions, "mem"))
+		can_suspend = TRUE;
+	if (strstr (poweroptions, "disk"))
+		can_hibernate = TRUE;
+	free (poweroptions);
+out:
+	hal_device_property_set_bool (d, "power_management.can_suspend_to_ram", can_suspend);
+	hal_device_property_set_bool (d, "power_management.can_suspend_to_disk", can_hibernate);
+}
+
 void 
 osspec_probe (void)
 {
@@ -708,8 +742,15 @@
 	}
 	HAL_INFO (("Done synthesizing events"));
 
-	/* TODO: add prober for PowerMac's */
+	/*
+	 * Populate the powermgmt keys according to the kernel options.
+	 * NOTE: This may not mean the machine is able to suspend
+	 *	 or hibernate successfully, only that the machine has
+	 *	 support compiled into the kernel.
+	 */
+	set_suspend_hibernate_keys (root);
 
+	/* TODO: add prober for PowerMac's */
 	if (should_decode_dmi) {
 		if (hal_util_helper_invoke ("hald-probe-smbios", NULL, root, NULL, NULL,
 					    computer_probing_pcbios_helper_done, 




More information about the hal-commit mailing list