From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux acpi <linux-acpi@vger.kernel.org>
Cc: Alexey Starikovskiy <astarikovskiy@suse.de>
Subject: [PATCH 3/3] ACPI: battery: register power_supply subdevice even when battery not present
Date: Tue, 12 May 2009 15:51:54 +0100 [thread overview]
Message-ID: <4A098D0A.6090509@tuffmail.co.uk> (raw)
Keeping this device around lets userspace know that we have a battery
bay, even if there is nothing in it at the moment. This is what every
other battery driver does, so ACPI should do it as well.
There is no reason to preserve the old behaviour. We now correctly
provide the "present" attribute, which will return "0" when the battery
is removed. HAL was already trying to check this attribute, so
it should be fine.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index 9208e97..9331f01 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -487,8 +487,6 @@ static int sysfs_add_battery(struct acpi_battery *battery)
static void sysfs_remove_battery(struct acpi_battery *battery)
{
- if (!battery->bat.dev)
- return;
device_remove_file(battery->bat.dev, &alarm_attr);
power_supply_unregister(&battery->bat);
battery->bat.dev = NULL;
@@ -502,9 +500,6 @@ static int acpi_battery_update(struct acpi_battery *battery)
if (result)
return result;
if (!acpi_battery_present(battery)) {
-#ifdef CONFIG_ACPI_SYSFS_POWER
- sysfs_remove_battery(battery);
-#endif
battery->update_time = 0;
return 0;
}
@@ -515,10 +510,6 @@ static int acpi_battery_update(struct acpi_battery *battery)
return result;
acpi_battery_init_alarm(battery);
}
-#ifdef CONFIG_ACPI_SYSFS_POWER
- if (!battery->bat.dev)
- sysfs_add_battery(battery);
-#endif
return acpi_battery_get_state(battery);
}
@@ -810,9 +801,7 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
dev_name(&device->dev), event,
acpi_battery_present(battery));
#ifdef CONFIG_ACPI_SYSFS_POWER
- /* acpi_batter_update could remove power_supply object */
- if (battery->bat.dev)
- power_supply_changed(&battery->bat);
+ power_supply_changed(&battery->bat);
#endif
}
@@ -837,6 +826,11 @@ static int acpi_battery_add(struct acpi_device *device)
if (result)
goto end;
#endif
+#ifdef CONFIG_ACPI_SYSFS_POWER
+ result = sysfs_add_battery(battery);
+ if (result)
+ goto end;
+#endif
status = acpi_install_notify_handler(device->handle,
ACPI_ALL_NOTIFY,
acpi_battery_notify, battery);
next reply other threads:[~2009-05-12 14:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 14:51 Alan Jenkins [this message]
2009-09-07 2:37 ` [PATCH 3/3] ACPI: battery: register power_supply subdevice even when battery not present Maxim Levitsky
2009-09-07 12:29 ` Alan Jenkins
2009-10-31 1:58 ` Maxim Levitsky
2009-10-31 10:48 ` Alan Jenkins
2009-10-31 13:20 ` Maxim Levitsky
2009-11-01 18:03 ` Alan Jenkins
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=4A098D0A.6090509@tuffmail.co.uk \
--to=alan-jenkins@tuffmail.co.uk \
--cc=astarikovskiy@suse.de \
--cc=linux-acpi@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.