mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-27 11:55:06 +00:00
Add the ability to detach a battery. Now batteries that are detached are
also removed from the battery list.
This commit is contained in:
parent
752d473505
commit
7a5230b8ad
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=132049
@ -241,3 +241,19 @@ acpi_battery_register(int type, int phys_unit)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
acpi_battery_remove(int type, int phys_unit)
|
||||
{
|
||||
struct acpi_batteries *bp, *tmp;
|
||||
|
||||
TAILQ_FOREACH_SAFE(bp, &acpi_batteries, link, tmp) {
|
||||
if (bp->battdesc.type == type && bp->battdesc.phys_unit == phys_unit) {
|
||||
TAILQ_REMOVE(&acpi_batteries, bp, link);
|
||||
acpi_batteries_units--;
|
||||
free(bp, M_ACPIBATT);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return (ENOENT);
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ struct acpi_cmbat_softc {
|
||||
int min;
|
||||
int full_charge_time;
|
||||
int initializing;
|
||||
int phys_unit;
|
||||
};
|
||||
|
||||
static struct timespec acpi_cmbat_info_lastupdated;
|
||||
@ -87,6 +88,7 @@ static void acpi_cmbat_get_bif(void *);
|
||||
static void acpi_cmbat_notify_handler(ACPI_HANDLE, UINT32, void *);
|
||||
static int acpi_cmbat_probe(device_t);
|
||||
static int acpi_cmbat_attach(device_t);
|
||||
static int acpi_cmbat_detach(device_t);
|
||||
static int acpi_cmbat_resume(device_t);
|
||||
static int acpi_cmbat_ioctl(u_long, caddr_t, void *);
|
||||
static int acpi_cmbat_is_bst_valid(struct acpi_bst*);
|
||||
@ -98,6 +100,7 @@ static device_method_t acpi_cmbat_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, acpi_cmbat_probe),
|
||||
DEVMETHOD(device_attach, acpi_cmbat_attach),
|
||||
DEVMETHOD(device_detach, acpi_cmbat_detach),
|
||||
DEVMETHOD(device_resume, acpi_cmbat_resume),
|
||||
|
||||
{0, 0}
|
||||
@ -339,7 +342,8 @@ acpi_cmbat_attach(device_t dev)
|
||||
return (error);
|
||||
}
|
||||
|
||||
error = acpi_battery_register(ACPI_BATT_TYPE_CMBAT, acpi_cmbat_units);
|
||||
sc->phys_unit = acpi_cmbat_units;
|
||||
error = acpi_battery_register(ACPI_BATT_TYPE_CMBAT, sc->phys_unit);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
@ -351,6 +355,17 @@ acpi_cmbat_attach(device_t dev)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_cmbat_detach(device_t dev)
|
||||
{
|
||||
struct acpi_cmbat_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
acpi_battery_remove(ACPI_BATT_TYPE_CMBAT, sc->phys_unit);
|
||||
acpi_cmbat_units--;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
acpi_cmbat_resume(device_t dev)
|
||||
{
|
||||
|
@ -338,6 +338,7 @@ struct acpi_battinfo;
|
||||
struct acpi_battdesc;
|
||||
|
||||
int acpi_battery_register(int, int);
|
||||
int acpi_battery_remove(int, int);
|
||||
int acpi_battery_get_battinfo(int, struct acpi_battinfo *);
|
||||
int acpi_battery_get_units(void);
|
||||
int acpi_battery_get_info_expire(void);
|
||||
|
Loading…
Reference in New Issue
Block a user