Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-26 Thread Rafael J. Wysocki
On Sat, Feb 24, 2018 at 6:32 PM, Ognjen Galić  wrote:
> On Sat, Feb 24, 2018 at 10:07:20AM +0100, Rafael J. Wysocki wrote:
>> On Fri, Feb 23, 2018 at 6:21 PM, Andy Shevchenko
>>  wrote:
>> > On Sat, Feb 10, 2018 at 10:48 AM, Ognjen Galić  wrote:
>> >
>> >> Do you guys want me to send in another revision of the patch with some
>> >> documentation on the sysfs API?
>> >
>> > I noticed I didn't apply it because of some pending changes discussed,
>> > perhaps this one above.
>> >
>> > So, definitely please send a new version which addresses comments.
>>
>> No, it actually has been applied already.
>
> And also, how is it applied if it does not apply to 4.16-rc2 anymore?
> Do you need a new revision that solves the apply conflicts?
> Do you need a new revision that addresses the documentation?
> Did you apply it earlier than 4.16-rc2?
> When did you apply it?
> Did you apply it at all?

Yes, I did, on top of 4.16-rc2, and I might have rebased it a bit.

Please see linux-next and I will expose the acpi-battery branch
containing this series later today and tomorrow.

>> What is needed is a follow-up patch, but I'll write on that later.

Please see my previous message in this thread regarding the above.

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-24 Thread Ognjen Galić
On Sat, Feb 24, 2018 at 10:07:20AM +0100, Rafael J. Wysocki wrote:
> On Fri, Feb 23, 2018 at 6:21 PM, Andy Shevchenko
>  wrote:
> > On Sat, Feb 10, 2018 at 10:48 AM, Ognjen Galić  wrote:
> >
> >> Do you guys want me to send in another revision of the patch with some
> >> documentation on the sysfs API?
> >
> > I noticed I didn't apply it because of some pending changes discussed,
> > perhaps this one above.
> >
> > So, definitely please send a new version which addresses comments.
> 
> No, it actually has been applied already.

And also, how is it applied if it does not apply to 4.16-rc2 anymore? 
Do you need a new revision that solves the apply conflicts?
Do you need a new revision that addresses the documentation?
Did you apply it earlier than 4.16-rc2? 
When did you apply it? 
Did you apply it at all?

> 
> What is needed is a follow-up patch, but I'll write on that later.
> 
> Thanks,
> Rafael

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-24 Thread Rafael J. Wysocki
On Fri, Feb 23, 2018 at 6:21 PM, Andy Shevchenko
 wrote:
> On Sat, Feb 10, 2018 at 10:48 AM, Ognjen Galić  wrote:
>
>> Do you guys want me to send in another revision of the patch with some
>> documentation on the sysfs API?
>
> I noticed I didn't apply it because of some pending changes discussed,
> perhaps this one above.
>
> So, definitely please send a new version which addresses comments.

No, it actually has been applied already.

What is needed is a follow-up patch, but I'll write on that later.

Thanks,
Rafael

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-24 Thread Ognjen Galić
On Sat, Feb 24, 2018 at 10:07:20AM +0100, Rafael J. Wysocki wrote:
> On Fri, Feb 23, 2018 at 6:21 PM, Andy Shevchenko
>  wrote:
> > On Sat, Feb 10, 2018 at 10:48 AM, Ognjen Galić  wrote:
> >
> >> Do you guys want me to send in another revision of the patch with some
> >> documentation on the sysfs API?
> >
> > I noticed I didn't apply it because of some pending changes discussed,
> > perhaps this one above.
> >
> > So, definitely please send a new version which addresses comments.
> 
> No, it actually has been applied already.

So it has been queued up for 4.17?

If it has, that is awesome! Thanks!

> 
> What is needed is a follow-up patch, but I'll write on that later.
> 
> Thanks,
> Rafael

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-23 Thread Andy Shevchenko
On Sat, Feb 10, 2018 at 10:48 AM, Ognjen Galić  wrote:

> Do you guys want me to send in another revision of the patch with some
> documentation on the sysfs API?

I noticed I didn't apply it because of some pending changes discussed,
perhaps this one above.
So, definitely please send a new version which addresses comments.

-- 
With Best Regards,
Andy Shevchenko

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-10 Thread Ognjen Galić
On Fri, Feb 09, 2018 at 01:34:14PM +0100, Sebastian Reichel wrote:
> Hi,
> 
> On Fri, Feb 09, 2018 at 11:49:40AM +0100, Rafael J. Wysocki wrote:
> > On Fri, Feb 9, 2018 at 11:39 AM, Sebastian Reichel  wrote:
> > > Hi,
> > >
> > > On Fri, Feb 09, 2018 at 10:22:54AM +0100, Rafael J. Wysocki wrote:
> > >> On Thu, Feb 8, 2018 at 11:03 PM, Sebastian Reichel  
> > >> wrote:
> > >> > Hi,
> > >> >
> > >> > On Wed, Feb 07, 2018 at 03:58:44PM +0100, Ognjen Galic wrote:
> > >> >> 1) Charge start threshold
> > >> >> /sys/class/power_supply/BATN/charge_start_threshold
> > >> >>
> > >> >> Valid values are [0, 99]. A value of 0 turns off the
> > >> >> start threshold wear control.
> > >> >>
> > >> >> 2) Charge stop threshold
> > >> >> /sys/class/power_supply/BATN/charge_stop_threshold
> > >> >>
> > >> >> Valid values are [1, 100]. A value of 100 turns off
> > >> >> the stop threshold wear control. This must be
> > >> >> configured first.
> > >> >
> > >> > This is a new sysfs file, that should be documented.
> > >>
> > >> Right, I should have remembered about that, sorry.
> > >>
> > >> > Also this looks pretty generic. Just introduce new POWER_SUPPLY_PROP_
> > >> > entries for start/stop charging threshold and use them.
> > >>
> > >> What about doing this as a follow-up?
> > >
> > > Fine with me.
> > 
> > OK
> > 
> > Actually, I don't see any documentation whatever for ACPI battery and
> > AC power supply properties, so I guess that needs to be added in
> > general and I don't think it would be fair to ask Ognjen to do that in
> > order to get the extension in.
> > 
> > Why don't we pencil this in as work to do?
> 
> The generic ones are documented here:

Do you guys want me to send in another revision of the patch with some
documentation on the sysfs API?

> 
> Documentation/power/power_supply_class.txt
> 
> -- Sebastian



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-09 Thread Sebastian Reichel
Hi,

On Fri, Feb 09, 2018 at 11:49:40AM +0100, Rafael J. Wysocki wrote:
> On Fri, Feb 9, 2018 at 11:39 AM, Sebastian Reichel  wrote:
> > Hi,
> >
> > On Fri, Feb 09, 2018 at 10:22:54AM +0100, Rafael J. Wysocki wrote:
> >> On Thu, Feb 8, 2018 at 11:03 PM, Sebastian Reichel  wrote:
> >> > Hi,
> >> >
> >> > On Wed, Feb 07, 2018 at 03:58:44PM +0100, Ognjen Galic wrote:
> >> >> 1) Charge start threshold
> >> >> /sys/class/power_supply/BATN/charge_start_threshold
> >> >>
> >> >> Valid values are [0, 99]. A value of 0 turns off the
> >> >> start threshold wear control.
> >> >>
> >> >> 2) Charge stop threshold
> >> >> /sys/class/power_supply/BATN/charge_stop_threshold
> >> >>
> >> >> Valid values are [1, 100]. A value of 100 turns off
> >> >> the stop threshold wear control. This must be
> >> >> configured first.
> >> >
> >> > This is a new sysfs file, that should be documented.
> >>
> >> Right, I should have remembered about that, sorry.
> >>
> >> > Also this looks pretty generic. Just introduce new POWER_SUPPLY_PROP_
> >> > entries for start/stop charging threshold and use them.
> >>
> >> What about doing this as a follow-up?
> >
> > Fine with me.
> 
> OK
> 
> Actually, I don't see any documentation whatever for ACPI battery and
> AC power supply properties, so I guess that needs to be added in
> general and I don't think it would be fair to ask Ognjen to do that in
> order to get the extension in.
> 
> Why don't we pencil this in as work to do?

The generic ones are documented here:

Documentation/power/power_supply_class.txt

-- Sebastian


signature.asc
Description: PGP signature
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-09 Thread Rafael J. Wysocki
On Fri, Feb 9, 2018 at 11:39 AM, Sebastian Reichel  wrote:
> Hi,
>
> On Fri, Feb 09, 2018 at 10:22:54AM +0100, Rafael J. Wysocki wrote:
>> On Thu, Feb 8, 2018 at 11:03 PM, Sebastian Reichel  wrote:
>> > Hi,
>> >
>> > On Wed, Feb 07, 2018 at 03:58:44PM +0100, Ognjen Galic wrote:
>> >> 1) Charge start threshold
>> >> /sys/class/power_supply/BATN/charge_start_threshold
>> >>
>> >> Valid values are [0, 99]. A value of 0 turns off the
>> >> start threshold wear control.
>> >>
>> >> 2) Charge stop threshold
>> >> /sys/class/power_supply/BATN/charge_stop_threshold
>> >>
>> >> Valid values are [1, 100]. A value of 100 turns off
>> >> the stop threshold wear control. This must be
>> >> configured first.
>> >
>> > This is a new sysfs file, that should be documented.
>>
>> Right, I should have remembered about that, sorry.
>>
>> > Also this looks pretty generic. Just introduce new POWER_SUPPLY_PROP_
>> > entries for start/stop charging threshold and use them.
>>
>> What about doing this as a follow-up?
>
> Fine with me.

OK

Actually, I don't see any documentation whatever for ACPI battery and
AC power supply properties, so I guess that needs to be added in
general and I don't think it would be fair to ask Ognjen to do that in
order to get the extension in.

Why don't we pencil this in as work to do?

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-09 Thread Henrique de Moraes Holschuh
Acked-by: Henrique de Moraes Holschuh 

-- 
  Henrique Holschuh

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-09 Thread Sebastian Reichel
Hi,

On Fri, Feb 09, 2018 at 10:22:54AM +0100, Rafael J. Wysocki wrote:
> On Thu, Feb 8, 2018 at 11:03 PM, Sebastian Reichel  wrote:
> > Hi,
> >
> > On Wed, Feb 07, 2018 at 03:58:44PM +0100, Ognjen Galic wrote:
> >> 1) Charge start threshold
> >> /sys/class/power_supply/BATN/charge_start_threshold
> >>
> >> Valid values are [0, 99]. A value of 0 turns off the
> >> start threshold wear control.
> >>
> >> 2) Charge stop threshold
> >> /sys/class/power_supply/BATN/charge_stop_threshold
> >>
> >> Valid values are [1, 100]. A value of 100 turns off
> >> the stop threshold wear control. This must be
> >> configured first.
> >
> > This is a new sysfs file, that should be documented.
> 
> Right, I should have remembered about that, sorry.
> 
> > Also this looks pretty generic. Just introduce new POWER_SUPPLY_PROP_
> > entries for start/stop charging threshold and use them.
> 
> What about doing this as a follow-up?

Fine with me.

-- Sebastian


signature.asc
Description: PGP signature
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-09 Thread Rafael J. Wysocki
On Thu, Feb 8, 2018 at 11:03 PM, Sebastian Reichel  wrote:
> Hi,
>
> On Wed, Feb 07, 2018 at 03:58:44PM +0100, Ognjen Galic wrote:
>> 1) Charge start threshold
>> /sys/class/power_supply/BATN/charge_start_threshold
>>
>> Valid values are [0, 99]. A value of 0 turns off the
>> start threshold wear control.
>>
>> 2) Charge stop threshold
>> /sys/class/power_supply/BATN/charge_stop_threshold
>>
>> Valid values are [1, 100]. A value of 100 turns off
>> the stop threshold wear control. This must be
>> configured first.
>
> This is a new sysfs file, that should be documented.

Right, I should have remembered about that, sorry.

> Also this looks pretty generic. Just introduce new POWER_SUPPLY_PROP_
> entries for start/stop charging threshold and use them.

What about doing this as a follow-up?

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel


Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-08 Thread Sebastian Reichel
Hi,

On Wed, Feb 07, 2018 at 03:58:44PM +0100, Ognjen Galic wrote:
> 1) Charge start threshold
> /sys/class/power_supply/BATN/charge_start_threshold
> 
> Valid values are [0, 99]. A value of 0 turns off the
> start threshold wear control.
> 
> 2) Charge stop threshold
> /sys/class/power_supply/BATN/charge_stop_threshold
> 
> Valid values are [1, 100]. A value of 100 turns off
> the stop threshold wear control. This must be
> configured first.

This is a new sysfs file, that should be documented. Also this
looks pretty generic. Just introduce new POWER_SUPPLY_PROP_
entries for start/stop charging threshold and use them.

-- Sebastian

> Signed-off-by: Ognjen Galic 
> ---
> 
> Notes:
> v2:
> * Re-write the patch to make the changes in
> battery.c generic as suggested by Rafael
> 
> v3:
> * Fixed a bug where you could not set the stop
> threshold to 100% when the start threshold is 0%
> * Fixed the "Not Charging" quirk to match Lenovo's
> BIOS Firmware specification
> 
> v4:
> * Fixed a bug where you could not set the start
> threshold to >stop if stop was 100%
> 
> v5:
> * Migrated from symbol_get to native linking,
> to fix module dependencies
> * Fixed a bug where unloading the module would
> cause a BUG inside battery
> * Fixed a bug where you could unload battery
> before unloading thinkpad_acpi
> 
> v6:
> * Fixed all the style and naming issues pointed
> out by Andy Shevchenko
> 
> v7:
> * No changes in this patch in v7
> 
> v8:
> * No changes in this patch in v8
> 
> v9:
> * Use DEVICE_ATTR_RW instead of DEVICE_ATTR
> * Use bitopts.h instead of raw operators
> * Remove redundant whitespaces
> * Remove redundant comments
> * Move the power_supply changes to separate patch
> * Fix other various styling issues pointed out by
> Andy Shevchenko
> 
> v10:
> * Fix a pasting error from v6 that prevents the setting
> of the start threshold with EINVAL
> 
> v11:
> * Fix formatting of changelog
> 
> v12:
> * Remove most whitespaces between ifs
> * Change int to acpi_status in tpacpi_battery_acpi_eval
> 
> v13:
> * Change if (!tpacpi_... to if ACPI_FAILURE(...
> 
>  drivers/platform/x86/Kconfig |   1 +
>  drivers/platform/x86/thinkpad_acpi.c | 389 
> ++-
>  2 files changed, 389 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 9a8f96465..0d13d30c1 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -425,6 +425,7 @@ config SURFACE3_WMI
>  config THINKPAD_ACPI
>   tristate "ThinkPad ACPI Laptop Extras"
>   depends on ACPI
> + depends on ACPI_BATTERY
>   depends on INPUT
>   depends on RFKILL || RFKILL = n
>   depends on ACPI_VIDEO || ACPI_VIDEO = n
> diff --git a/drivers/platform/x86/thinkpad_acpi.c 
> b/drivers/platform/x86/thinkpad_acpi.c
> index d5eaf3b1e..1c57ee2b6 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -23,7 +23,7 @@
>  
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
> -#define TPACPI_VERSION "0.25"
> +#define TPACPI_VERSION "0.26"
>  #define TPACPI_SYSFS_VERSION 0x03
>  
>  /*
> @@ -66,6 +66,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -78,11 +79,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  /* ThinkPad CMOS commands */
> @@ -335,6 +338,7 @@ static struct {
>   u32 sensors_pdev_attrs_registered:1;
>   u32 hotkey_poll_active:1;
>   u32 has_adaptive_kbd:1;
> + u32 battery:1;
>  } tp_features;
>  
>  static struct {
> @@ -9209,6 +9213,385 @@ static struct ibm_struct mute_led_driver_data = {
>   .resume = mute_led_resume,
>  };
>  
> +/*
> + * Battery Wear Control Driver
> + * Contact: Ognjen Galic 
> + */
> +
> +/* Metadata */
> +
> +#define GET_START"BCTG"
> +#define SET_START"BCCS"
> +#define GET_STOP "BCSG"
> +#define SET_STOP "BCSS"
> +
> +#define START_ATTR "charge_start_threshold"
> +#define STOP_ATTR  "charge_stop_threshold"
> +
> +enum {
> + BAT_ANY = 0,
> + BAT_PRIMARY = 1,
> + BAT_SECONDARY = 2
> +};
> +
> +enum {
> + /* Error condition bit */
> + METHOD_ERR = BIT(31),
> +};
> +
> +enum {
> + /* This is used in the get/set helpers */
> + THRESHOLD_START,
> + THRESHOLD_STOP,
> +};
> +
> +struct tpacpi_battery_data {
> + int charge_start;
> + int start_support;
> + int charge_stop;
> + int stop_support;
> +};
> +
> +struct tpacpi_battery_driver_data {
> + struct tpacpi_battery_data batteries[3];
> + int individual_addressing;
> +};
> +
> +static struct tpacpi_battery_driver_data battery_info;
> +
> +/* ACPI hel

Re: [ibm-acpi-devel] [PATCH v13 3/4] thinkpad_acpi: Add support for battery thresholds

2018-02-08 Thread Rafael J. Wysocki
On Wed, Feb 7, 2018 at 3:58 PM, Ognjen Galic  wrote:
> 1) Charge start threshold
> /sys/class/power_supply/BATN/charge_start_threshold
>
> Valid values are [0, 99]. A value of 0 turns off the
> start threshold wear control.
>
> 2) Charge stop threshold
> /sys/class/power_supply/BATN/charge_stop_threshold
>
> Valid values are [1, 100]. A value of 100 turns off
> the stop threshold wear control. This must be
> configured first.
>
> Signed-off-by: Ognjen Galic 

Andy, Darren, Henrique,

I'm assuming no concerns about this you from you, please let me know
if that's not correct.

> ---
>
> Notes:
> v2:
> * Re-write the patch to make the changes in
> battery.c generic as suggested by Rafael
>
> v3:
> * Fixed a bug where you could not set the stop
> threshold to 100% when the start threshold is 0%
> * Fixed the "Not Charging" quirk to match Lenovo's
> BIOS Firmware specification
>
> v4:
> * Fixed a bug where you could not set the start
> threshold to >stop if stop was 100%
>
> v5:
> * Migrated from symbol_get to native linking,
> to fix module dependencies
> * Fixed a bug where unloading the module would
> cause a BUG inside battery
> * Fixed a bug where you could unload battery
> before unloading thinkpad_acpi
>
> v6:
> * Fixed all the style and naming issues pointed
> out by Andy Shevchenko
>
> v7:
> * No changes in this patch in v7
>
> v8:
> * No changes in this patch in v8
>
> v9:
> * Use DEVICE_ATTR_RW instead of DEVICE_ATTR
> * Use bitopts.h instead of raw operators
> * Remove redundant whitespaces
> * Remove redundant comments
> * Move the power_supply changes to separate patch
> * Fix other various styling issues pointed out by
> Andy Shevchenko
>
> v10:
> * Fix a pasting error from v6 that prevents the setting
> of the start threshold with EINVAL
>
> v11:
> * Fix formatting of changelog
>
> v12:
> * Remove most whitespaces between ifs
> * Change int to acpi_status in tpacpi_battery_acpi_eval
>
> v13:
> * Change if (!tpacpi_... to if ACPI_FAILURE(...
>
>  drivers/platform/x86/Kconfig |   1 +
>  drivers/platform/x86/thinkpad_acpi.c | 389 
> ++-
>  2 files changed, 389 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 9a8f96465..0d13d30c1 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -425,6 +425,7 @@ config SURFACE3_WMI
>  config THINKPAD_ACPI
> tristate "ThinkPad ACPI Laptop Extras"
> depends on ACPI
> +   depends on ACPI_BATTERY
> depends on INPUT
> depends on RFKILL || RFKILL = n
> depends on ACPI_VIDEO || ACPI_VIDEO = n
> diff --git a/drivers/platform/x86/thinkpad_acpi.c 
> b/drivers/platform/x86/thinkpad_acpi.c
> index d5eaf3b1e..1c57ee2b6 100644
> --- a/drivers/platform/x86/thinkpad_acpi.c
> +++ b/drivers/platform/x86/thinkpad_acpi.c
> @@ -23,7 +23,7 @@
>
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> -#define TPACPI_VERSION "0.25"
> +#define TPACPI_VERSION "0.26"
>  #define TPACPI_SYSFS_VERSION 0x03
>
>  /*
> @@ -66,6 +66,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -78,11 +79,13 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>
>  /* ThinkPad CMOS commands */
> @@ -335,6 +338,7 @@ static struct {
> u32 sensors_pdev_attrs_registered:1;
> u32 hotkey_poll_active:1;
> u32 has_adaptive_kbd:1;
> +   u32 battery:1;
>  } tp_features;
>
>  static struct {
> @@ -9209,6 +9213,385 @@ static struct ibm_struct mute_led_driver_data = {
> .resume = mute_led_resume,
>  };
>
> +/*
> + * Battery Wear Control Driver
> + * Contact: Ognjen Galic 
> + */
> +
> +/* Metadata */
> +
> +#define GET_START  "BCTG"
> +#define SET_START  "BCCS"
> +#define GET_STOP   "BCSG"
> +#define SET_STOP   "BCSS"
> +
> +#define START_ATTR "charge_start_threshold"
> +#define STOP_ATTR  "charge_stop_threshold"
> +
> +enum {
> +   BAT_ANY = 0,
> +   BAT_PRIMARY = 1,
> +   BAT_SECONDARY = 2
> +};
> +
> +enum {
> +   /* Error condition bit */
> +   METHOD_ERR = BIT(31),
> +};
> +
> +enum {
> +   /* This is used in the get/set helpers */
> +   THRESHOLD_START,
> +   THRESHOLD_STOP,
> +};
> +
> +struct tpacpi_battery_data {
> +   int charge_start;
> +   int start_support;
> +   int charge_stop;
> +   int stop_support;
> +};
> +
> +struct tpacpi_battery_driver_data {
> +   struct tpacpi_battery_data batteries[3];
> +   int individual_addressing;
> +};
> +
> +static struct tpacpi_battery_driver_data battery_info;
> +
> +/* ACPI helpers/functions/probes */
> +
> +/**
> + * This evaluates a ACPI method call specific to the battery
> +