From: Len Brown <lenb@kernel.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Alan Stern <stern@rowland.harvard.edu>,
David Brownell <david-b@pacbell.net>,
Len Brown <len.brown@intel.com>,
Nigel Cunningham <nigel@nigel.suspend2.net>,
Pavel Machek <pavel@ucw.cz>, Shaohua Li <shaohua.li@intel.com>,
Johannes Berg <johannes@sipsolutions.net>,
Paul Mackerras <paulus@samba.org>,
Russell King <rmk@arm.linux.org.uk>
Subject: Re: [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine
Date: Sun, 22 Jul 2007 05:00:33 -0400 [thread overview]
Message-ID: <200707220500.33973.lenb@kernel.org> (raw)
In-Reply-To: <200707172240.27424.rjw@sisk.pl>
Ugh,
this breaks the build if CONFIG_ACPI_SLEEP=n
maybe it is time to delete the CONFIG_ACPI_SLEEP config option....
-Len
On Tuesday 17 July 2007 16:40, Rafael J. Wysocki wrote:
> From: Shaohua Li <shaohua.li@intel.com>, Rafael J. Wysocki <rjw@sisk.pl>
>
> Based on the David Brownell's patch at
> http://marc.info/?l=linux-acpi&m=117873972806360&w=2
>
> Add a helper routine returning the lowest power (highest number) ACPI device
> power state that given device can be in while the system is in the sleep state
> indicated by acpi_target_sleep_state .
>
> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Acked-by: Pavel Machek <pavel@ucw.cz>
> ---
> drivers/acpi/sleep/main.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++
> include/acpi/acpi_bus.h | 2 +
> 2 files changed, 77 insertions(+)
>
> Index: linux-2.6.22-git9/drivers/acpi/sleep/main.c
> ===================================================================
> --- linux-2.6.22-git9.orig/drivers/acpi/sleep/main.c
> +++ linux-2.6.22-git9/drivers/acpi/sleep/main.c
> @@ -255,6 +255,81 @@ static struct hibernation_ops acpi_hiber
> };
> #endif /* CONFIG_SOFTWARE_SUSPEND */
>
> +/**
> + * acpi_pm_device_sleep_state - return preferred power state of ACPI device
> + * in the system sleep state given by %acpi_target_sleep_state
> + * @dev: device to examine
> + * @wake: if set, the device should be able to wake up the system
> + * @d_min_p: used to store the upper limit of allowed states range
> + * Return value: preferred power state of the device on success, -ENODEV on
> + * failure (ie. if there's no 'struct acpi_device' for @dev)
> + *
> + * Find the lowest power (highest number) ACPI device power state that
> + * device @dev can be in while the system is in the sleep state represented
> + * by %acpi_target_sleep_state. If @wake is nonzero, the device should be
> + * able to wake up the system from this sleep state. If @d_min_p is set,
> + * the highest power (lowest number) device power state of @dev allowed
> + * in this system sleep state is stored at the location pointed to by it.
> + *
> + * The caller must ensure that @dev is valid before using this function.
> + * The caller is also responsible for figuring out if the device is
> + * supposed to be able to wake up the system and passing this information
> + * via @wake.
> + */
> +
> +int acpi_pm_device_sleep_state(struct device *dev, int wake, int *d_min_p)
> +{
> + acpi_handle handle = DEVICE_ACPI_HANDLE(dev);
> + struct acpi_device *adev;
> + char acpi_method[] = "_SxD";
> + unsigned long d_min, d_max;
> +
> + if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) {
> + printk(KERN_ERR "ACPI handle has no context!\n");
> + return -ENODEV;
> + }
> +
> + acpi_method[2] = '0' + acpi_target_sleep_state;
> + /*
> + * If the sleep state is S0, we will return D3, but if the device has
> + * _S0W, we will use the value from _S0W
> + */
> + d_min = ACPI_STATE_D0;
> + d_max = ACPI_STATE_D3;
> +
> + /*
> + * If present, _SxD methods return the minimum D-state (highest power
> + * state) we can use for the corresponding S-states. Otherwise, the
> + * minimum D-state is D0 (ACPI 3.x).
> + *
> + * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer
> + * provided -- that's our fault recovery, we ignore retval.
> + */
> + if (acpi_target_sleep_state > ACPI_STATE_S0)
> + acpi_evaluate_integer(handle, acpi_method, NULL, &d_min);
> +
> + /*
> + * If _PRW says we can wake up the system from the target sleep state,
> + * the D-state returned by _SxD is sufficient for that (we assume a
> + * wakeup-aware driver if wake is set). Still, if _SxW exists
> + * (ACPI 3.x), it should return the maximum (lowest power) D-state that
> + * can wake the system. _S0W may be valid, too.
> + */
> + if (acpi_target_sleep_state == ACPI_STATE_S0 ||
> + (wake && adev->wakeup.state.enabled &&
> + adev->wakeup.sleep_state <= acpi_target_sleep_state)) {
> + acpi_method[3] = 'W';
> + acpi_evaluate_integer(handle, acpi_method, NULL, &d_max);
> + /* Sanity check */
> + if (d_max < d_min)
> + d_min = d_max;
> + }
> +
> + if (d_min_p)
> + *d_min_p = d_min;
> + return d_max;
> +}
> +
> /*
> * Toshiba fails to preserve interrupts over S1, reinitialization
> * of 8259 is needed after S1 resume.
> Index: linux-2.6.22-git9/include/acpi/acpi_bus.h
> ===================================================================
> --- linux-2.6.22-git9.orig/include/acpi/acpi_bus.h
> +++ linux-2.6.22-git9/include/acpi/acpi_bus.h
> @@ -364,6 +364,8 @@ acpi_handle acpi_get_child(acpi_handle,
> acpi_handle acpi_get_pci_rootbridge_handle(unsigned int, unsigned int);
> #define DEVICE_ACPI_HANDLE(dev) ((acpi_handle)((dev)->archdata.acpi_handle))
>
> +int acpi_pm_device_sleep_state(struct device *, int, int *);
> +
> #endif /* CONFIG_ACPI */
>
> #endif /*__ACPI_BUS_H__*/
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
next prev parent reply other threads:[~2007-07-22 9:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-17 20:36 [Resend][PATCH 0/9] PM: Update global suspend and hibernation operations framework Rafael J. Wysocki
2007-07-17 20:40 ` [Resend][PATCH 1/9] ACPI: Implement the set_target() callback from pm_ops Rafael J. Wysocki
2007-07-18 0:02 ` Andrew Morton
2007-07-18 6:41 ` Rafael J. Wysocki
2007-07-19 2:05 ` Len Brown
2007-07-19 9:17 ` Rafael J. Wysocki
2007-07-21 19:26 ` David Brownell
2007-07-17 20:40 ` [Resend][PATCH 2/9] ACPI: Add acpi_pm_device_sleep_state helper routine Rafael J. Wysocki
2007-07-22 9:00 ` Len Brown [this message]
2007-07-17 20:42 ` [Resend][PATCH 3/9] PM: Move definition of struct pm_ops to suspend.h Rafael J. Wysocki
2007-07-17 20:43 ` [Resend][PATCH 4/9] PM: Rename struct pm_ops and related things Rafael J. Wysocki
2007-07-17 20:44 ` [Resend][PATCH 5/9] PM: Rework struct platform_suspend_ops Rafael J. Wysocki
2007-07-17 20:45 ` [Resend][PATCH 6/9] PM: Fix compilation of suspend code if CONFIG_PM is unset Rafael J. Wysocki
2007-07-17 20:46 ` [Resend][PATCH 7/9] PM: Make suspend_ops static Rafael J. Wysocki
2007-07-17 20:47 ` [Resend][PATCH 8/9] PM: Rework struct hibernation_ops Rafael J. Wysocki
2007-07-17 20:48 ` [Resend][PATCH 9/9] PM: Rename hibernation_ops to platform_hibernation_ops Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200707220500.33973.lenb@kernel.org \
--to=lenb@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david-b@pacbell.net \
--cc=johannes@sipsolutions.net \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nigel@nigel.suspend2.net \
--cc=paulus@samba.org \
--cc=pavel@ucw.cz \
--cc=rjw@sisk.pl \
--cc=rmk@arm.linux.org.uk \
--cc=shaohua.li@intel.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.