Re: [PATCH v2 1/2] acpi: battery: Query Battery charge time ("_BCT") method

From: Rafael J. Wysocki (Intel)

Date: Wed Oct 14 2026 - 14:13:25 EST


On Wed, Oct 14, 2026 at 7:31 PM Umang Jain <uajain@xxxxxxxxxx> wrote:
>
> On 2026-10-12 17:15, Rafael J. Wysocki (Intel) wrote:
> > On Wed, Sep 23, 2026 at 10:28 AM Umang Jain <uajain@xxxxxxxxxx> wrote:
> >>
> >> Add plumbing for querying the Battery Charge Time ("_BCT") method.
> >> If present, set ACPI_BATTERY_BCT_PRESENT in battery flags to denote
> >> that the method is supported in ACPI.
> >>
> >> Signed-off-by: Umang Jain <uajain@xxxxxxxxxx>
> >> ---
> >> drivers/acpi/battery.c | 17 +++++++++++++++++
> >> 1 file changed, 17 insertions(+)
> >>
> >> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> >> index 670853ec3a4d..a1b7a821abaf 100644
> >> --- a/drivers/acpi/battery.c
> >> +++ b/drivers/acpi/battery.c
> >> @@ -76,6 +76,7 @@ MODULE_DEVICE_TABLE(acpi, battery_device_ids);
> >> enum {
> >> ACPI_BATTERY_ALARM_PRESENT,
> >> ACPI_BATTERY_XINFO_PRESENT,
> >> + ACPI_BATTERY_BCT_PRESENT,
> >> ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY,
> >> /* On Lenovo Thinkpad models from 2010 and 2011, the power unit
> >> * switches between mWh and mAh depending on whether the system
> >> @@ -110,6 +111,7 @@ struct acpi_battery {
> >>
> >> struct mutex property_lock; /* Protects properties below. */
> >> unsigned long update_time;
> >> + unsigned long long charge_time;
> >
> > This doesn't need to be unsigned long long. As per the spec, unsigned
> > int should be sufficient.
>
> Last thing before I send out v3, this is the function param-type for the
> acpi_evaluate_integer()
>
> In include/acpi/acpi_bus.h,
>
> acpi_status
> acpi_evaluate_integer(acpi_handle handle,
> acpi_string pathname,
> struct acpi_object_list *arguments, unsigned long long *data);

Yes, so you need an unsigned long long for calling that function, but
then you can copy the value to a variable of a different type (a u32,
say) if the given object is defined to return a value within the scope
of that type. Of course, you should validate the returned value
before doing so, but it generally needs to be validated before being
used anyway.