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 <coproscef...@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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to