All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@infradead.org>
To: Azael Avalos <coproscefalo@gmail.com>
Cc: platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/4] toshiba_acpi: Add support for USB Rapid Charge
Date: Sun, 18 Jan 2015 11:00:12 -0800	[thread overview]
Message-ID: <20150118190012.GG56582@vmdeb7> (raw)
In-Reply-To: <1421271621-8330-4-git-send-email-coproscefalo@gmail.com>

On Wed, Jan 14, 2015 at 02:40:20PM -0700, Azael Avalos wrote:
> Newer Toshiba laptops equipped with USB 3.0 ports now have the
> functionality of rapid charging devices connected to their USB hubs.
> 
> This patch adds support to use such feature by creating a sysfs entry
> named "usb_rapid_charge", accepting only two values, 0 to disable and
> one to enable, however, the machine needs a restart everytime the

s/one/1//

> function is toggled.
> 
> Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
> ---
>  drivers/platform/x86/toshiba_acpi.c | 107 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 107 insertions(+)
> 
> diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
> index 9e054c5..eba5f9e 100644
> --- a/drivers/platform/x86/toshiba_acpi.c
> +++ b/drivers/platform/x86/toshiba_acpi.c
> @@ -155,6 +155,7 @@ MODULE_LICENSE("GPL");
>  #define SCI_USB_CHARGE_BAT_LVL_OFF	0x1
>  #define SCI_USB_CHARGE_BAT_LVL_ON	0x4
>  #define SCI_USB_CHARGE_BAT_LVL		0x0200
> +#define SCI_USB_CHARGE_RAPID_DSP	0x0300
>  
>  struct toshiba_acpi_dev {
>  	struct acpi_device *acpi_dev;
> @@ -188,6 +189,7 @@ struct toshiba_acpi_dev {
>  	unsigned int eco_supported:1;
>  	unsigned int accelerometer_supported:1;
>  	unsigned int usb_sleep_charge_supported:1;
> +	unsigned int usb_rapid_charge_supported:1;
>  	unsigned int sysfs_created:1;
>  
>  	struct mutex mutex;
> @@ -874,6 +876,60 @@ static int toshiba_sleep_functions_status_set(struct toshiba_acpi_dev *dev,
>  	return 0;
>  }
>  
> +static int toshiba_usb_rapid_charge_get(struct toshiba_acpi_dev *dev,
> +					u32 *state)
> +{
> +	u32 in[TCI_WORDS] = { SCI_GET, SCI_USB_SLEEP_CHARGE, 0, 0, 0, 0 };
> +	u32 out[TCI_WORDS];
> +	acpi_status status;
> +
> +	if (!sci_open(dev))
> +		return -EIO;
> +
> +	in[5] = SCI_USB_CHARGE_RAPID_DSP;
> +	status = tci_raw(dev, in, out);
> +	sci_close(dev);
> +	if (ACPI_FAILURE(status) || out[0] == TOS_FAILURE) {
> +		pr_err("ACPI call to get USB S&C battery level failed\n");
> +		return -EIO;
> +	} else if (out[0] == TOS_NOT_SUPPORTED ||
> +		   out[0] == TOS_INPUT_DATA_ERROR) {
> +		pr_info("USB Sleep and Charge not supported\n");
> +		return -ENODEV;
> +	}
> +

Same comment on return codes.

Although, on looking through the existing driver, I only see EIO, and internally
consistency is important.... we can stick with EIO for this driver.
-- 
Darren Hart
Intel Open Source Technology Center

  reply	other threads:[~2015-01-18 19:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 21:40 [PATCH 0/4] toshiba_acpi: Add support for USB Sleep functions Azael Avalos
2015-01-14 21:40 ` [PATCH 1/4] toshiba_acpi: Add support for USB Sleep and Charge function Azael Avalos
2015-01-18 18:46   ` Darren Hart
2015-01-18 18:55   ` Darren Hart
2015-01-14 21:40 ` [PATCH 2/4] toshiba_acpi: Add support for USB Sleep functions under battery Azael Avalos
2015-01-18 18:54   ` Darren Hart
2015-01-14 21:40 ` [PATCH 3/4] toshiba_acpi: Add support for USB Rapid Charge Azael Avalos
2015-01-18 19:00   ` Darren Hart [this message]
2015-01-14 21:40 ` [PATCH 4/4] toshiba_acpi: Add support for USB Sleep and Music Azael Avalos
2015-01-18 19:07 ` [PATCH 0/4] toshiba_acpi: Add support for USB Sleep functions Darren Hart

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=20150118190012.GG56582@vmdeb7 \
    --to=dvhart@infradead.org \
    --cc=coproscefalo@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=platform-driver-x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.