Re: [PATCH v2 2/2] eeepc-wmi: Add cpufv sysfs interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 12, 2010 at 1:47 AM,  <chris@xxxxxxxxxxxxxx> wrote:
> From: Chris Bagwell <chris@xxxxxxxxxxxxxx>
>
> eeepc-laptop provides a sysfs interface to read and control what it
> calls cpufv. ÂWhen WMI is enabled, the ACPI interface changes slightly
> and becames a write-only control with 3 valid values.
>
> Expose cpufv again to allow for user space utils that can extended battery
> life noticably and come a little closer to parity with eeepc-laptop.
>
> Write-only is OK for most user space apps because read status was
> mostly used to prevent unneeded mode changes. ÂSince this same check
> to ignore changes to same mode also exists in the DSDT then it was
> wasted ACPI call.
>
> acpi_osi="!Windows 2009" can be used for get back eeepc-laptop's
> read support of cpufv for debugging things such as behaviour
> during resume.
>
> This patch was tested with EEE PC 1005PE by monitoring powertop output while
> writing values of "0", "1", and "2" and by reviewing the decompiled DSDT of
> an 1201NL and comparing it to 1005PE's DSDT.
>
> Signed-off-by: Chris Bagwell <chris@xxxxxxxxxxxxxx>
> ---
> Âdrivers/platform/x86/eeepc-wmi.c | Â 51 ++++++++++++++++++++++++++++++++++++++
> Â1 files changed, 51 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/platform/x86/eeepc-wmi.c b/drivers/platform/x86/eeepc-wmi.c
> index 21df266..462ceab 100644
> --- a/drivers/platform/x86/eeepc-wmi.c
> +++ b/drivers/platform/x86/eeepc-wmi.c
> @@ -57,6 +57,7 @@ MODULE_ALIAS("wmi:"EEEPC_WMI_MGMT_GUID);
>
> Â#define EEEPC_WMI_METHODID_DEVS Â Â Â Â0x53564544
> Â#define EEEPC_WMI_METHODID_DSTS Â Â Â Â0x53544344
> +#define EEEPC_WMI_METHODID_CFVS Â Â Â Â0x53564643
>
> Â#define EEEPC_WMI_DEVID_BACKLIGHT Â Â Â0x00050012
>
> @@ -297,6 +298,49 @@ static void eeepc_wmi_notify(u32 value, void *context)
> Â Â Â Âkfree(obj);
> Â}
>
> +static int store_cpufv(struct device *dev, struct device_attribute *attr,
> + Â Â Â Â Â Â Â Â Â Â Âconst char *buf, size_t count)
> +{
> + Â Â Â int value;
> + Â Â Â struct acpi_buffer input = { (acpi_size)sizeof(value), &value };
> + Â Â Â acpi_status status;
> +
> + Â Â Â if (!count || sscanf(buf, "%i", &value) != 1)
> + Â Â Â Â Â Â Â return -EINVAL;
> + Â Â Â if (value < 0 || value > 2)
> + Â Â Â Â Â Â Â return -EINVAL;
> +
> + Â Â Â status = wmi_evaluate_method(EEEPC_WMI_MGMT_GUID,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â1, EEEPC_WMI_METHODID_CFVS, &input, NULL);
> +
> + Â Â Â if (ACPI_FAILURE(status))
> + Â Â Â Â Â Â Â return -EIO;
> + Â Â Â else
> + Â Â Â Â Â Â Â return count;
> +}
> +
> +static DEVICE_ATTR(cpufv, S_IRUGO | S_IWUSR, NULL, store_cpufv);
> +
> +static void eeepc_wmi_sysfs_exit(struct platform_device *device)
> +{
> + Â Â Â device_remove_file(&device->dev, &dev_attr_cpufv);
> +}
> +
> +static int eeepc_wmi_sysfs_init(struct platform_device *device)
> +{
> + Â Â Â int retval = -ENOMEM;
> +
> + Â Â Â retval = device_create_file(&device->dev, &dev_attr_cpufv);
> + Â Â Â if (retval)
> + Â Â Â Â Â Â Â goto error_sysfs;
> +
> + Â Â Â return 0;
> +
> +error_sysfs:
> + Â Â Â eeepc_wmi_sysfs_exit(platform_device);
> + Â Â Â return retval;
> +}
> +
> Âstatic int __devinit eeepc_wmi_platform_probe(struct platform_device *device)
> Â{
> Â Â Â Âstruct eeepc_wmi *eeepc;
> @@ -392,8 +436,14 @@ static int __init eeepc_wmi_init(void)
> Â Â Â Â Â Â Â Âgoto del_dev;
> Â Â Â Â}
>
> + Â Â Â err = eeepc_wmi_sysfs_init(platform_device);
> + Â Â Â if (err)
> + Â Â Â Â Â Â Â goto del_sysfs;
> +
> Â Â Â Âreturn 0;
>
> +del_sysfs:
> + Â Â Â eeepc_wmi_sysfs_exit(platform_device);
> Âdel_dev:
> Â Â Â Âplatform_device_del(platform_device);
> Âput_dev:
> @@ -408,6 +458,7 @@ static void __exit eeepc_wmi_exit(void)
> Â{
> Â Â Â Âstruct eeepc_wmi *eeepc;
>
> + Â Â Â eeepc_wmi_sysfs_exit(platform_device);
> Â Â Â Âeeepc = platform_get_drvdata(platform_device);
> Â Â Â Âplatform_driver_unregister(&platform_driver);
> Â Â Â Âplatform_device_unregister(platform_device);
> --
> 1.7.3.1
>
>

Seems ok.
Matthew, could you add that one for inclusion in 2.6.37 ?

Chris, could you document cpufv in
Documentation/ABI/testing/sysfs-platform-eeepc-wmi (see eeepc-laptop
example) ?
I don't think the lacking documentation should delay this patch because:
- most of platform-x86 are not documented at all
- the merge window is open, and we should'nt miss that.

Thanks,

-- 
Corentin Chary
http://xf.iksaif.net
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux