[PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-acpi@...>
Cc: <linux-kernel@...>, <cbou@...>, <dwmw2@...>
Date: Saturday, October 27, 2007 - 12:54 pm

--Boundary-01=_H12IHT5Jl25MIH1
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

I am not exactly sure about this one ... what other power_supply class driv=
ers=20
do? Should I fix HAL instead (but then, I do not know whether HAL is the on=
ly=20
application that is using this interface).


--Boundary-01=_H12IHT5Jl25MIH1
Content-Type: text/x-diff;
  charset="us-ascii";
  name="2.6.24-rc1_battery_present_property"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
	filename="2.6.24-rc1_battery_present_property"

Subject: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if batte=
ry is absent
=46rom: 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>

=2D--

 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
=2D-- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -187,6 +187,10 @@ static int acpi_battery_get_property(struct power_supp=
ly *psy,
 	return 0;
 }
=20
+static enum power_supply_property missing_battery_props[] =3D {
+	POWER_SUPPLY_PROP_PRESENT,
+};
+
 static enum power_supply_property charge_battery_props[] =3D {
 	POWER_SUPPLY_PROP_STATUS,
 	POWER_SUPPLY_PROP_PRESENT,
@@ -389,8 +393,13 @@ static int acpi_battery_update(struct acpi_battery *ba=
ttery)
 {
 	int saved_present =3D acpi_battery_present(battery);
 	int result =3D acpi_battery_get_status(battery);
=2D	if (result || !acpi_battery_present(battery))
+	if (result)
 		return result;
+	if (!acpi_battery_present(battery)) {
+		battery->bat.properties =3D missing_battery_props;
+		battery->bat.num_properties =3D ARRAY_SIZE(missing_battery_props);
+		return result;
+	}
 	if (saved_present !=3D acpi_battery_present(battery) ||
 	    !battery->update_time) {
 		battery->update_time =3D 0;

--Boundary-01=_H12IHT5Jl25MIH1--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if..., Andrey Borzenkov, (Sat Oct 27, 12:54 pm)
Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute eve..., Alexey Starikovskiy, (Sat Oct 27, 1:16 pm)
Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute eve..., Alexey Starikovskiy, (Sat Oct 27, 2:18 pm)