ACPI: battery: Make "not-charging" the default on no charging or full info
authorWerner Sembach <wse@tuxedocomputers.com>
Wed, 27 Apr 2022 15:40:53 +0000 (17:40 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 6 May 2022 18:37:51 +0000 (20:37 +0200)
When the battery is neither charging or discharging and is not full,
"not-charging" is a useful status description for the case in general.
Currently this state is set as "unknown" by default, expect when this is
explicitly replaced with "not-charging" on a per device or per vendor
basis.

A lot of devices have this state without a BIOS specification available
explicitly describing it. e.g. some current Clevo barebones have a BIOS
setting to stop charging at a user defined battery level.

Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/battery.c

index dc208f5..306513f 100644 (file)
@@ -52,7 +52,6 @@ static bool battery_driver_registered;
 static int battery_bix_broken_package;
 static int battery_notification_delay_ms;
 static int battery_ac_is_broken;
-static int battery_quirk_notcharging;
 static unsigned int cache_time = 1000;
 module_param(cache_time, uint, 0644);
 MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -216,10 +215,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
                        val->intval = POWER_SUPPLY_STATUS_CHARGING;
                else if (acpi_battery_is_charged(battery))
                        val->intval = POWER_SUPPLY_STATUS_FULL;
-               else if (battery_quirk_notcharging)
-                       val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
                else
-                       val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
+                       val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
                break;
        case POWER_SUPPLY_PROP_PRESENT:
                val->intval = acpi_battery_present(battery);
@@ -1105,12 +1102,6 @@ battery_ac_is_broken_quirk(const struct dmi_system_id *d)
        return 0;
 }
 
-static int __init battery_quirk_not_charging(const struct dmi_system_id *d)
-{
-       battery_quirk_notcharging = 1;
-       return 0;
-}
-
 static const struct dmi_system_id bat_dmi_table[] __initconst = {
        {
                /* NEC LZ750/LS */
@@ -1140,19 +1131,6 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
                },
        },
        {
-               /*
-                * On Lenovo ThinkPads the BIOS specification defines
-                * a state when the bits for charging and discharging
-                * are both set to 0. That state is "Not Charging".
-                */
-               .callback = battery_quirk_not_charging,
-               .ident = "Lenovo ThinkPad",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
-                       DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"),
-               },
-       },
-       {
                /* Microsoft Surface Go 3 */
                .callback = battery_notification_delay_quirk,
                .matches = {