hal: Branch 'origin' - 7 commits
David Zeuthen
david at fubar.dk
Wed Sep 27 09:36:35 PDT 2006
Hi,
Thanks for committing this. In the future please follow the guidelines
in HACKING
http://gitweb.freedesktop.org/?p=hal.git;a=blob;hb=HEAD;f=HACKING
on how to format the commit message. Using a standard format makes it a
breeze to use git-log, git-short-log to generate easy to view changes
suitable for e.g. RPM and/or DEB change logs. Thanks!
David
ps. We still need to fix the broken hal-commit mailing list trigger.
It's close to useless the messages it's sending out. But Danny raised
this already.
On Wed, 2006-09-27 at 09:29 -0700, Sjoerd Simons wrote:
> hald/linux/osspec.c | 89 +++++++++++++++++++++++++++++++++-----
> hald/linux/pmu.c | 3 -
> hald/linux/probing/probe-smbios.c | 9 ++-
> 3 files changed, 83 insertions(+), 18 deletions(-)
>
> New commits:
> diff-tree 99f0ef983dc8724680c3892d44ec9c20df0eae1f (from parents)
> Merge: 87aced5410449757026d61aee50d518976937806 40aa75e140eff9e2cfa22874a76badfbd126b6ec
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Wed Sep 27 18:27:09 2006 +0200
>
> Merge branch 'master' of ssh://git.freedesktop.org/git/hal
>
> diff-tree 87aced5410449757026d61aee50d518976937806 (from 05ef3a0f18b047834786fee087e2791ccf132917)
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Wed Sep 27 18:25:21 2006 +0200
>
> * Fix some code-style issues that David commented on
> * Check if the openfirmware.model string is actually set before using it.
>
> diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
> index e7f183e..2a998c3 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;
> diff-tree 05ef3a0f18b047834786fee087e2791ccf132917 (from parents)
> Merge: b83f4c83f60e8cf5da52a10e2546fef20053d25c 2ea340399bf8cf3d2bb6bd1b5c4ecbc2042e93d4
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Tue Sep 26 22:43:09 2006 +0200
>
> Merge branch 'master' of ssh://git.freedesktop.org/git/hal
>
> diff-tree b83f4c83f60e8cf5da52a10e2546fef20053d25c (from 80b89a74fe53fb036b5826fbea4ebec18d3378c8)
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Tue Sep 26 22:42:50 2006 +0200
>
> Read out model and compatible property out of openfirmware if possible. And use the openfirmware module property to decide what formfactor the system has.
>
> diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
> index 8aca683..a2a1998 100644
> --- a/hald/linux/osspec.c
> +++ b/hald/linux/osspec.c
> @@ -496,6 +496,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)
> {
> @@ -547,12 +609,12 @@ 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);
> } else {
> /* 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 */
> diff-tree 80b89a74fe53fb036b5826fbea4ebec18d3378c8 (from 7b4b27aa607baf38d1e8d8b38d748cff2e5210e3)
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Sun Sep 17 22:26:24 2006 +0200
>
> 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.
>
> diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
> index b9fb922..8aca683 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);
> @@ -554,11 +552,9 @@ 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 */
> computer_probing_helper_done (root);
> - }
> + }
> }
>
> DBusHandlerResult
> diff-tree 7b4b27aa607baf38d1e8d8b38d748cff2e5210e3 (from 0a14231944a194b6bc31b737ff9b0dbec91edebc)
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Sun Sep 17 21:57:11 2006 +0200
>
> Let probe-smbios only return successfully if it actually got something
> usefull to parse
>
> 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) {
> diff-tree 0a14231944a194b6bc31b737ff9b0dbec91edebc (from dbbb676c54531b04ea03a81769b24e6b4bf23166)
> Author: Sjoerd Simons <sjoerd at luon.net>
> Date: Sun Sep 17 20:25:25 2006 +0200
>
> 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.
>
> 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;
> _______________________________________________
> hal-commit mailing list
> hal-commit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/hal-commit
More information about the hal-commit
mailing list