From: Andrey Borzenkov <arvidjaar@mail.ru>
To: linux-acpi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, cbou@mail.ru, dwmw2@infradead.org
Subject: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent
Date: Sat, 27 Oct 2007 20:54:30 +0400 [thread overview]
Message-ID: <200710272054.31160.arvidjaar@mail.ru> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 207 bytes --]
I am not exactly sure about this one ... what other power_supply class drivers
do? Should I fix HAL instead (but then, I do not know whether HAL is the only
application that is using this interface).
[-- Attachment #1.2: 2.6.24-rc1_battery_present_property --]
[-- Type: text/x-diff, Size: 1625 bytes --]
Subject: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent
From: Andrey Borzenkov <arvidjaar@mail.ru>
Ensure that we always have "present" attribute in sysfs. This is compatible
with procfs case where we had "present: no" if battery was not available.
This fixes HAL battery detection where it does pretend battery is present
but canot provide any value for it.
Signed-off-by: Andrey Borzenkov <arvidjaar@mail.ru>
---
drivers/acpi/battery.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 681e26b..6e67fcd 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -187,6 +187,10 @@ static int acpi_battery_get_property(struct power_supply *psy,
return 0;
}
+static enum power_supply_property missing_battery_props[] = {
+ POWER_SUPPLY_PROP_PRESENT,
+};
+
static enum power_supply_property charge_battery_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_PRESENT,
@@ -389,8 +393,13 @@ static int acpi_battery_update(struct acpi_battery *battery)
{
int saved_present = acpi_battery_present(battery);
int result = acpi_battery_get_status(battery);
- if (result || !acpi_battery_present(battery))
+ if (result)
return result;
+ if (!acpi_battery_present(battery)) {
+ battery->bat.properties = missing_battery_props;
+ battery->bat.num_properties = ARRAY_SIZE(missing_battery_props);
+ return result;
+ }
if (saved_present != acpi_battery_present(battery) ||
!battery->update_time) {
battery->update_time = 0;
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2007-10-27 16:54 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-27 16:54 Andrey Borzenkov [this message]
2007-10-27 17:16 ` [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent Alexey Starikovskiy
2007-10-27 17:50 ` Andrey Borzenkov
2007-10-27 18:18 ` Alexey Starikovskiy
2007-10-27 18:42 ` Anton Vorontsov
2007-10-27 19:32 ` David Woodhouse
2007-10-27 19:50 ` Anton Vorontsov
2007-10-28 6:50 ` Andrey Borzenkov
2007-10-28 7:37 ` [PATCH] [2.6.24-rc] ACPI: register power_supply subdevice only when battery is present Andrey Borzenkov
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=200710272054.31160.arvidjaar@mail.ru \
--to=arvidjaar@mail.ru \
--cc=cbou@mail.ru \
--cc=dwmw2@infradead.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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.