lkml.org 
[lkml]   [2013]   [Jan]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [Update][PATCH] ACPI / PM: Export power states of ACPI devices via sysfs
Date
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.


\
 
 \ /
  Last update: 2013-01-21 14:21    [W:0.094 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site