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).
Subject: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent From: Andrey Borzenkov <[email protected]> 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 <[email protected]> --- 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:
signature.asc
Description: This is a digitally signed message part.
- Follow-Ups:
- Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent
- From: Anton Vorontsov <[email protected]>
- Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent
- From: Alexey Starikovskiy <[email protected]>
- Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent
- Prev by Date: Re: [PATCH] fix 'and' typos in drivers/block/pktcdvd.c
- Next by Date: Re: epoll design problems with common fork/exec patterns
- Previous by thread: [PATCH] isd200: don't include <linux/ide.h>
- Next by thread: Re: [PATCH] 2.6.24-rc1: ensure "present" sysfs attribute even if battery is absent
- Index(es):