summaryrefslogtreecommitdiffstats
path: root/sys/i386/acpica
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2005-07-23 19:36:00 +0000
committernjl <njl@FreeBSD.org>2005-07-23 19:36:00 +0000
commit1cb806cc9e5fbdc3e914ad946522d64a8237ff6a (patch)
tree098bd44131b4884e3f9bfa4b18f7728aa68f1ff4 /sys/i386/acpica
parentdd4ae2e4bda1d9276dd71e2dd37fe3ee108c4d91 (diff)
downloadFreeBSD-src-1cb806cc9e5fbdc3e914ad946522d64a8237ff6a.zip
FreeBSD-src-1cb806cc9e5fbdc3e914ad946522d64a8237ff6a.tar.gz
Rewrite the acpi_battery interface to allow for other battery types
(i.e., smart battery) and fix various bugs found during the cleanup. API changes: * kernel access: Access to individual batteries is now via devclass_find("battery"). Introduce new methods ACPI_BATT_GET_STATUS (for _BST-formatted data) and ACPI_BATT_GET_INFO (for _BIF-formatted data). The helper function acpi_battery_get_battinfo() now takes a device_t instead of a unit # argument. If dev is NULL, this signifies all batteries. * ioctl access: The ACPIIO_BATT_GET_TYPE and ACPIIO_BATT_GET_BATTDESC ioctls have been removed. Since there is now no need for a mapping between "virtual" unit and physical unit, usermode programs can just specify the unit directly and skip the old translation steps. In fact, acpiconf(8) was actually already doing this and virtual unit was the same as physical unit in all cases since there was previously only one battery type (acpi_cmbat). Additionally, we now map the ACPIIO_BATT_GET_BIF and ACPIIO_BATT_GET_BST ioctls for all batteries, if they provide the associated methods. * apm compatibility device/ioctls: no change * sysctl: no change Since most third-party applications use the apm(4) compat interface, there should be very few affected applications (if any). Reviewed by: bruno MFC after: 5 days
Diffstat (limited to 'sys/i386/acpica')
-rw-r--r--sys/i386/acpica/acpi_machdep.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/i386/acpica/acpi_machdep.c b/sys/i386/acpica/acpi_machdep.c
index f98a6fb..8b2efd0 100644
--- a/sys/i386/acpica/acpi_machdep.c
+++ b/sys/i386/acpica/acpi_machdep.c
@@ -143,7 +143,7 @@ acpi_capm_get_info(apm_info_t aip)
else
aip->ai_acline = acline; /* on/off */
- if (acpi_battery_get_battinfo(-1, &batt)) {
+ if (acpi_battery_get_battinfo(NULL, &batt) != 0) {
aip->ai_batt_stat = APM_UNKNOWN;
aip->ai_batt_life = APM_UNKNOWN;
aip->ai_batt_time = -1; /* unknown */
@@ -161,8 +161,8 @@ acpi_capm_get_info(apm_info_t aip)
static int
acpi_capm_get_pwstatus(apm_pwstatus_t app)
{
- int batt_unit;
- int acline;
+ device_t dev;
+ int acline, unit, error;
struct acpi_battinfo batt;
if (app->ap_device != PMDV_ALLDEV &&
@@ -170,11 +170,16 @@ acpi_capm_get_pwstatus(apm_pwstatus_t app)
return (1);
if (app->ap_device == PMDV_ALLDEV)
- batt_unit = -1; /* all units */
- else
- batt_unit = app->ap_device - PMDV_BATT0;
-
- if (acpi_battery_get_battinfo(batt_unit, &batt))
+ error = acpi_battery_get_battinfo(NULL, &batt);
+ else {
+ unit = app->ap_device - PMDV_BATT0;
+ dev = devclass_get_device(devclass_find("battery"), unit);
+ if (dev != NULL)
+ error = acpi_battery_get_battinfo(dev, &batt);
+ else
+ error = ENXIO;
+ }
+ if (error)
return (1);
app->ap_batt_stat = acpi_capm_convert_battstate(&batt);
OpenPOWER on IntegriCloud