Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > 26764e702e441b473525f6a16ac25557 > files > 29

hal-0.5.8.1-59.el5.src.rpm

commit d432770926e8cb95cc170ecd142ec2a319ed1d2f
Author: Sjoerd Simons <sjoerd@luon.net>
Date:   Sun Sep 17 21:57:11 2006 +0200

    Let probe-smbios only return succes when it has info
    
    Let probe-smbios only return successfully if it actually got something
    usefull to parse. Otherwise we're just checking the output for nothing.
    (cherry picked from 7b4b27aa607baf38d1e8d8b38d748cff2e5210e3 commit)

diff --git a/hald/linux/probing/probe-smbios.c b/hald/linux/probing/probe-smbios.c
index 2beb809..bb9ace3 100644
--- a/hald/linux/probing/probe-smbios.c
+++ b/hald/linux/probing/probe-smbios.c
@@ -140,7 +140,7 @@ main (int argc, char *argv[])
 		break;
 	case -1:
 		HAL_ERROR (("Cannot fork!"));
-		break;
+		goto out;
 	}
 	
 	/* parent continues from here */
@@ -199,6 +199,10 @@ main (int argc, char *argv[])
 		if (dmiparser_state == DMIPARSER_STATE_IGNORE)
 			continue;
 
+		/* return success only if there was something usefull to parse */
+		ret = 0;
+
+
 		/* removes the leading tab */
 		nbuf = &buf[1];
 
@@ -228,9 +232,6 @@ main (int argc, char *argv[])
 	/* as read to EOF, close */
 	fclose (f);
 
-	/* return success */
-	ret = 0;
-
 out:
 	/* free ctx */
 	if (ctx != NULL) {
commit 946edcebb99e8725e437d1915e0d5fb08093faa4
Author: Sjoerd Simons <sjoerd@luon.net>
Date:   Sun Sep 17 20:25:25 2006 +0200

    Set power_management.can_suspend to true for ppc systems using pmu
    
    Always set power_management.can_suspend to true if the power_management.type is
    pmu. Recent kernels don't report mem in /sys/power/state for ppc, but we have
    our own utility that issues ioctl's to suspend.
    (cherry picked from 0a14231944a194b6bc31b737ff9b0dbec91edebc commit)

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index ed762a8..b9fb922 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -475,6 +475,11 @@ set_suspend_hibernate_keys (HalDevice *d
 		can_hibernate = TRUE;
 	free (poweroptions);
 
+	if (!strcmp(hal_device_property_get_string(d, "power_management.type"), "pmu")) {
+		/* We got our own helper for suspend PMU machines */
+		can_suspend = TRUE;
+	}
+
 	/* check for the presence of suspend2 */
 	if (access ("/proc/software_suspend", F_OK) == 0)
 		can_hibernate = TRUE;
commit 0b6ef0ec9a040906515ed097c0a939a35f8dcfc3
Author: Sjoerd Simons <sjoerd@luon.net>
Date:   Tue Sep 26 22:42:50 2006 +0200

    Get some properties from openfirmware and use them to decide the formfactor
    
    Read out model and compatible property out of openfirmware if possible. And use the openfirmware model property to decide what formfactor the system has.
    (cherry picked from b83f4c83f60e8cf5da52a10e2546fef20053d25c commit)

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index b9fb922..cb767f6 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -498,6 +498,68 @@ out:
 	hal_device_property_set_bool (d, "power_management.can_suspend_to_disk", can_hibernate);
 }
 
+static void
+get_openfirmware_entry(HalDevice *d, char *property, char *entry, 
+                       gboolean multivalue) {
+	char *contents;
+	gsize length;
+	if (!g_file_get_contents(entry, &contents, &length, NULL)) {
+		return;
+	}
+	if (multivalue) {
+		gsize offset = 0;
+		while (offset < length) { 
+			hal_device_property_strlist_append(d, property, contents + offset);
+			for (; offset < length - 1 && contents[offset] != '\0'; offset++)
+				;
+			offset++;
+		}
+	} else {
+		hal_device_property_set_string(d, property, contents);
+	}
+	free(contents);
+}
+
+static void
+detect_openfirmware_formfactor(HalDevice *root) {
+	int x;
+	struct { gchar *model; gchar *formfactor; } model_formfactor[] =
+		{ 
+			{ "RackMac"   , "server" },
+			{ "AAPL,3400" , "laptop"  },
+			{ "AAPL,3500" , "laptop"  },
+			{ "PowerBook" , "laptop"  },
+			{ "AAPL"      , "desktop" },
+			{ "iMac"      , "desktop" },
+			{ "PowerMac"  , "desktop" },
+			{NULL, NULL }
+		};
+	const gchar *model =
+	  hal_device_property_get_string(root, "openfirmware.model");
+
+	for (x = 0 ; model_formfactor[x].model ; x++) {
+		if (strstr(model, model_formfactor[x].model)) {
+			hal_device_property_set_string (root, "system.formfactor",
+				model_formfactor[x].formfactor);
+			break;
+		}
+	}
+}
+
+static void
+probe_openfirmware(HalDevice *root) {
+#define DEVICE_TREE "/proc/device-tree/"
+	if (!g_file_test(DEVICE_TREE, G_FILE_TEST_IS_DIR)) {
+		return;
+	}
+	get_openfirmware_entry(root, "openfirmware.model", 
+		DEVICE_TREE "model", FALSE);
+	get_openfirmware_entry(root, "openfirmware.compatible", 
+		DEVICE_TREE "compatible", TRUE);
+	detect_openfirmware_formfactor(root);
+}
+
+
 void 
 osspec_probe (void)
 {
@@ -549,7 +611,6 @@ osspec_probe (void)
 	 */
 	set_suspend_hibernate_keys (root);
 
-	/* TODO: add prober for PowerMac's */
 	if (should_decode_dmi) {
 		hald_runner_run (root, "hald-probe-smbios", NULL, HAL_HELPER_TIMEOUT,
         	                 computer_probing_pcbios_helper_done, NULL, NULL);
@@ -557,6 +618,7 @@ osspec_probe (void)
 		/* set a default value, can be overridden by others */
 		hal_device_property_set_string (root, "system.formfactor", "unknown");
 		/* no probing */
+		probe_openfirmware(root);
 		computer_probing_helper_done (root);
   	}
 }
diff --git a/hald/linux/pmu.c b/hald/linux/pmu.c
index d2ce912..b43d5f0 100644
--- a/hald/linux/pmu.c
+++ b/hald/linux/pmu.c
@@ -381,9 +381,6 @@ pmu_synthesize_hotplug_events (void)
 		/* Add Laptop Panel */
 		snprintf (path, sizeof (path), "%s/pmu/info", get_hal_proc_path ());
 		pmu_synthesize_item (path, PMU_TYPE_LAPTOP_PANEL);
-
-		/* If the machine has got battery bays then this is a laptop. */
-		hal_device_property_set_string (computer, "system.formfactor", "laptop");
 	}
 
 	/* setup timer for things that we need to poll */
commit e29998967c7d687581c780cb973b03bba3d41e62
Author: Sjoerd Simons <sjoerd@luon.net>
Date:   Sun Sep 17 22:26:24 2006 +0200

    create one common fallback for system.formfactor
    
    Set system.formfactor fallback in exactly one place instead of three and be
    carefull not to override if already set. Fixes bug on macintosh powerpc
    machines where the detected value was overriden by the fallback.
    (cherry picked from 80b89a74fe53fb036b5826fbea4ebec18d3378c8 commit)

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index cb767f6..a2a1998 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -346,6 +346,10 @@ hotplug_queue_now_empty (void)
 static void
 computer_probing_helper_done (HalDevice *d)
 {
+	/* if not set, set a default value */
+	if (!hal_device_has_property (d, "system.formfactor")) {
+		hal_device_property_set_string (d, "system.formfactor", "unknown");
+	}
 	di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION);
 	di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY);
 
@@ -363,9 +367,6 @@ computer_probing_pcbios_helper_done (Hal
 	const char *system_version;
 
 	if (exit_type == HALD_RUN_FAILED) {
-		/* set a default value */
-		if (!hal_device_has_property (d, "system.formfactor"))
-			hal_device_property_set_string (d, "system.formfactor", "unknown");
 		goto out;
 	}
 
@@ -433,10 +434,7 @@ computer_probing_pcbios_helper_done (Hal
 				}
 			}
 		       
-		} else {
-			/* set a default value */
-			hal_device_property_set_string (d, "system.formfactor", "unknown");
-		}
+		} 
 	}
 out:
 	computer_probing_helper_done (d);
@@ -615,12 +613,10 @@ osspec_probe (void)
 		hald_runner_run (root, "hald-probe-smbios", NULL, HAL_HELPER_TIMEOUT,
         	                 computer_probing_pcbios_helper_done, NULL, NULL);
 	} else {
-		/* set a default value, can be overridden by others */
-		hal_device_property_set_string (root, "system.formfactor", "unknown");
 		/* no probing */
 		probe_openfirmware(root);
 		computer_probing_helper_done (root);
-  	}
+	}
 }
 
 DBusHandlerResult
commit 5cbbf1ca4fa93483373186c7a33eff02761137d8
Author: Sjoerd Simons <sjoerd@luon.net>
Date:   Wed Sep 27 18:25:21 2006 +0200

    check if openfirmware.model is set before using it
    
    Check if the openfirmware.model string is actually set before using it. Also
    fix some code style issues David commented on.
    (cherry picked from 87aced5410449757026d61aee50d518976937806 commit)

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index a2a1998..1b322bb 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -473,7 +473,7 @@ set_suspend_hibernate_keys (HalDevice *d
 		can_hibernate = TRUE;
 	free (poweroptions);
 
-	if (!strcmp(hal_device_property_get_string(d, "power_management.type"), "pmu")) {
+	if (strcmp(hal_device_property_get_string(d, "power_management.type"), "pmu") == 0) {
 		/* We got our own helper for suspend PMU machines */
 		can_suspend = TRUE;
 	}
@@ -498,7 +498,8 @@ out:
 
 static void
 get_openfirmware_entry(HalDevice *d, char *property, char *entry, 
-                       gboolean multivalue) {
+                       gboolean multivalue) 
+{
 	char *contents;
 	gsize length;
 	if (!g_file_get_contents(entry, &contents, &length, NULL)) {
@@ -519,7 +520,8 @@ get_openfirmware_entry(HalDevice *d, cha
 }
 
 static void
-detect_openfirmware_formfactor(HalDevice *root) {
+detect_openfirmware_formfactor(HalDevice *root) 
+{
 	int x;
 	struct { gchar *model; gchar *formfactor; } model_formfactor[] =
 		{ 
@@ -534,7 +536,8 @@ detect_openfirmware_formfactor(HalDevice
 		};
 	const gchar *model =
 	  hal_device_property_get_string(root, "openfirmware.model");
-
+	if (model == NULL) 
+		return;
 	for (x = 0 ; model_formfactor[x].model ; x++) {
 		if (strstr(model, model_formfactor[x].model)) {
 			hal_device_property_set_string (root, "system.formfactor",
@@ -545,7 +548,8 @@ detect_openfirmware_formfactor(HalDevice
 }
 
 static void
-probe_openfirmware(HalDevice *root) {
+probe_openfirmware(HalDevice *root) 
+{
 #define DEVICE_TREE "/proc/device-tree/"
 	if (!g_file_test(DEVICE_TREE, G_FILE_TEST_IS_DIR)) {
 		return;
commit 7c240196eae1cce8bf511dffaa7019e08383d1fb
Author: David Woodhouse <dwmw2@redhat.com>
Date:   Tue Oct 3 11:57:51 2006 -0400

    fix crash on PPC Pegasos that don't have PMU, ACPI or APM
    
    Also adds Pegasos to OF formfactor probing.
    (cherry picked from bc96ff3b760917f4431015d9782d3d70f8b337ea commit)

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 1b322bb..31ef498 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -448,6 +448,7 @@ set_suspend_hibernate_keys (HalDevice *d
 	ssize_t read;
 	size_t len;
 	char *poweroptions;
+	char *pmtype;
 	FILE *fp;
 
 	can_suspend = FALSE;
@@ -473,7 +474,8 @@ set_suspend_hibernate_keys (HalDevice *d
 		can_hibernate = TRUE;
 	free (poweroptions);
 
-	if (strcmp(hal_device_property_get_string(d, "power_management.type"), "pmu") == 0) {
+	pmtype = hal_device_property_get_string(d, "power_management.type");
+	if (pmtype != NULL && strcmp(pmtype, "pmu") == 0) {
 		/* We got our own helper for suspend PMU machines */
 		can_suspend = TRUE;
 	}
@@ -532,6 +534,7 @@ detect_openfirmware_formfactor(HalDevice
 			{ "AAPL"      , "desktop" },
 			{ "iMac"      , "desktop" },
 			{ "PowerMac"  , "desktop" },
+			{ "Pegasos"   , "desktop" },
 			{NULL, NULL }
 		};
 	const gchar *model =