diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2006-02-22 19:28:18 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2006-02-22 19:28:18 +0000 |
commit | dfd94d28c4b7f3dcaf4dd88f9d34ff84c6c8c496 (patch) | |
tree | 8628a2d5d2b45a714bb80570715c2fbb2c0db943 /sys/dev/acpi | |
parent | e04008c2a60fa14277334a79a52d9dbbcad7fffb (diff) |
Rework notify handler.
Use jordan's new notify register function.
ok jordan@
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r-- | sys/dev/acpi/acpibat.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/sys/dev/acpi/acpibat.c b/sys/dev/acpi/acpibat.c index f42bf4559fb..65db8b12efa 100644 --- a/sys/dev/acpi/acpibat.c +++ b/sys/dev/acpi/acpibat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: acpibat.c,v 1.18 2006/02/22 15:29:23 marco Exp $ */ +/* $OpenBSD: acpibat.c,v 1.19 2006/02/22 19:28:17 marco Exp $ */ /* * Copyright (c) 2005 Marco Peereboom <marco@openbsd.org> * @@ -127,7 +127,7 @@ acpibat_attach(struct device *parent, struct device *self, void *aux) } - aml_register_notify(sc->sc_devnode->parent, acpibat_notify, sc); + aml_register_notify(sc->sc_devnode->parent, aa->aaa_dev, acpibat_notify, sc); } /* XXX this is for debug only, remove later */ @@ -390,22 +390,23 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg) if (sensor_task_register(sc, acpibat_refresh, 10)) printf(", unable to register update task\n"); - } - sc->sc_bat_present = 1; - acpibat_getbif(sc); - acpibat_getbst(sc); + sc->sc_bat_present = 1; + } break; case 0x81: /* _BIF changed */ /* XXX consider this a device removal */ - sensor_task_unregister(sc); - sc->sc_bat_present = 0; - strlcpy(sc->sc_sens[4].desc, "battery removed", - sizeof(sc->sc_sens[4].desc)); - printf("%s: %s: removed\n", DEVNAME(sc), - sc->sc_devnode->parent->name); + if (sc->sc_bat_present != 0) { + sensor_task_unregister(sc); + + strlcpy(sc->sc_sens[4].desc, "battery removed", + sizeof(sc->sc_sens[4].desc)); + printf("%s: %s: removed\n", DEVNAME(sc), + sc->sc_devnode->parent->name); + sc->sc_bat_present = 0; + } break; default: printf("%s: unhandled battery event %x\n", DEVNAME(sc), @@ -413,5 +414,9 @@ acpibat_notify(struct aml_node *node, int notify_type, void *arg) break; } + acpibat_getbif(sc); + acpibat_getbst(sc); + acpibat_refresh(sc); + return (0); } |