lkml.org 
[lkml]   [2015]   [Jan]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/4] toshiba_acpi: Add support for USB Sleep and Charge function
On Wed, Jan 14, 2015 at 02:40:18PM -0700, Azael Avalos wrote:
> Newer Toshiba models now come with a feature called Sleep and Charge,
> where the computer USB ports remain powered when the computer is
> asleep or turned off.
>
> This patch adds support to such feature, creating a sysfs entry
> called "usb_sleep_charge" to set the desired charging mode or to
> disable it.
>
> The sysfs entry accepts three parameters, 0x0, 0x9 and 0x21, beign
> disabled, alternate and auto respectively.
>
> Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
> ---
> drivers/platform/x86/toshiba_acpi.c | 112 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 112 insertions(+)
...

> +static ssize_t toshiba_usb_sleep_charge_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);
> + int state;
> + int ret;
> +
> + ret = kstrtoint(buf, 0, &state);
> + if (ret)
> + return ret;
> +
> + /* Set the USB charging mode where:
> + * 0x30000 - Disable
> + * 0x30009 - Alternate
> + * 0x30021 - Auto
> + */
> + state |= 0x30000;
> + if (state != SCI_USB_CHARGE_DISABLED && state != SCI_USB_CHARGE_AUTO &&
> + state != SCI_USB_CHARGE_ALTERNATE)
> + return -EINVAL;

Sorry, I missed this as the input validation on my first pass. Looks good.

--
Darren Hart
Intel Open Source Technology Center


\
 
 \ /
  Last update: 2015-01-18 20:21    [W:0.063 / U:0.348 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site