* [PATCH] [PATCH] platform/x86: Add Battery Threshold support @ 2026-06-05 23:19 yahia 2026-06-08 12:35 ` Ilpo Järvinen 0 siblings, 1 reply; 6+ messages in thread From: yahia @ 2026-06-05 23:19 UTC (permalink / raw) To: hansg, ilpo.jarvinen; +Cc: platform-driver-x86, linux-kernel, yahia Hello, I aim in this patch to add support to Battery threshold via SBCT and GBCT acpi methods from the acpi table Signed-off-by: yahia <yahia.a.abdrabou@gmail.com> --- drivers/platform/x86/hp/hp-wmi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index f63bc00d9a9b..3d035ad9f03d 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -59,6 +59,8 @@ enum hp_ec_offsets { #define HP_POWER_LIMIT_DEFAULT 0x00 #define HP_POWER_LIMIT_NO_CHANGE 0xFF +#define HP_BATTERY_THRESHOLD_CAP 0x37 + #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required enum hp_thermal_profile_omen_v0 { @@ -448,6 +450,7 @@ static struct notifier_block platform_power_source_nb; static enum platform_profile_option active_platform_profile; static bool platform_profile_support; static bool zero_insize_support; +static bool battery_threshold_support; static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; @@ -1130,6 +1133,22 @@ static struct attribute *hp_wmi_attrs[] = { }; ATTRIBUTE_GROUPS(hp_wmi); +static int hp_battery_threshold_check(void) +{ + u8 buffer[128] = {0}; + int ret; + ret = hp_wmi_perform_query(HP_BATTERY_THRESHOLD_CAP, HPWMI_READ, buffer, 128, 128); + if (ret != 0) { + battery_threshold_support = false; + return -1; + } + if (buffer[28] == 0xAA) { + battery_threshold_support = true; + return 0; + } + return false; +} + static void hp_wmi_notify(union acpi_object *obj, void *context) { u32 event_id, event_data; @@ -2287,6 +2306,12 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) hp_wmi_rfkill2_setup(device); } + err = hp_battery_threshold_check(); + + if (err == 0) { + pr_info("Battery Threshold is supported"); + } + err = hp_wmi_hwmon_init(); if (err < 0) -- 2.54.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] [PATCH] platform/x86: Add Battery Threshold support 2026-06-05 23:19 [PATCH] [PATCH] platform/x86: Add Battery Threshold support yahia @ 2026-06-08 12:35 ` Ilpo Järvinen 2026-06-08 15:36 ` [PATCH v2] hp-wmi: add battery threshold support yahia 0 siblings, 1 reply; 6+ messages in thread From: Ilpo Järvinen @ 2026-06-08 12:35 UTC (permalink / raw) To: yahia; +Cc: Hans de Goede, platform-driver-x86, LKML On Sat, 6 Jun 2026, yahia wrote: Thanks for the patch. One PATCH is enough on the subject lines. :-) > Hello, > I aim in this patch to add support to > Battery threshold via SBCT and GBCT > acpi methods from the acpi table acpi -> ACPI Please write a proper changelog using imperative tone and real English sentences. Don't use "I" (or "we") nor "this patch" but start with the verb: Add support ... > > Signed-off-by: yahia <yahia.a.abdrabou@gmail.com> Please add also your surname before the email address. For more information, please see Documentation/process/submitting-patches.rst > --- > drivers/platform/x86/hp/hp-wmi.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c > index f63bc00d9a9b..3d035ad9f03d 100644 > --- a/drivers/platform/x86/hp/hp-wmi.c > +++ b/drivers/platform/x86/hp/hp-wmi.c > @@ -59,6 +59,8 @@ enum hp_ec_offsets { > #define HP_POWER_LIMIT_DEFAULT 0x00 > #define HP_POWER_LIMIT_NO_CHANGE 0xFF > > +#define HP_BATTERY_THRESHOLD_CAP 0x37 > + > #define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required > > enum hp_thermal_profile_omen_v0 { > @@ -448,6 +450,7 @@ static struct notifier_block platform_power_source_nb; > static enum platform_profile_option active_platform_profile; > static bool platform_profile_support; > static bool zero_insize_support; > +static bool battery_threshold_support; > > static struct rfkill *wifi_rfkill; > static struct rfkill *bluetooth_rfkill; > @@ -1130,6 +1133,22 @@ static struct attribute *hp_wmi_attrs[] = { > }; > ATTRIBUTE_GROUPS(hp_wmi); > > +static int hp_battery_threshold_check(void) > +{ > + u8 buffer[128] = {0}; = {}; is enough to initialize it. > + int ret; Add an empty line after local vars. > + ret = hp_wmi_perform_query(HP_BATTERY_THRESHOLD_CAP, HPWMI_READ, buffer, 128, 128); sizeof(buffer) > + if (ret != 0) { > + battery_threshold_support = false; battery_threshold_support is initialized to false so do you need this? > + return -1; You should generally pass the error code onwards. Though the positive returns you should handle too so it would be better to split it into two if()s. > + } > + if (buffer[28] == 0xAA) { Please name 0xaa with a define. Maybe 28 as well should be named with a define. > + battery_threshold_support = true; > + return 0; > + } > + return false; Returning false from int function??? > +} > + > static void hp_wmi_notify(union acpi_object *obj, void *context) > { > u32 event_id, event_data; > @@ -2287,6 +2306,12 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) > hp_wmi_rfkill2_setup(device); > } > > + err = hp_battery_threshold_check(); > + > + if (err == 0) { Please don't leave empty lines in between call and it's error handling (but see the next comment below). > + pr_info("Battery Threshold is supported"); Success path should be silent. After correcting these issues, please send v2. > + } > + > err = hp_wmi_hwmon_init(); > > if (err < 0) > -- i. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] hp-wmi: add battery threshold support 2026-06-08 12:35 ` Ilpo Järvinen @ 2026-06-08 15:36 ` yahia 2026-06-08 15:57 ` Ilpo Järvinen 0 siblings, 1 reply; 6+ messages in thread From: yahia @ 2026-06-08 15:36 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: platform-driver-x86, yahia Hello, Ilpo Thanks for your review, This V2 patch implements Battery threshold support via ACPI methods SBCO and GBCO,This Implementation adds battery_get function to retrieve the current battery threshold mode and use it to identify capabilities to simplify code instead of another function specifically for detection Signed-off-by: yahia ahmed <yahia.a.abdrabou@gmail.com> --- drivers/platform/x86/hp/hp-wmi.c | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index f63bc00d9a9b..f2180b61b84e 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -11,6 +11,7 @@ * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/acpi.h> @@ -292,6 +293,18 @@ enum hp_wmi_event_ids { HPWMI_SMART_EXPERIENCE_APP = 0x21, }; +/* + * Profiles for hp battery threshold profile 0x05 and 0x06 map to 4 and 5 respectively + */ +enum hp_battery_modes { + HP_BATTERY_MODE_NORMAL = 0x00, + HP_BATTERY_MODE_ADAPTIVE = 0x02, + HP_BATTERY_THRESHOLD_4 = 0x05, + HP_BATTERY_THRESHOLD_5 = 0x06, +}; + +#define HPWMI_BATTERY_THRESHOLD_SBCO 0x2B // SBCO Command id +#define HPWMI_AC_REQUIRED 0x35 // obscure edge case where the bios requires the user to be charged while setting a profile /* * struct bios_args buffer is dynamically allocated. New WMI command types * were introduced that exceeds 128-byte data size. Changes to handle @@ -448,6 +461,7 @@ static struct notifier_block platform_power_source_nb; static enum platform_profile_option active_platform_profile; static bool platform_profile_support; static bool zero_insize_support; +static bool battery_threshold_support; static struct rfkill *wifi_rfkill; static struct rfkill *bluetooth_rfkill; @@ -1085,6 +1099,50 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, return count; } +static int battery_get(void) { + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; + int mode = -1; + if (ACPI_SUCCESS(acpi_evaluate_object(NULL, "\\_SB.WMID.GBCO", NULL, &output))) { + union acpi_object *obj = (union acpi_object *)output.pointer; + if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 3) { // standard package sent by bios + mode = (int)obj->package.elements[2].buffer.pointer[0]; // bios returns the result in the third buffer + } + kfree(output.pointer); + } else + mode = -EIO; + return mode; +} + +static int battery_set(int profile) +{ + if (!battery_threshold_support) { + pr_err("Battery threshold is not supported"); + return -EOPNOTSUPP; + } + union acpi_object args[4]; + acpi_status status; + struct acpi_object_list arg_list = { .count = 4, .pointer = args }; + memset(args, 0, sizeof(args)); + args[0].type = ACPI_TYPE_INTEGER; + args[0].integer.value = 0; + args[1].type = ACPI_TYPE_INTEGER; + args[1].integer.value = profile; + args[2].type = ACPI_TYPE_INTEGER; // padding required by bios + args[2].integer.value = 0; + args[3].type = ACPI_TYPE_INTEGER; + args[3].integer.value = 0; + status = acpi_evaluate_object(NULL, "\\_SB.WMID.SBCO", &arg_list, NULL); + if (unlikely(status == HPWMI_AC_REQUIRED)) { + pr_err("You have to be plugged in while setting a battery profile"); // random edge case in the bios + return -EIO; + } + if (ACPI_FAILURE(status)) { + pr_info("Write failed with Error code 0x%08x\n", status); + return -EIO; + } + return status; +} + static int camera_shutter_input_setup(void) { int err; @@ -2292,6 +2350,9 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) if (err < 0) return err; + int ret = battery_get(); + if (ret >= 0) + battery_threshold_support = true; thermal_profile_setup(device); return 0; -- 2.54.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] hp-wmi: add battery threshold support 2026-06-08 15:36 ` [PATCH v2] hp-wmi: add battery threshold support yahia @ 2026-06-08 15:57 ` Ilpo Järvinen 2026-06-08 18:07 ` [PATCH v3] " yahia 0 siblings, 1 reply; 6+ messages in thread From: Ilpo Järvinen @ 2026-06-08 15:57 UTC (permalink / raw) To: yahia; +Cc: platform-driver-x86 On Mon, 8 Jun 2026, yahia wrote: > Hello, Ilpo > Thanks for your review, > This V2 patch implements Battery threshold support via ACPI methods > SBCO and GBCO,This Implementation adds battery_get function to retrieve > the current battery threshold mode and use it to identify capabilities > to simplify code instead of another function specifically for detection As already stated, please write proper English sentences. Anything you want to say that isn't part of the changelog should appear under --- line. > Signed-off-by: yahia ahmed <yahia.a.abdrabou@gmail.com> > --- Missing version history. > drivers/platform/x86/hp/hp-wmi.c | 61 ++++++++++++++++++++++++++++++++ > 1 file changed, 61 insertions(+) > > diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c > index f63bc00d9a9b..f2180b61b84e 100644 > --- a/drivers/platform/x86/hp/hp-wmi.c > +++ b/drivers/platform/x86/hp/hp-wmi.c > @@ -11,6 +11,7 @@ > * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> > */ > > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > #include <linux/acpi.h> Eh? > @@ -292,6 +293,18 @@ enum hp_wmi_event_ids { > HPWMI_SMART_EXPERIENCE_APP = 0x21, > }; > > +/* > + * Profiles for hp battery threshold profile 0x05 and 0x06 map to 4 and 5 respectively > + */ > +enum hp_battery_modes { > + HP_BATTERY_MODE_NORMAL = 0x00, > + HP_BATTERY_MODE_ADAPTIVE = 0x02, > + HP_BATTERY_THRESHOLD_4 = 0x05, > + HP_BATTERY_THRESHOLD_5 = 0x06, The values should be aligned. > +}; > + > +#define HPWMI_BATTERY_THRESHOLD_SBCO 0x2B // SBCO Command id > +#define HPWMI_AC_REQUIRED 0x35 // obscure edge case where the bios requires the user to be charged while setting a profile ??? > /* > * struct bios_args buffer is dynamically allocated. New WMI command types > * were introduced that exceeds 128-byte data size. Changes to handle > @@ -448,6 +461,7 @@ static struct notifier_block platform_power_source_nb; > static enum platform_profile_option active_platform_profile; > static bool platform_profile_support; > static bool zero_insize_support; > +static bool battery_threshold_support; > > static struct rfkill *wifi_rfkill; > static struct rfkill *bluetooth_rfkill; > @@ -1085,6 +1099,50 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, > return count; > } > > +static int battery_get(void) { > + struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; > + int mode = -1; > + if (ACPI_SUCCESS(acpi_evaluate_object(NULL, "\\_SB.WMID.GBCO", NULL, &output))) { > + union acpi_object *obj = (union acpi_object *)output.pointer; > + if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 3) { // standard package sent by bios > + mode = (int)obj->package.elements[2].buffer.pointer[0]; // bios returns the result in the third buffer > + } > + kfree(output.pointer); > + } else > + mode = -EIO; > + return mode; > +} > + > +static int battery_set(int profile) > +{ > + if (!battery_threshold_support) { > + pr_err("Battery threshold is not supported"); > + return -EOPNOTSUPP; > + } > + union acpi_object args[4]; > + acpi_status status; > + struct acpi_object_list arg_list = { .count = 4, .pointer = args }; > + memset(args, 0, sizeof(args)); > + args[0].type = ACPI_TYPE_INTEGER; > + args[0].integer.value = 0; > + args[1].type = ACPI_TYPE_INTEGER; > + args[1].integer.value = profile; > + args[2].type = ACPI_TYPE_INTEGER; // padding required by bios > + args[2].integer.value = 0; > + args[3].type = ACPI_TYPE_INTEGER; > + args[3].integer.value = 0; > + status = acpi_evaluate_object(NULL, "\\_SB.WMID.SBCO", &arg_list, NULL); > + if (unlikely(status == HPWMI_AC_REQUIRED)) { > + pr_err("You have to be plugged in while setting a battery profile"); // random edge case in the bios > + return -EIO; > + } > + if (ACPI_FAILURE(status)) { > + pr_info("Write failed with Error code 0x%08x\n", status); > + return -EIO; > + } > + return status; > +} > + > static int camera_shutter_input_setup(void) > { > int err; > @@ -2292,6 +2350,9 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) > if (err < 0) > return err; > > + int ret = battery_get(); > + if (ret >= 0) > + battery_threshold_support = true; > thermal_profile_setup(device); > > return 0; > Unfortunately, this submission doesn't match kernel coding style guidelines you can find under Documentation/. Please review the patch yourself before submitting the next version and correct all error you find before the submission. -- i. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3] hp-wmi: add battery threshold support 2026-06-08 15:57 ` Ilpo Järvinen @ 2026-06-08 18:07 ` yahia 2026-06-09 7:55 ` Ilpo Järvinen 0 siblings, 1 reply; 6+ messages in thread From: yahia @ 2026-06-08 18:07 UTC (permalink / raw) To: ilpo.jarvinen; +Cc: platform-driver-x86, yahia ahmed From: yahia ahmed <yahia.a.abdrabou@gmail.com> Implement battery threshold support using the SBCO and GBCO ACPI methods, Add battery_get to retrieve the current battery mode and provide a function to set the battery threshold. Signed-off-by: yahia ahmed <yahia.a.abdrabou@gmail.com> --- v3: - Fix coding style errors and warning - Refine the changelogs for clarity v2: - Simplify detection logic via battery_get - Add Battery Profiles enum table - Add functions to set the battery mode --- drivers/platform/x86/hp/hp-wmi.c | 37 ++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index f2180b61b84e..c50fe78099d9 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -11,7 +11,6 @@ * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> */ -#include <asm-generic/errno.h> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/acpi.h> @@ -297,15 +296,16 @@ enum hp_wmi_event_ids { * Profiles for hp battery threshold profile 0x05 and 0x06 map to 4 and 5 respectively */ enum hp_battery_modes { - HP_BATTERY_MODE_NORMAL = 0x00, + HP_BATTERY_MODE_NORMAL = 0x00, HP_BATTERY_MODE_ADAPTIVE = 0x02, - HP_BATTERY_THRESHOLD_4 = 0x05, - HP_BATTERY_THRESHOLD_5 = 0x06, + HP_BATTERY_THRESHOLD_4 = 0x05, + HP_BATTERY_THRESHOLD_5 = 0x06, }; -#define HPWMI_BATTERY_THRESHOLD_SBCO 0x2B // SBCO Command id -#define HPWMI_AC_REQUIRED 0x35 // obscure edge case where the bios requires the user to be charged while setting a profile -/* +#define HPWMI_BATTERY_THRESHOLD_SBCO 0x2B /* SBCO Command id */ +#define HPWMI_AC_REQUIRED 0x35 +/* obscure edge case where the bios requires the user to be charging while setting a profile + * * struct bios_args buffer is dynamically allocated. New WMI command types * were introduced that exceeds 128-byte data size. Changes to handle * the data size allocation scheme were kept in hp_wmi_perform_qurey function. @@ -1099,21 +1099,26 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, return count; } -static int battery_get(void) { +static int battery_get(void) +{ struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; int mode = -1; + if (ACPI_SUCCESS(acpi_evaluate_object(NULL, "\\_SB.WMID.GBCO", NULL, &output))) { union acpi_object *obj = (union acpi_object *)output.pointer; - if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 3) { // standard package sent by bios - mode = (int)obj->package.elements[2].buffer.pointer[0]; // bios returns the result in the third buffer + + if (obj && obj->type == ACPI_TYPE_PACKAGE /* standard package sent by bios */ + && obj->package.count >= 3) { + /* bios returns the result in the third buffer */ + mode = (int)obj->package.elements[2].buffer.pointer[0]; } kfree(output.pointer); - } else + } else mode = -EIO; return mode; } -static int battery_set(int profile) +static int battery_set(int profile) { if (!battery_threshold_support) { pr_err("Battery threshold is not supported"); @@ -1122,18 +1127,21 @@ static int battery_set(int profile) union acpi_object args[4]; acpi_status status; struct acpi_object_list arg_list = { .count = 4, .pointer = args }; + memset(args, 0, sizeof(args)); args[0].type = ACPI_TYPE_INTEGER; args[0].integer.value = 0; args[1].type = ACPI_TYPE_INTEGER; args[1].integer.value = profile; - args[2].type = ACPI_TYPE_INTEGER; // padding required by bios + args[2].type = ACPI_TYPE_INTEGER; /* padding required by bios */ args[2].integer.value = 0; args[3].type = ACPI_TYPE_INTEGER; args[3].integer.value = 0; status = acpi_evaluate_object(NULL, "\\_SB.WMID.SBCO", &arg_list, NULL); + if (unlikely(status == HPWMI_AC_REQUIRED)) { - pr_err("You have to be plugged in while setting a battery profile"); // random edge case in the bios + /* random edge case in the bios */ + pr_err("You have to be plugged in while setting a battery profile"); return -EIO; } if (ACPI_FAILURE(status)) { @@ -2351,6 +2359,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) return err; int ret = battery_get(); + if (ret >= 0) battery_threshold_support = true; thermal_profile_setup(device); -- 2.54.0 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3] hp-wmi: add battery threshold support 2026-06-08 18:07 ` [PATCH v3] " yahia @ 2026-06-09 7:55 ` Ilpo Järvinen 0 siblings, 0 replies; 6+ messages in thread From: Ilpo Järvinen @ 2026-06-09 7:55 UTC (permalink / raw) To: yahia; +Cc: platform-driver-x86 On Mon, 8 Jun 2026, yahia wrote: > From: yahia ahmed <yahia.a.abdrabou@gmail.com> > > Implement battery threshold support using the SBCO and GBCO ACPI methods, > Add battery_get to retrieve the current battery mode and provide a function > to set the battery threshold. > > Signed-off-by: yahia ahmed <yahia.a.abdrabou@gmail.com> > --- > v3: > - Fix coding style errors and warning > - Refine the changelogs for clarity > > v2: > - Simplify detection logic via battery_get > - Add Battery Profiles enum table > - Add functions to set the battery mode > --- > drivers/platform/x86/hp/hp-wmi.c | 37 ++++++++++++++++++++------------ > 1 file changed, 23 insertions(+), 14 deletions(-) > > diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c > index f2180b61b84e..c50fe78099d9 100644 > --- a/drivers/platform/x86/hp/hp-wmi.c > +++ b/drivers/platform/x86/hp/hp-wmi.c > @@ -11,7 +11,6 @@ > * Copyright (C) 2005 Dmitry Torokhov <dtor@mail.ru> > */ > > -#include <asm-generic/errno.h> > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > #include <linux/acpi.h> > @@ -297,15 +296,16 @@ enum hp_wmi_event_ids { > * Profiles for hp battery threshold profile 0x05 and 0x06 map to 4 and 5 respectively > */ > enum hp_battery_modes { > - HP_BATTERY_MODE_NORMAL = 0x00, > + HP_BATTERY_MODE_NORMAL = 0x00, > HP_BATTERY_MODE_ADAPTIVE = 0x02, > - HP_BATTERY_THRESHOLD_4 = 0x05, > - HP_BATTERY_THRESHOLD_5 = 0x06, > + HP_BATTERY_THRESHOLD_4 = 0x05, > + HP_BATTERY_THRESHOLD_5 = 0x06, > }; > > -#define HPWMI_BATTERY_THRESHOLD_SBCO 0x2B // SBCO Command id > -#define HPWMI_AC_REQUIRED 0x35 // obscure edge case where the bios requires the user to be charged while setting a profile > -/* > +#define HPWMI_BATTERY_THRESHOLD_SBCO 0x2B /* SBCO Command id */ > +#define HPWMI_AC_REQUIRED 0x35 > +/* obscure edge case where the bios requires the user to be charging while setting a profile > + * > * struct bios_args buffer is dynamically allocated. New WMI command types > * were introduced that exceeds 128-byte data size. Changes to handle > * the data size allocation scheme were kept in hp_wmi_perform_qurey function. > @@ -1099,21 +1099,26 @@ static ssize_t postcode_store(struct device *dev, struct device_attribute *attr, > return count; > } > > -static int battery_get(void) { > +static int battery_get(void) > +{ > struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; > int mode = -1; > + > if (ACPI_SUCCESS(acpi_evaluate_object(NULL, "\\_SB.WMID.GBCO", NULL, &output))) { > union acpi_object *obj = (union acpi_object *)output.pointer; > - if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 3) { // standard package sent by bios > - mode = (int)obj->package.elements[2].buffer.pointer[0]; // bios returns the result in the third buffer > + > + if (obj && obj->type == ACPI_TYPE_PACKAGE /* standard package sent by bios */ > + && obj->package.count >= 3) { > + /* bios returns the result in the third buffer */ > + mode = (int)obj->package.elements[2].buffer.pointer[0]; > } > kfree(output.pointer); > - } else > + } else > mode = -EIO; > return mode; > } > > -static int battery_set(int profile) > +static int battery_set(int profile) > { > if (!battery_threshold_support) { > pr_err("Battery threshold is not supported"); > @@ -1122,18 +1127,21 @@ static int battery_set(int profile) > union acpi_object args[4]; > acpi_status status; > struct acpi_object_list arg_list = { .count = 4, .pointer = args }; > + > memset(args, 0, sizeof(args)); > args[0].type = ACPI_TYPE_INTEGER; > args[0].integer.value = 0; > args[1].type = ACPI_TYPE_INTEGER; > args[1].integer.value = profile; > - args[2].type = ACPI_TYPE_INTEGER; // padding required by bios > + args[2].type = ACPI_TYPE_INTEGER; /* padding required by bios */ > args[2].integer.value = 0; > args[3].type = ACPI_TYPE_INTEGER; > args[3].integer.value = 0; > status = acpi_evaluate_object(NULL, "\\_SB.WMID.SBCO", &arg_list, NULL); > + > if (unlikely(status == HPWMI_AC_REQUIRED)) { > - pr_err("You have to be plugged in while setting a battery profile"); // random edge case in the bios > + /* random edge case in the bios */ > + pr_err("You have to be plugged in while setting a battery profile"); > return -EIO; > } > if (ACPI_FAILURE(status)) { > @@ -2351,6 +2359,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device) > return err; > > int ret = battery_get(); > + > if (ret >= 0) > battery_threshold_support = true; > thermal_profile_setup(device); This patch wouldn't even apply. Also, I'm very skeptical you reviewed it yourself before sending it as some of the changes are direct opposite of my earlier review comments (irrespective of whether the patch would apply or not). -- i. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-06-09 7:55 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-06-05 23:19 [PATCH] [PATCH] platform/x86: Add Battery Threshold support yahia 2026-06-08 12:35 ` Ilpo Järvinen 2026-06-08 15:36 ` [PATCH v2] hp-wmi: add battery threshold support yahia 2026-06-08 15:57 ` Ilpo Järvinen 2026-06-08 18:07 ` [PATCH v3] " yahia 2026-06-09 7:55 ` Ilpo Järvinen
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.