From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 272932E764E; Tue, 15 Jul 2025 13:57:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752587876; cv=none; b=dW6Au6AUXWyREJFUTFwUmG+9YsJcKi7TlpkXz+gX8BGjkUTtS9vXtHd+3XVglYQLAJLM+u9C9K7mMnu8nF4ms/4JunpzcYdrJyEqTSXMnCczHmabeqvm4z1DlE/COYRRULv72ds7/wG9mwKyS+OjNkumI0znp8GbvdBurjzzKNs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752587876; c=relaxed/simple; bh=6vTfLsDfZ7slYUtuTuR6Olp1pgQsqdjNd1huxfTAyf8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ndXG7GWbL2QmCdzaxtxU3VJT/m9fLU9CiRVmoNR2GOlNloKhhVelyB1oPR7j5khzAkGx9ultp5qN5i/1K6aPtT+JbtIp6PR6uvm3qNaSeG7PI8Ie7IHB+3VziYRePR73O6BAsmeGJHO2ACmch9cPq9kRYBzqgvZ8NufjzsJ1fcE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=EsvEznPr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="EsvEznPr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46ADBC4CEE3; Tue, 15 Jul 2025 13:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752587875; bh=6vTfLsDfZ7slYUtuTuR6Olp1pgQsqdjNd1huxfTAyf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EsvEznPr8O4QF4eQzykitir4TtojeXPZuys1u3hW+2ByFBXQY7eJL1EPxq+gmuoYW 7tzD4zWg8uJ6XdTjxDKhuCnJI1xxgycpRX7vGtsujFbjsEsN1tD5+ArjKh9bYf6VQ0 JlEav6EgxG1hEVC/RRG/77rfU5nMKBYIUdL5eRxQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Matthew Schwartz , "Rafael J. Wysocki" Subject: [PATCH 5.10 177/208] Revert "ACPI: battery: negate current when discharging" Date: Tue, 15 Jul 2025 15:14:46 +0200 Message-ID: <20250715130818.056566480@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130810.830580412@linuxfoundation.org> References: <20250715130810.830580412@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Rafael J. Wysocki commit de1675de39aa945bad5937d1fde4df3682670639 upstream. Revert commit 234f71555019 ("ACPI: battery: negate current when discharging") breaks not one but several userspace implementations of battery monitoring: Steam and MangoHud. Perhaps it breaks more, but those are the two that have been tested. Reported-by: Matthew Schwartz Closes: https://lore.kernel.org/linux-acpi/87C1B2AF-D430-4568-B620-14B941A8ABA4@linux.dev/ Signed-off-by: Rafael J. Wysocki Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/battery.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -255,23 +255,10 @@ static int acpi_battery_get_property(str break; case POWER_SUPPLY_PROP_CURRENT_NOW: case POWER_SUPPLY_PROP_POWER_NOW: - if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) { + if (battery->rate_now == ACPI_BATTERY_VALUE_UNKNOWN) ret = -ENODEV; - break; - } - - val->intval = battery->rate_now * 1000; - /* - * When discharging, the current should be reported as a - * negative number as per the power supply class interface - * definition. - */ - if (psp == POWER_SUPPLY_PROP_CURRENT_NOW && - (battery->state & ACPI_BATTERY_STATE_DISCHARGING) && - acpi_battery_handle_discharging(battery) - == POWER_SUPPLY_STATUS_DISCHARGING) - val->intval = -val->intval; - + else + val->intval = battery->rate_now * 1000; break; case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: case POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN: