diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-08-05 13:13:18 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-08-05 13:13:18 +0000 |
commit | 86df2b0fcdc2ab7d6dba8b49aa56e3a0d6ef3ae4 (patch) | |
tree | 106e7297dfab55be2f48bd414d88b828705de9f1 /sys/dev/bluetooth/btkbd.c | |
parent | bc04296ac2ac7e8cf4d50d37943b78b6833a1bd6 (diff) |
Allow bthidev_output() to not grab the bt lock, to prevent lock
recursion when trying to send commands from input callbacks. Makes the
caps/num/scroll lock keys on btkbd correctly lit the leds instead of
panic'ing.
Noticed and fix tested by mlarkin@, "do whatever you want in bt" deraadt@
Diffstat (limited to 'sys/dev/bluetooth/btkbd.c')
-rw-r--r-- | sys/dev/bluetooth/btkbd.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/sys/dev/bluetooth/btkbd.c b/sys/dev/bluetooth/btkbd.c index ff34824c200..5de8553c04a 100644 --- a/sys/dev/bluetooth/btkbd.c +++ b/sys/dev/bluetooth/btkbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: btkbd.c,v 1.6 2010/07/31 16:04:50 miod Exp $ */ +/* $OpenBSD: btkbd.c,v 1.7 2010/08/05 13:13:17 miod Exp $ */ /* $NetBSD: btkbd.c,v 1.10 2008/09/09 03:54:56 cube Exp $ */ /* @@ -90,7 +90,8 @@ struct btkbd_softc { struct bthidev sc_hidev; /* device */ struct hidkbd sc_kbd; /* keyboard state */ int (*sc_output) /* output method */ - (struct bthidev *, uint8_t *, int); + (struct bthidev *, uint8_t *, int, int); + int sc_inintr; }; /* autoconf(9) methods */ @@ -188,7 +189,7 @@ btkbd_set_leds(void *self, int leds) if (hidkbd_set_leds(kbd, leds, &report) != 0) { if (sc->sc_output != NULL) (*sc->sc_output)(&sc->sc_hidev, &report, - sizeof(report)); + sizeof(report), sc->sc_inintr); } } @@ -216,6 +217,9 @@ btkbd_input(struct bthidev *self, uint8_t *data, int len) struct btkbd_softc *sc = (struct btkbd_softc *)self; struct hidkbd *kbd = &sc->sc_kbd; - if (kbd->sc_enabled != 0) + if (kbd->sc_enabled != 0) { + sc->sc_inintr = 1; hidkbd_input(kbd, data, len); + sc->sc_inintr = 0; + } } |