From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>, Len Brown <lenb@kernel.org>,
"Kristen C. Accardi" <kristen.c.accardi@intel.com>
Subject: Re: [Update][PATCH] ACPI / PM: Export power states of ACPI devices via sysfs
Date: Mon, 21 Jan 2013 13:59:05 +0100 [thread overview]
Message-ID: <2154175.hki2a10WqW@vostro.rjw.lan> (raw)
In-Reply-To: <1982172.z1FZmGBJNL@vostro.rjw.lan>
On Saturday, January 19, 2013 09:53:32 PM Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Subject: ACPI / PM: Export power states of ACPI devices via sysfs
>
> Make it possible to retrieve the current power state of a device with
> ACPI power management from user space via sysfs by adding a new
> attribute power_state to the sysfs directory associated with the
> struct acpi_device object representing the device's ACPI node.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
>
> I've changed my mind here. It looks like it's more convenient to put the
> power_state attribute directly into the ACPI device node's directory in sysfs
> rather than into its power subdirectory.
Well, please scratch this, I'm dropping it for now.
I'll send a new version shortly along with the patches that export power
resources information.
Thanks,
Rafael
> ---
> Documentation/ABI/testing/sysfs-devices-power | 13 +++++++++++++
> drivers/acpi/scan.c | 25 ++++++++++++++++++++++++-
> 2 files changed, 37 insertions(+), 1 deletion(-)
>
> Index: linux-pm/drivers/acpi/scan.c
> ===================================================================
> --- linux-pm.orig/drivers/acpi/scan.c
> +++ linux-pm/drivers/acpi/scan.c
> @@ -184,6 +184,19 @@ err_out:
> }
> EXPORT_SYMBOL(acpi_bus_hot_remove_device);
>
> +static ssize_t power_state_show(struct device *dev,
> + struct device_attribute *attr, char *buf)
> +{
> + struct acpi_device *adev = to_acpi_device(dev);
> + int state;
> + int ret;
> +
> + ret = acpi_device_get_power(adev, &state);
> + return ret ? ret : sprintf(buf, "%s\n", acpi_power_state_string(state));
> +}
> +
> +static DEVICE_ATTR(power_state, 0444, power_state_show, NULL);
> +
> static ssize_t
> acpi_eject_store(struct device *d, struct device_attribute *attr,
> const char *buf, size_t count)
> @@ -375,8 +388,15 @@ static int acpi_device_setup_files(struc
> * hot-removal function from userland.
> */
> status = acpi_get_handle(dev->handle, "_EJ0", &temp);
> - if (ACPI_SUCCESS(status))
> + if (ACPI_SUCCESS(status)) {
> result = device_create_file(&dev->dev, &dev_attr_eject);
> + if (result)
> + goto end;
> + }
> +
> + if (dev->flags.power_manageable)
> + result = device_create_file(&dev->dev, &dev_attr_power_state);
> +
> end:
> return result;
> }
> @@ -386,6 +406,9 @@ static void acpi_device_remove_files(str
> acpi_status status;
> acpi_handle temp;
>
> + if (dev->flags.power_manageable)
> + device_remove_file(&dev->dev, &dev_attr_power_state);
> +
> /*
> * If device has _STR, remove 'description' file
> */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2013-01-21 12:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-04 21:58 [PATCH 0/6] ACPI / PM: ACPI power management update Rafael J. Wysocki
2013-01-04 22:00 ` [PATCH 1/6] ACPI / PM: Change the way power transitions to D3cold are carried out Rafael J. Wysocki
2013-01-05 2:37 ` Zheng, Lv
2013-01-04 22:01 ` [PATCH 2/6] ACPI / PM: More visible function for retrieving device power states Rafael J. Wysocki
2013-01-04 22:02 ` [PATCH 3/6] ACPI / PM: Common string representations of " Rafael J. Wysocki
2013-01-04 22:03 ` [PATCH 4/6] ACPI / PM: Export power states of ACPI devices via sysfs Rafael J. Wysocki
2013-01-19 20:53 ` [Update][PATCH] " Rafael J. Wysocki
2013-01-21 12:59 ` Rafael J. Wysocki [this message]
2013-01-04 22:03 ` [PATCH 5/6] ACPI / PM: Move device power management functions to device_pm.c Rafael J. Wysocki
2013-01-04 22:04 ` [PATCH 6/6] ACPI / PM: Consolidate suspend-specific and hibernate-specific code Rafael J. Wysocki
2013-01-11 21:59 ` [PATCH 0/6] ACPI / PM: ACPI power management update 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=2154175.hki2a10WqW@vostro.rjw.lan \
--to=rjw@sisk.pl \
--cc=kristen.c.accardi@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®