diff options
| author | macallan <macallan@NetBSD.org> | 2007-04-16 23:33:10 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2007-04-16 23:33:10 +0000 |
| commit | 9fbe2d39ef6a8dc3e50931fcb4af4a3e6b46795e (patch) | |
| tree | ed87993697741728aa838e2d4492ea62f8b481c9 /sys/dev | |
| parent | 1fcc2e9929ea0b4c860ed188b85618fd76247962 (diff) | |
don't panic when someone presses the power button without powerd running
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/adb/adb_kbd.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/dev/adb/adb_kbd.c b/sys/dev/adb/adb_kbd.c index 90d7d34cb98..4048cdd3826 100644 --- a/sys/dev/adb/adb_kbd.c +++ b/sys/dev/adb/adb_kbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb_kbd.c,v 1.8 2007/04/16 02:12:11 macallan Exp $ */ +/* $NetBSD: adb_kbd.c,v 1.9 2007/04/16 23:33:10 macallan Exp $ */ /* * Copyright (C) 1998 Colin Wood @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.8 2007/04/16 02:12:11 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.9 2007/04/16 23:33:10 macallan Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -84,7 +84,7 @@ struct adbkbd_softc { uint8_t sc_buffer[16]; uint8_t sc_pollbuf[16]; uint8_t sc_us; - uint8_t sc_power; + uint8_t sc_power, sc_pe; }; /* @@ -108,6 +108,7 @@ static int adbkbd_enable(void *, int); static int adbkbd_ioctl(void *, u_long, void *, int, struct lwp *); static void adbkbd_set_leds(void *, int); static void adbkbd_handler(void *, int, uint8_t *); +static void adbkbd_powerbutton(void *); struct wskbd_accessops adbkbd_accessops = { adbkbd_enable, @@ -377,13 +378,8 @@ adbkbd_keys(struct adbkbd_softc *sc, uint8_t k1, uint8_t k2) if (((k1 == k2) && (k1 == 0x7f)) || (k1 == sc->sc_power)) { /* power button, report to sysmon */ -#if 1 - sysmon_pswitch_event(&sc->sc_sm_pbutton, - ADBK_PRESS(k1) ? PSWITCH_EVENT_PRESSED : - PSWITCH_EVENT_RELEASED); -#else - printf("[%02x %02x]", k1, k2); -#endif + sc->sc_pe = k1; + sysmon_task_queue_sched(0, adbkbd_powerbutton, sc); } else { adbkbd_key(sc, k1); @@ -392,6 +388,16 @@ adbkbd_keys(struct adbkbd_softc *sc, uint8_t k1, uint8_t k2) } } +static void +adbkbd_powerbutton(void *cookie) +{ + struct adbkbd_softc *sc = cookie; + + sysmon_pswitch_event(&sc->sc_sm_pbutton, + ADBK_PRESS(sc->sc_pe) ? PSWITCH_EVENT_PRESSED : + PSWITCH_EVENT_RELEASED); +} + static inline void adbkbd_key(struct adbkbd_softc *sc, uint8_t k) { |
