All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathew King <mathewk@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Mathew King <mathewk@chromium.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org
Subject: [PATCH] acpi: battery: Always read fresh battery state on update
Date: Thu,  4 Jun 2020 13:56:58 -0600	[thread overview]
Message-ID: <20200604195658.66201-1-mathewk@chromium.org> (raw)

When the ACPI battery receives a notification event it should always
read the battery state fresh from the ACPI device and not use the cached
state. Currently the cached state stays valid and the new state may not
be read when a notification occurs. This can lead to a udev event
showing that the battery has changed but the sysfs state will still have
the cached state values. This change invalidates the update time forcing
the state to be updated before notifying the power_supply subsystem of
the change.

Signed-off-by: Mathew King <mathewk@chromium.org>
---
 drivers/acpi/battery.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 366c389175d8..ab7fa4879fbe 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -981,6 +981,7 @@ static int acpi_battery_update(struct acpi_battery *battery, bool resume)
 		acpi_battery_init_alarm(battery);
 	}
 
+	battery->update_time = 0;
 	result = acpi_battery_get_state(battery);
 	if (result)
 		return result;
-- 
2.27.0.rc2.251.g90737beb825-goog


             reply	other threads:[~2020-06-04 19:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-04 19:56 Mathew King [this message]
2020-06-05 11:30 ` [PATCH] acpi: battery: Always read fresh battery state on update Rafael J. Wysocki
2020-06-05 18:01   ` Mat King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200604195658.66201-1-mathewk@chromium.org \
    --to=mathewk@chromium.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.