Created
July 26, 2018 19:20
-
-
Save linrunner/1e343a0125a14448246300a8106dfcf5 to your computer and use it in GitHub Desktop.
[PATCH] thinkpad_acpi: use BDSS to set force_discharge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 234dbcfa353de7d8bca9f5c9dec6ce9c196faec7 Mon Sep 17 00:00:00 2001 | |
From: Thomas Koch <linrunner@gmx.net> | |
Date: Thu, 26 Jul 2018 07:01:01 +0200 | |
Subject: [PATCH] thinkpad_acpi: use BDSS to set force_discharge | |
PSBS won't work on all (relevant) ThinkPads, so mimic tpacpi-bat | |
with BDSS. | |
Signed-off-by: Thomas Koch <linrunner@gmx.net> | |
--- | |
drivers/platform/x86/thinkpad_acpi.c | 8 +++++--- | |
1 file changed, 5 insertions(+), 3 deletions(-) | |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c | |
index 80e32d5..0273765 100644 | |
--- a/drivers/platform/x86/thinkpad_acpi.c | |
+++ b/drivers/platform/x86/thinkpad_acpi.c | |
@@ -9249,7 +9249,7 @@ static struct ibm_struct mute_led_driver_data = { | |
#define GET_INHIBIT "BICG" | |
#define GET_DISCHARGE "BDSG" | |
-#define SET_DISCHARGE "PSBS" | |
+#define SET_DISCHARGE "BDSS" | |
#define INHIBIT_ATTR "inhibit_charge" | |
#define DISCHARGE_ATTR "force_discharge" | |
@@ -9397,8 +9397,10 @@ static int tpacpi_battery_set(int what, int battery, int value) | |
} | |
return 0; | |
case FORCE_DISCHARGE: | |
- param = battery; | |
- param |= value << 8; | |
+ /* Force discharge is in bit 0, | |
+ * break on AC attach is in bit 1 (won't work on some ThinkPads), | |
+ * battery ID is in bits 8-9, 2 bits. | |
+ */ | |
if ACPI_FAILURE(tpacpi_battery_acpi_eval(SET_DISCHARGE, &ret, param)) { | |
pr_err("failed to set force dischrage on %d", battery); | |
return -ENODEV; | |
-- | |
2.7.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment