CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: thorpej Date: Mon Jun 8 20:20:54 UTC 2020 Modified Files: src/sys/dev/bluetooth: bthub.c Log Message: Update for proplib(3) API changes. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/bluetooth/bthub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthub.c diff -u src/sys/dev/bluetooth/bthub.c:1.22 src/sys/dev/bluetooth/bthub.c:1.23 --- src/sys/dev/bluetooth/bthub.c:1.22 Sat May 9 22:23:40 2015 +++ src/sys/dev/bluetooth/bthub.c Mon Jun 8 20:20:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bthub.c,v 1.22 2015/05/09 22:23:40 dholland Exp $ */ +/* $NetBSD: bthub.c,v 1.23 2020/06/08 20:20:54 thorpej Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.22 2015/05/09 22:23:40 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.23 2020/06/08 20:20:54 thorpej Exp $"); #include #include @@ -110,7 +110,7 @@ bthub_attach(device_t parent, device_t s prop_object_t obj; dict = device_properties(self); - obj = prop_data_create_data(addr, sizeof(*addr)); + obj = prop_data_create_copy(addr, sizeof(*addr)); prop_dictionary_set(dict, BTDEVladdr, obj); prop_object_release(obj);
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: maxv Date: Sat Mar 14 04:49:33 UTC 2020 Modified Files: src/sys/dev/bluetooth: btkbd.c Log Message: fix memory leaks To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/dev/bluetooth/btkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btkbd.c diff -u src/sys/dev/bluetooth/btkbd.c:1.18 src/sys/dev/bluetooth/btkbd.c:1.19 --- src/sys/dev/bluetooth/btkbd.c:1.18 Sun Dec 10 17:03:07 2017 +++ src/sys/dev/bluetooth/btkbd.c Sat Mar 14 04:49:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: btkbd.c,v 1.18 2017/12/10 17:03:07 bouyer Exp $ */ +/* $NetBSD: btkbd.c,v 1.19 2020/03/14 04:49:33 maxv Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.18 2017/12/10 17:03:07 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.19 2020/03/14 04:49:33 maxv Exp $"); #include #include @@ -281,8 +281,10 @@ btkbd_parse_desc(struct btkbd_softc *sc, continue; if (h.flags & HIO_VARIABLE) { - if (h.loc.size != 1) + if (h.loc.size != 1) { +hid_end_parse(d); return ("bad modifier size"); + } /* Single item */ if (imod < MAXMOD) { @@ -290,22 +292,28 @@ btkbd_parse_desc(struct btkbd_softc *sc, sc->sc_mods[imod].mask = 1 << imod; sc->sc_mods[imod].key = HID_GET_USAGE(h.usage); imod++; - } else + } else { +hid_end_parse(d); return ("too many modifier keys"); + } } else { /* Array */ - if (h.loc.size != 8) + if (h.loc.size != 8) { +hid_end_parse(d); return ("key code size != 8"); - - if (h.loc.count > MAXKEYCODE) + } + if (h.loc.count > MAXKEYCODE) { +hid_end_parse(d); return ("too many key codes"); - - if (h.loc.pos % 8 != 0) + } + if (h.loc.pos % 8 != 0) { +hid_end_parse(d); return ("key codes not on byte boundary"); - - if (sc->sc_nkeycode != 0) + } + if (sc->sc_nkeycode != 0) { +hid_end_parse(d); return ("multiple key code arrays\n"); - + } sc->sc_keycodeloc = h.loc; sc->sc_nkeycode = h.loc.count; }
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Sun Sep 3 23:11:19 UTC 2017 Modified Files: src/sys/dev/bluetooth: bth5.c bth5.h Log Message: Remove references to BlueCore. Enable XON/XOFF flowcontrol in SLIP layer depending on config response. Send an acknowlegment packet on timeout/retry. Compute tx{ack,seq} and rx{ack,seq} according to the specification. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/bluetooth/bth5.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/bluetooth/bth5.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bth5.c diff -u src/sys/dev/bluetooth/bth5.c:1.4 src/sys/dev/bluetooth/bth5.c:1.5 --- src/sys/dev/bluetooth/bth5.c:1.4 Mon Aug 14 12:51:11 2017 +++ src/sys/dev/bluetooth/bth5.c Sun Sep 3 23:11:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: bth5.c,v 1.4 2017/08/14 12:51:11 nat Exp $ */ +/* $NetBSD: bth5.c,v 1.5 2017/09/03 23:11:19 nat Exp $ */ /* * Copyright (c) 2017 Nathanial Sloss * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.4 2017/08/14 12:51:11 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.5 2017/09/03 23:11:19 nat Exp $"); #include #include @@ -110,14 +110,16 @@ struct bth5_softc { MBUFQ_HEAD() sc_seqq; /* Sequencing Layer queue */ MBUFQ_HEAD() sc_seq_retryq; /* retry queue */ uint32_t sc_seq_txseq; - uint32_t sc_seq_txack; uint32_t sc_seq_expected_rxseq; + uint32_t sc_seq_total_rxpkts; + uint32_t sc_seq_winack; uint32_t sc_seq_winspace; uint32_t sc_seq_retries; callout_t sc_seq_timer; uint32_t sc_seq_timeout; uint32_t sc_seq_winsize; uint32_t sc_seq_retry_limit; + bool sc_oof_flow_control; /* variables of Datagram Queue Layer */ MBUFQ_HEAD() sc_dgq; /* Datagram Queue Layer queue */ @@ -500,10 +502,13 @@ bth5_slip_transmit(struct tty *tp) struct mbuf *m; int count, rlen; uint8_t *rptr; + int s; m = sc->sc_txp; if (m == NULL) { + s = spltty(); sc->sc_flags &= ~BTH5_XMIT; + splx(s); bth5_mux_transmit(sc); return 0; } @@ -526,12 +531,18 @@ bth5_slip_transmit(struct tty *tp) count++; if (sc->sc_slip_txrsv == BTH5_SLIP_ESCAPE_PKTEND || - sc->sc_slip_txrsv == BTH5_SLIP_ESCAPE_XON || - sc->sc_slip_txrsv == BTH5_SLIP_ESCAPE_XOFF || sc->sc_slip_txrsv == BTH5_SLIP_ESCAPE_ESCAPE) { rlen++; rptr++; } + if (sc->sc_oof_flow_control == true) { + if (sc->sc_slip_txrsv == BTH5_SLIP_ESCAPE_XON || + sc->sc_slip_txrsv == BTH5_SLIP_ESCAPE_XOFF) { +rlen++; +rptr++; + } + } + sc->sc_slip_txrsv = 0; } @@ -571,7 +582,8 @@ bth5_slip_transmit(struct tty *tp) } DPRINTFN(4, ("0x%02x ", BTH5_SLIP_ESCAPE_PKTEND)); rptr++; - } else if (*rptr == BTH5_SLIP_XON) { + } else if (sc->sc_oof_flow_control == true && *rptr == + BTH5_SLIP_XON) { if (putc(BTH5_SLIP_ESCAPE, &tp->t_outq) < 0) break; count++; @@ -583,7 +595,8 @@ bth5_slip_transmit(struct tty *tp) } DPRINTFN(4, ("0x%02x ", BTH5_SLIP_ESCAPE_XON)); rptr++; - } else if (*rptr == BTH5_SLIP_XOFF) { + } else if (sc->sc_oof_flow_control == true && *rptr == + BTH5_SLIP_XOFF) { if (putc(BTH5_SLIP_ESCAPE, &tp->t_outq) < 0) break; count++; @@ -728,10 +741,12 @@ bth5_slip_receive(int c, struct tty *tp) if (c == BTH5_SLIP_ESCAPE_PKTEND) mtod(m, uint8_t *)[m->m_len++] = BTH5_SLIP_PKTEND; - else if (c == BTH5_SLIP_ESCAPE_XON) + else if (sc->sc_oof_flow_control == true && + c == BTH5_SLIP_ESCAPE_XON) mtod(m, uint8_t *)[m->m_len++] = BTH5_SLIP_XON; - else if (c == BTH5_SLIP_ESCAPE_XOFF) + else if (sc->sc_oof_flow_control == true && + c == BTH5_SLIP_ESCAPE_XOFF) mtod(m, uint8_t *)[m->m_len++] = BTH5_SLIP_XOFF; else if (c == BTH5_SLIP_ESCAPE_ESCAPE) @@ -921,6 +936,7 @@ bth5_mux_transmit(struct bth5_softc *sc) { struct mbuf *m; bth5_hdr_t *hdrp; + int s; DPRINTFN(2, ("%s: mux transmit: sc_flags=0x%x, choke=%d", device_xname(sc->sc_dev), sc->sc_flags, sc->sc_mux_choke)); @@ -963,8 +979,12 @@ bth5_mux_transmit(struct bth5_softc *sc) hdrp->flags |= BTH5_FLAGS_PROTOCOL_REL; /* Reliable */ goto transmit; } - sc->sc_flags &= ~BTH5_XMIT; - bth5_start(sc); + + s = spltty(); + if ((sc->sc_flags & BTH5_XMIT) == 0) + bth5_start(sc); + splx(s); + if (sc->sc_mux_send_ack == true) { m = bth5_create_ackpkt(); if (m != NULL) @@ -975,6 +995,7 @@ bth5_mux_transmit(struct bth5_softc *sc) /* Nothing to send */ DPRINTFN(2, ("\n")); + return; transmit: @@ -1017,6 +1038,9 @@ bth5_mux_receive(struct bth5_softc *sc, if (BTH5_FLAGS_SEQ(hdrp->flags) == 0 && hdrp->ident == BTH5_IDENT_ACKPKT && BTH5_GET_PLEN(hdrp) == 0) { + sc->sc_seq_txseq = BTH5_FLAGS_ACK(hdrp->flags); + bth5_send_ack_command(sc); + bth5_mux_transmit(sc); m_freem(m); return; } @@ -1076,11 +1100,12 @@ static vo
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Mon Aug 14 12:51:11 UTC 2017 Modified Files: src/sys/dev/bluetooth: bth5.c Log Message: Apply the sequence number mask to txack. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/bluetooth/bth5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bth5.c diff -u src/sys/dev/bluetooth/bth5.c:1.3 src/sys/dev/bluetooth/bth5.c:1.4 --- src/sys/dev/bluetooth/bth5.c:1.3 Mon Aug 14 05:33:30 2017 +++ src/sys/dev/bluetooth/bth5.c Mon Aug 14 12:51:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $ */ +/* $NetBSD: bth5.c,v 1.4 2017/08/14 12:51:11 nat Exp $ */ /* * Copyright (c) 2017 Nathanial Sloss * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.4 2017/08/14 12:51:11 nat Exp $"); #include #include @@ -1149,7 +1149,7 @@ bth5_sequencing_receive(struct bth5_soft if (sc->sc_seq_expected_rxseq / sc->sc_seq_winsize == sc->sc_seq_winsize) { bth5_send_ack_command(sc); - sc->sc_seq_txack = sc->sc_seq_expected_rxseq; + sc->sc_seq_txack = sc->sc_seq_expected_rxseq & BTH5_FLAGS_SEQ_MASK; } else sc->sc_seq_txack = rxseq;
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Mon Aug 14 05:33:30 UTC 2017 Modified Files: src/sys/dev/bluetooth: bth5.c Log Message: Conform to the spec. with regards to acknowlegment packets. This prevents the host controller from freezing. Inmprove communication from inactive to active state. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/bluetooth/bth5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bth5.c diff -u src/sys/dev/bluetooth/bth5.c:1.2 src/sys/dev/bluetooth/bth5.c:1.3 --- src/sys/dev/bluetooth/bth5.c:1.2 Fri Aug 11 00:58:37 2017 +++ src/sys/dev/bluetooth/bth5.c Mon Aug 14 05:33:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $ */ +/* $NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $ */ /* * Copyright (c) 2017 Nathanial Sloss * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $"); #include #include @@ -1076,13 +1076,14 @@ static void bth5_sequencing_receive(struct bth5_softc *sc, struct mbuf *m) { bth5_hdr_t hdr; - uint32_t rxseq; + uint32_t exp_rxseq, rxseq; + exp_rxseq = sc->sc_seq_expected_rxseq & BTH5_FLAGS_SEQ_MASK; m_copydata(m, 0, sizeof(bth5_hdr_t), &hdr); rxseq = BTH5_FLAGS_SEQ(hdr.flags); DPRINTFN(1, ("%s: seq receive: rxseq=%d, expected %d\n", - device_xname(sc->sc_dev), rxseq, sc->sc_seq_expected_rxseq)); + device_xname(sc->sc_dev), rxseq, exp_rxseq)); #ifdef BTH5_DEBUG if (bth5_debug == 2) bth5_packet_print(m); @@ -1094,9 +1095,10 @@ bth5_sequencing_receive(struct bth5_soft */ m_adj(m, sizeof(bth5_hdr_t) - sizeof(uint8_t)); - if (rxseq != sc->sc_seq_expected_rxseq) { + if (rxseq != exp_rxseq) { m_freem(m); + bth5_send_ack_command(sc); /* send ack packet, if needly */ bth5_mux_transmit(sc); @@ -1144,10 +1146,15 @@ bth5_sequencing_receive(struct bth5_soft break; } + if (sc->sc_seq_expected_rxseq / sc->sc_seq_winsize == + sc->sc_seq_winsize) { + bth5_send_ack_command(sc); + sc->sc_seq_txack = sc->sc_seq_expected_rxseq; + } else + sc->sc_seq_txack = rxseq; + sc->sc_seq_expected_rxseq = - (sc->sc_seq_expected_rxseq + 1) & BTH5_FLAGS_SEQ_MASK; - sc->sc_seq_txack = sc->sc_seq_expected_rxseq; - bth5_send_ack_command(sc); + (sc->sc_seq_expected_rxseq + 1); } static bool @@ -1539,7 +1546,7 @@ bth5_input_le(struct bth5_softc *sc, str } else if (*rcvpkt == *(const uint16_t *)syncresp) { DPRINTF(("%s: state change to curious\n", device_xname(sc->sc_dev))); - + rplypkt = conf; callout_schedule(&sc->sc_le_timer, BTH5_LE_TCONF_TIMEOUT); sc->sc_le_state = le_state_curious; @@ -1551,6 +1558,8 @@ bth5_input_le(struct bth5_softc *sc, str case le_state_curious: if (*rcvpkt == *(const uint16_t *)sync) rplypkt = syncresp; + else if (*rcvpkt == *(const uint16_t *)syncresp) + rplypkt = conf; else if (*rcvpkt == *(const uint16_t *)conf) rplypkt = confresp; else if (*rcvpkt == *(const uint16_t *)confresp) {
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Fri Aug 11 00:58:37 UTC 2017 Modified Files: src/sys/dev/bluetooth: bth5.c Log Message: Ensure the XMIT flag is cleared before calling bth5_start. This avoids a panic due to a diagnostic assertion. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/dev/bluetooth/bth5.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bth5.c diff -u src/sys/dev/bluetooth/bth5.c:1.1 src/sys/dev/bluetooth/bth5.c:1.2 --- src/sys/dev/bluetooth/bth5.c:1.1 Thu Aug 10 13:22:19 2017 +++ src/sys/dev/bluetooth/bth5.c Fri Aug 11 00:58:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: bth5.c,v 1.1 2017/08/10 13:22:19 nat Exp $ */ +/* $NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $ */ /* * Copyright (c) 2017 Nathanial Sloss * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.1 2017/08/10 13:22:19 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $"); #include #include @@ -963,6 +963,7 @@ bth5_mux_transmit(struct bth5_softc *sc) hdrp->flags |= BTH5_FLAGS_PROTOCOL_REL; /* Reliable */ goto transmit; } + sc->sc_flags &= ~BTH5_XMIT; bth5_start(sc); if (sc->sc_mux_send_ack == true) { m = bth5_create_ackpkt();
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Thu Aug 10 13:22:19 UTC 2017 Modified Files: src/sys/dev/bluetooth: Makefile bluetoothdevices.config files.bluetooth Added Files: src/sys/dev/bluetooth: bth5.c bth5.h Log Message: Add support for btuart h5 3-wire protocol. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/dev/bluetooth/Makefile cvs rdiff -u -r1.1 -r1.2 src/sys/dev/bluetooth/bluetoothdevices.config cvs rdiff -u -r0 -r1.1 src/sys/dev/bluetooth/bth5.c \ src/sys/dev/bluetooth/bth5.h cvs rdiff -u -r1.14 -r1.15 src/sys/dev/bluetooth/files.bluetooth Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/Makefile diff -u src/sys/dev/bluetooth/Makefile:1.6 src/sys/dev/bluetooth/Makefile:1.7 --- src/sys/dev/bluetooth/Makefile:1.6 Tue Apr 15 11:17:48 2008 +++ src/sys/dev/bluetooth/Makefile Thu Aug 10 13:22:19 2017 @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.6 2008/04/15 11:17:48 plunky Exp $ +# $NetBSD: Makefile,v 1.7 2017/08/10 13:22:19 nat Exp $ INCSDIR= /usr/include/dev/bluetooth -INCS= bcsp.h btdev.h bthidev.h btsco.h +INCS= bcsp.h btdev.h bth5.h bthidev.h btsco.h .include Index: src/sys/dev/bluetooth/bluetoothdevices.config diff -u src/sys/dev/bluetooth/bluetoothdevices.config:1.1 src/sys/dev/bluetooth/bluetoothdevices.config:1.2 --- src/sys/dev/bluetooth/bluetoothdevices.config:1.1 Wed Jul 20 22:42:59 2011 +++ src/sys/dev/bluetooth/bluetoothdevices.config Thu Aug 10 13:22:19 2017 @@ -1,4 +1,4 @@ -# $NetBSD: bluetoothdevices.config,v 1.1 2011/07/20 22:42:59 jakllsch Exp $ +# $NetBSD: bluetoothdevices.config,v 1.2 2017/08/10 13:22:19 nat Exp $ # # Bluetooth devices for config(5) file inclusion. @@ -44,3 +44,4 @@ btsco* at bthub? # Bluetooth pseudo devices pseudo-device bcsp # BlueCore Serial Protocol pseudo-device btuart # Bluetooth HCI UART (H4) +pseudo-device bthfive # Bluetooth HCI UART (H5) Index: src/sys/dev/bluetooth/files.bluetooth diff -u src/sys/dev/bluetooth/files.bluetooth:1.14 src/sys/dev/bluetooth/files.bluetooth:1.15 --- src/sys/dev/bluetooth/files.bluetooth:1.14 Sat May 22 18:56:01 2010 +++ src/sys/dev/bluetooth/files.bluetooth Thu Aug 10 13:22:19 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.bluetooth,v 1.14 2010/05/22 18:56:01 plunky Exp $ +# $NetBSD: files.bluetooth,v 1.15 2017/08/10 13:22:19 nat Exp $ # # Config file for machine independent Bluetooth devices @@ -44,3 +44,7 @@ file dev/bluetooth/btuart.c btuart # BlueCore Serial Protocol defpseudodev bcsp: btbus, bluetooth file dev/bluetooth/bcsp.c bcsp + +# Bluetooth HCI UART (H5) +defpseudodev bthfive: btbus, bluetooth +file dev/bluetooth/bth5.c bthfive Added files: Index: src/sys/dev/bluetooth/bth5.c diff -u /dev/null src/sys/dev/bluetooth/bth5.c:1.1 --- /dev/null Thu Aug 10 13:22:19 2017 +++ src/sys/dev/bluetooth/bth5.c Thu Aug 10 13:22:19 2017 @@ -0,0 +1,1830 @@ +/* $NetBSD: bth5.c,v 1.1 2017/08/10 13:22:19 nat Exp $ */ +/* + * Copyright (c) 2017 Nathanial Sloss + * All rights reserved. + * + * Copyright (c) 2007 KIYOHARA Takashi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.1 2017/08/10 13:22:19 nat Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "ioconf.h" + +#ifdef BTH5_DEBUG +#ifdef DPRINTF +#undef DPRINTF +#endif +#ifdef DPRINTFN +#undef DPRINTFN +#endif + +#define DPRINTF(x) printf x +#define DPRINTFN(n, x) do { if (bth5_debug > (n)) printf x; } while (0) +int bth5_debug =
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Sun May 28 04:12:13 UTC 2017 Modified Files: src/sys/dev/bluetooth: btsco.c Log Message: bt_lock is now used as the audio interrupt lock. This is more appropriate as the interrupt lock deals with the hardware. btsco audio works again with the new audio changes. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/dev/bluetooth/btsco.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btsco.c diff -u src/sys/dev/bluetooth/btsco.c:1.34 src/sys/dev/bluetooth/btsco.c:1.35 --- src/sys/dev/bluetooth/btsco.c:1.34 Fri Jul 10 22:03:12 2015 +++ src/sys/dev/bluetooth/btsco.c Sun May 28 04:12:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: btsco.c,v 1.34 2015/07/10 22:03:12 nat Exp $ */ +/* $NetBSD: btsco.c,v 1.35 2017/05/28 04:12:13 nat Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.34 2015/07/10 22:03:12 nat Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.35 2017/05/28 04:12:13 nat Exp $"); #include #include @@ -97,7 +97,7 @@ struct btsco_softc { device_t sc_audio; /* MI audio device */ void *sc_intr; /* interrupt cookie */ kcondvar_t sc_connect; /* connect wait */ - kmutex_t sc_intr_lock; /* for audio */ + kmutex_t sc_lock; /* for audio */ /* Bluetooth */ bdaddr_t sc_laddr; /* local address */ @@ -295,7 +295,7 @@ btsco_attach(device_t parent, device_t s sc->sc_state = BTSCO_CLOSED; sc->sc_name = device_xname(self); cv_init(&sc->sc_connect, "connect"); - mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); /* * copy in our configuration info @@ -382,10 +382,12 @@ btsco_detach(device_t self, int flags) sc->sc_intr = NULL; } + mutex_enter(bt_lock); if (sc->sc_rx_mbuf != NULL) { m_freem(sc->sc_rx_mbuf); sc->sc_rx_mbuf = NULL; } + mutex_exit(bt_lock); if (sc->sc_tx_refcnt > 0) { aprint_error_dev(self, "tx_refcnt=%d!\n", sc->sc_tx_refcnt); @@ -395,7 +397,7 @@ btsco_detach(device_t self, int flags) } cv_destroy(&sc->sc_connect); - mutex_destroy(&sc->sc_intr_lock); + mutex_destroy(&sc->sc_lock); return 0; } @@ -462,7 +464,7 @@ btsco_sco_disconnected(void *arg, int er * has completed so that when it tries to send more, we * can indicate an error. */ - mutex_enter(&sc->sc_intr_lock); + mutex_enter(bt_lock); if (sc->sc_tx_pending > 0) { sc->sc_tx_pending = 0; (*sc->sc_tx_intr)(sc->sc_tx_intrarg); @@ -471,7 +473,7 @@ btsco_sco_disconnected(void *arg, int er sc->sc_rx_want = 0; (*sc->sc_rx_intr)(sc->sc_rx_intrarg); } - mutex_exit(&sc->sc_intr_lock); + mutex_exit(bt_lock); break; default: @@ -505,13 +507,11 @@ btsco_sco_complete(void *arg, int count) DPRINTFN(10, "%s count %d\n", sc->sc_name, count); - mutex_enter(&sc->sc_intr_lock); if (sc->sc_tx_pending > 0) { sc->sc_tx_pending -= count; if (sc->sc_tx_pending == 0) (*sc->sc_tx_intr)(sc->sc_tx_intrarg); } - mutex_exit(&sc->sc_intr_lock); } static void @@ -530,7 +530,6 @@ btsco_sco_input(void *arg, struct mbuf * DPRINTFN(10, "%s len=%d\n", sc->sc_name, m->m_pkthdr.len); - mutex_enter(&sc->sc_intr_lock); if (sc->sc_rx_want == 0) { m_freem(m); } else { @@ -556,7 +555,6 @@ btsco_sco_input(void *arg, struct mbuf * if (sc->sc_rx_want == 0) (*sc->sc_rx_intr)(sc->sc_rx_intrarg); } - mutex_exit(&sc->sc_intr_lock); } @@ -777,7 +775,7 @@ btsco_round_blocksize(void *hdl, int bs, /* * Start Output * - * We dont want to be calling the network stack with sc_intr_lock held + * We dont want to be calling the network stack with bt_lock held * so make a note of what is to be sent, and schedule an interrupt to * bundle it up and queue it. */ @@ -1079,8 +1077,8 @@ btsco_get_locks(void *hdl, kmutex_t **in { struct btsco_softc *sc = hdl; - *intr = &sc->sc_intr_lock; - *thread = bt_lock; + *thread = &sc->sc_lock; + *intr = bt_lock; } /* @@ -1141,12 +1139,12 @@ btsco_intr(void *arg) if (sc->sc_sco == NULL) return; /* connection is lost */ + mutex_enter(bt_lock); block = sc->sc_tx_block; size = sc->sc_tx_size; sc->sc_tx_block = NULL; sc->sc_tx_size = 0; - mutex_enter(bt_lock); while (size > 0) { MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL)
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: maxv Date: Mon Aug 15 08:20:11 UTC 2016 Modified Files: src/sys/dev/bluetooth: bcsp.c Log Message: Curious typo, found by mootja To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/bluetooth/bcsp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.29 src/sys/dev/bluetooth/bcsp.c:1.30 --- src/sys/dev/bluetooth/bcsp.c:1.29 Thu Aug 20 14:40:17 2015 +++ src/sys/dev/bluetooth/bcsp.c Mon Aug 15 08:20:11 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.29 2015/08/20 14:40:17 christos Exp $ */ +/* $NetBSD: bcsp.c,v 1.30 2016/08/15 08:20:11 maxv Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.29 2015/08/20 14:40:17 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.30 2016/08/15 08:20:11 maxv Exp $"); #include #include @@ -780,7 +780,7 @@ bcsp_pktintegrity_receive(struct bcsp_so u_int pldlen; int discard = 0; uint16_t crc = 0x; - const char *errstr + const char *errstr; DPRINTFN(3, ("%s: pi receive\n", device_xname(sc->sc_dev))); #ifdef BCSP_DEBUG
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Sun Dec 13 21:13:00 UTC 2015 Modified Files: src/sys/dev/bluetooth: btmagic.c Log Message: STRENGHT -> STRENGTH and misc spelling/whitespace. no functional change To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/dev/bluetooth/btmagic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btmagic.c diff -u src/sys/dev/bluetooth/btmagic.c:1.14 src/sys/dev/bluetooth/btmagic.c:1.15 --- src/sys/dev/bluetooth/btmagic.c:1.14 Fri Jul 3 14:18:18 2015 +++ src/sys/dev/bluetooth/btmagic.c Sun Dec 13 21:13:00 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: btmagic.c,v 1.14 2015/07/03 14:18:18 bouyer Exp $ */ +/* $NetBSD: btmagic.c,v 1.15 2015/12/13 21:13:00 plunky Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.14 2015/07/03 14:18:18 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.15 2015/12/13 21:13:00 plunky Exp $"); #include #include @@ -163,7 +163,7 @@ struct btmagic_softc { int sc_rw; /* previous touches */ - uint32_t sc_smask; /* active(s) IDs */ + uint32_t sc_smask; /* active IDs */ int sc_nfingers; /* number of active IDs */ int sc_ax[16]; int sc_ay[16]; @@ -234,7 +234,7 @@ static void btmagic_tapcallout(void *); #define TRACKPAD_REPORT_ID 0x28 #define MOUSE_REPORT_ID 0x29 #define BATT_STAT_REPORT_ID 0x30 -#define BATT_STRENGHT_REPORT_ID 0x47 +#define BATT_STRENGTH_REPORT_ID 0x47 #define SURFACE_REPORT_ID 0x61 static const struct btproto btmagic_ctl_proto = { @@ -1114,6 +1114,7 @@ btmagic_input(void *arg, struct mbuf *m) case TRACKPAD_REPORT_ID: /* Magic trackpad (input) */ btmagic_input_magict(sc, data + 2, len - 2); break; + case MOUSE_REPORT_ID: /* Magic touch (input) */ btmagic_input_magicm(sc, data + 2, len - 2); break; @@ -1131,7 +1132,7 @@ btmagic_input(void *arg, struct mbuf *m) } break; - case BATT_STRENGHT_REPORT_ID: /* Battery strength (feature) */ + case BATT_STRENGTH_REPORT_ID: /* Battery strength (feature) */ if (len != 3) break; @@ -1529,7 +1530,7 @@ btmagic_input_magict(struct btmagic_soft ay = hid_get_data(data, &toucht.aY); DPRINTF(sc, - "btmagic_input_magicm: id %d ax %d ay %d phase %ld %s\n", + "btmagic_input_magict: id %d ax %d ay %d phase %ld %s\n", id, ax, ay, hid_get_udata(data, &toucht.phase), bpress ? "button pressed" : "");
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nat Date: Fri Jul 10 22:03:12 UTC 2015 Modified Files: src/sys/dev/bluetooth: btsco.c Log Message: Wrap up calls to softint_schedule in kpeempt_[dis/en]able. Addresses PR kern/48459. This commit was approved by christos@ To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/bluetooth/btsco.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btsco.c diff -u src/sys/dev/bluetooth/btsco.c:1.33 src/sys/dev/bluetooth/btsco.c:1.34 --- src/sys/dev/bluetooth/btsco.c:1.33 Tue Aug 5 07:55:31 2014 +++ src/sys/dev/bluetooth/btsco.c Fri Jul 10 22:03:12 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: btsco.c,v 1.33 2014/08/05 07:55:31 rtr Exp $ */ +/* $NetBSD: btsco.c,v 1.34 2015/07/10 22:03:12 nat Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.33 2014/08/05 07:55:31 rtr Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.34 2015/07/10 22:03:12 nat Exp $"); #include #include @@ -798,7 +798,9 @@ btsco_start_output(void *hdl, void *bloc sc->sc_tx_intr = intr; sc->sc_tx_intrarg = intrarg; + kpreempt_disable(); softint_schedule(sc->sc_intr); + kpreempt_enable(); return 0; }
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: dholland Date: Sat May 9 22:23:40 UTC 2015 Modified Files: src/sys/dev/bluetooth: bthub.c Log Message: use standard idiom - thanks riastradh@ To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/bluetooth/bthub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthub.c diff -u src/sys/dev/bluetooth/bthub.c:1.21 src/sys/dev/bluetooth/bthub.c:1.22 --- src/sys/dev/bluetooth/bthub.c:1.21 Sat May 9 21:31:05 2015 +++ src/sys/dev/bluetooth/bthub.c Sat May 9 22:23:40 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bthub.c,v 1.21 2015/05/09 21:31:05 dholland Exp $ */ +/* $NetBSD: bthub.c,v 1.22 2015/05/09 22:23:40 dholland Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.21 2015/05/09 21:31:05 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.22 2015/05/09 22:23:40 dholland Exp $"); #include #include @@ -127,8 +127,7 @@ bthub_attach(device_t parent, device_t s * avoiding it needs a pretty big rearrangement of * device attachments. */ - printf("bthub_attach: pmf_device_register failed -- " - "no power management for you!\n"); + aprint_error_dev(self, "couldn't establish power handler\n"); } }
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: dholland Date: Sat May 9 21:31:05 UTC 2015 Modified Files: src/sys/dev/bluetooth: bthub.c Log Message: Coverity CID 975184: don't ignore pmf_device_register failure. (XXX: unfortunately all we can do for the moment is print a warning) To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/bluetooth/bthub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthub.c diff -u src/sys/dev/bluetooth/bthub.c:1.20 src/sys/dev/bluetooth/bthub.c:1.21 --- src/sys/dev/bluetooth/bthub.c:1.20 Fri Jul 25 08:10:36 2014 +++ src/sys/dev/bluetooth/bthub.c Sat May 9 21:31:05 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bthub.c,v 1.20 2014/07/25 08:10:36 dholland Exp $ */ +/* $NetBSD: bthub.c,v 1.21 2015/05/09 21:31:05 dholland Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.20 2014/07/25 08:10:36 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.21 2015/05/09 21:31:05 dholland Exp $"); #include #include @@ -121,7 +121,15 @@ bthub_attach(device_t parent, device_t s aprint_normal("\n"); - pmf_device_register(self, NULL, NULL); + if (!pmf_device_register(self, NULL, NULL)) { + /* + * XXX this should not be allowed to happen, but + * avoiding it needs a pretty big rearrangement of + * device attachments. + */ + printf("bthub_attach: pmf_device_register failed -- " + "no power management for you!\n"); + } } static int
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: christos Date: Fri May 8 11:47:53 UTC 2015 Modified Files: src/sys/dev/bluetooth: bcsp.c Log Message: goto out for negative lengths too. Really this test should either be removed or turned into a KASSERT(). From max. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/sys/dev/bluetooth/bcsp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.27 src/sys/dev/bluetooth/bcsp.c:1.28 --- src/sys/dev/bluetooth/bcsp.c:1.27 Thu Apr 30 12:01:51 2015 +++ src/sys/dev/bluetooth/bcsp.c Fri May 8 07:47:53 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.27 2015/04/30 16:01:51 christos Exp $ */ +/* $NetBSD: bcsp.c,v 1.28 2015/05/08 11:47:53 christos Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.27 2015/04/30 16:01:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.28 2015/05/08 11:47:53 christos Exp $"); #include #include @@ -1128,7 +1128,7 @@ bcsp_tx_reliable_pkt(struct bcsp_softc * for (pldlen = 0, _m = m; _m != NULL; _m = _m->m_next) { if (_m->m_len < 0) - return false; + goto out; pldlen += _m->m_len; } if (pldlen > 0xfff) @@ -1367,7 +1367,7 @@ bcsp_tx_unreliable_pkt(struct bcsp_softc for (pldlen = 0, _m = m; _m != NULL; _m = m->m_next) { if (_m->m_len < 0) - return false; + goto out; pldlen += _m->m_len; } DPRINTFN(1, (" pldlen=%d\n", pldlen));
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: christos Date: Thu Apr 30 16:01:52 UTC 2015 Modified Files: src/sys/dev/bluetooth: bcsp.c Log Message: Fix more memory leaks by changing the transmit routines to always free the mbuf to send. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/bluetooth/bcsp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.26 src/sys/dev/bluetooth/bcsp.c:1.27 --- src/sys/dev/bluetooth/bcsp.c:1.26 Mon Apr 27 13:36:41 2015 +++ src/sys/dev/bluetooth/bcsp.c Thu Apr 30 12:01:51 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.26 2015/04/27 17:36:41 christos Exp $ */ +/* $NetBSD: bcsp.c,v 1.27 2015/04/30 16:01:51 christos Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.26 2015/04/27 17:36:41 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.27 2015/04/30 16:01:51 christos Exp $"); #include #include @@ -1132,12 +1132,12 @@ bcsp_tx_reliable_pkt(struct bcsp_softc * pldlen += _m->m_len; } if (pldlen > 0xfff) - return false; + goto out; if (protocol_id == BCSP_IDENT_ACKPKT || protocol_id > 15) - return false; + goto out; if (sc->sc_seq_winspace == 0) - return false; + goto out; M_PREPEND(m, sizeof(bcsp_hdr_t), M_DONTWAIT); if (m == NULL) { @@ -1168,12 +1168,15 @@ bcsp_tx_reliable_pkt(struct bcsp_softc * _m = m_copym(m, 0, M_COPYALL, M_DONTWAIT); if (_m == NULL) { aprint_error_dev(sc->sc_dev, "out of memory\n"); - return false; + goto out; } MBUFQ_ENQUEUE(&sc->sc_seq_retryq, _m); bcsp_mux_transmit(sc); return true; +out: + m_freem(m); + return false; } #if 0 @@ -1369,9 +1372,9 @@ bcsp_tx_unreliable_pkt(struct bcsp_softc } DPRINTFN(1, (" pldlen=%d\n", pldlen)); if (pldlen > 0xfff) - return false; + goto out; if (protocol_id == BCSP_IDENT_ACKPKT || protocol_id > 15) - return false; + goto out; M_PREPEND(m, sizeof(bcsp_hdr_t), M_DONTWAIT); if (m == NULL) { @@ -1397,6 +1400,9 @@ bcsp_tx_unreliable_pkt(struct bcsp_softc bcsp_mux_transmit(sc); return true; +out: + m_freem(m); + return false; } #if 0 @@ -1442,7 +1448,6 @@ bcsp_start_le(struct bcsp_softc *sc) m->m_pkthdr.len = m->m_len = 0; m_copyback(m, 0, sizeof(sync), sync); if (!bcsp_tx_unreliable_pkt(sc, m, BCSP_CHANNEL_LE)) { - m_freem(m); aprint_error_dev(sc->sc_dev, "le-packet transmit failed\n"); return EINVAL;
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: christos Date: Mon Apr 27 17:36:41 UTC 2015 Modified Files: src/sys/dev/bluetooth: bcsp.c Log Message: free mbuf on failure (Brainy) To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/bluetooth/bcsp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.25 src/sys/dev/bluetooth/bcsp.c:1.26 --- src/sys/dev/bluetooth/bcsp.c:1.25 Sun Nov 16 11:20:00 2014 +++ src/sys/dev/bluetooth/bcsp.c Mon Apr 27 13:36:41 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.25 2014/11/16 16:20:00 ozaki-r Exp $ */ +/* $NetBSD: bcsp.c,v 1.26 2015/04/27 17:36:41 christos Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.25 2014/11/16 16:20:00 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.26 2015/04/27 17:36:41 christos Exp $"); #include #include @@ -1442,6 +1442,7 @@ bcsp_start_le(struct bcsp_softc *sc) m->m_pkthdr.len = m->m_len = 0; m_copyback(m, 0, sizeof(sync), sync); if (!bcsp_tx_unreliable_pkt(sc, m, BCSP_CHANNEL_LE)) { + m_freem(m); aprint_error_dev(sc->sc_dev, "le-packet transmit failed\n"); return EINVAL;
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: christos Date: Thu Apr 16 19:53:19 UTC 2015 Modified Files: src/sys/dev/bluetooth: btmagic.c Log Message: CID 1293640/1 memory corruption/overrun To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/dev/bluetooth/btmagic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btmagic.c diff -u src/sys/dev/bluetooth/btmagic.c:1.12 src/sys/dev/bluetooth/btmagic.c:1.13 --- src/sys/dev/bluetooth/btmagic.c:1.12 Mon Apr 6 13:45:31 2015 +++ src/sys/dev/bluetooth/btmagic.c Thu Apr 16 15:53:19 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: btmagic.c,v 1.12 2015/04/06 17:45:31 bouyer Exp $ */ +/* $NetBSD: btmagic.c,v 1.13 2015/04/16 19:53:19 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.12 2015/04/06 17:45:31 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.13 2015/04/16 19:53:19 christos Exp $"); #include #include @@ -1523,6 +1523,8 @@ btmagic_input_magict(struct btmagic_soft */ continue; } + if (id >= __arraycount(sc->sc_ax)) +continue; tx = ax - sc->sc_ax[id]; ty = ay - sc->sc_ay[id]; @@ -1562,6 +1564,9 @@ btmagic_input_magict(struct btmagic_soft break; } + if (id >= __arraycount(sc->sc_ax)) + continue; + sc->sc_ax[id] = ax; sc->sc_ay[id] = ay; }
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: bouyer Date: Mon Apr 6 17:45:31 UTC 2015 Modified Files: src/sys/dev/bluetooth: btmagic.c Log Message: Add support for Apple Magic Trackpad. 3 button emulation by detecting in which area of the bottom of the device the trackpad's button is pressed. Pointer move support with 1 finger touch, X/Y scroll with 2-finger touch. TODO: - detect tap to emulate button press and drag/n/drop. - Detect and support zoom, if wsmouse allows to report this To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/bluetooth/btmagic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btmagic.c diff -u src/sys/dev/bluetooth/btmagic.c:1.11 src/sys/dev/bluetooth/btmagic.c:1.12 --- src/sys/dev/bluetooth/btmagic.c:1.11 Tue Aug 5 07:55:31 2014 +++ src/sys/dev/bluetooth/btmagic.c Mon Apr 6 17:45:31 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: btmagic.c,v 1.11 2014/08/05 07:55:31 rtr Exp $ */ +/* $NetBSD: btmagic.c,v 1.12 2015/04/06 17:45:31 bouyer Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.11 2014/08/05 07:55:31 rtr Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.12 2015/04/06 17:45:31 bouyer Exp $"); #include #include @@ -163,11 +163,13 @@ struct btmagic_softc { int sc_rw; /* previous touches */ - uint32_t sc_smask; /* scrolling */ - int sc_az[16]; - int sc_aw[16]; + uint32_t sc_smask; /* active(s) IDs */ + int sc_nfingers; /* number of active IDs */ + int sc_ax[16]; + int sc_ay[16]; /* previous mouse buttons */ + int sc_mb_id; /* which ID selects the button */ uint32_t sc_mb; }; @@ -216,7 +218,16 @@ static void btmagic_complete(void *, in static void btmagic_linkmode(void *, int); static void btmagic_input(void *, struct mbuf *); static void btmagic_input_basic(struct btmagic_softc *, uint8_t *, size_t); -static void btmagic_input_magic(struct btmagic_softc *, uint8_t *, size_t); +static void btmagic_input_magicm(struct btmagic_softc *, uint8_t *, size_t); +static void btmagic_input_magict(struct btmagic_softc *, uint8_t *, size_t); + +/* report types (data[1]) */ +#define BASIC_REPORT_ID 0x10 +#define TRACKPAD_REPORT_ID 0x28 +#define MOUSE_REPORT_ID 0x29 +#define BATT_STAT_REPORT_ID 0x30 +#define BATT_STRENGHT_REPORT_ID 0x47 +#define SURFACE_REPORT_ID 0x61 static const struct btproto btmagic_ctl_proto = { btmagic_connecting, @@ -259,7 +270,8 @@ btmagic_match(device_t self, cfdata_t cf if (prop_dictionary_get_uint16(aux, BTDEVvendor, &v) && prop_dictionary_get_uint16(aux, BTDEVproduct, &p) && v == USB_VENDOR_APPLE - && p == USB_PRODUCT_APPLE_MAGICMOUSE) + && (p == USB_PRODUCT_APPLE_MAGICMOUSE || + p == USB_PRODUCT_APPLE_MAGICTRACKPAD)) return 2; /* trump bthidev(4) */ return 0; @@ -1047,15 +1059,18 @@ btmagic_input(void *arg, struct mbuf *m) break; switch (data[1]) { - case 0x10: /* Basic mouse (input) */ + case BASIC_REPORT_ID: /* Basic mouse (input) */ btmagic_input_basic(sc, data + 2, len - 2); break; - case 0x29: /* Magic touch (input) */ - btmagic_input_magic(sc, data + 2, len - 2); + case TRACKPAD_REPORT_ID: /* Magic trackpad (input) */ + btmagic_input_magict(sc, data + 2, len - 2); + break; + case MOUSE_REPORT_ID: /* Magic touch (input) */ + btmagic_input_magicm(sc, data + 2, len - 2); break; - case 0x30: /* Battery status (input) */ + case BATT_STAT_REPORT_ID: /* Battery status (input) */ if (len != 3) break; @@ -1068,7 +1083,7 @@ btmagic_input(void *arg, struct mbuf *m) } break; - case 0x47: /* Battery strength (feature) */ + case BATT_STRENGHT_REPORT_ID: /* Battery strength (feature) */ if (len != 3) break; @@ -1076,7 +1091,7 @@ btmagic_input(void *arg, struct mbuf *m) data[2]); break; - case 0x61: /* Surface detection (input) */ + case SURFACE_REPORT_ID: /* Surface detection (input) */ if (len != 3) break; @@ -1246,7 +1261,7 @@ static const struct { #define BTMAGIC_PHASE_CANCEL 0x0 static void -btmagic_input_magic(struct btmagic_softc *sc, uint8_t *data, size_t len) +btmagic_input_magicm(struct btmagic_softc *sc, uint8_t *data, size_t len) { uint32_t mb; int dx, dy, dz, dw; @@ -1290,10 +1305,12 @@ btmagic_input_magic(struct btmagic_softc switch (hid_get_udata(data, &touch.phase)) { case BTMAGIC_PHASE_CONT: +#define sc_az sc_ay +#define sc_aw sc_ax tz = az - sc->sc_az[id]; tw = aw - sc->sc_aw[id]; - if (ISSET(sc->sc_smask, id)) { + if (ISSET(sc->sc_smask, __BIT(id))) { /* scrolling finger */ dz += btmagic_scale(tz, &sc->sc_rz, sc->sc_resolution / sc->sc_scale); @@ -1307,7 +1324,7 @@ btmagic_input_magic(struct btmagic_softc sc->sc_rw
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: nonaka Date: Sat Dec 13 19:28:55 UTC 2014 Modified Files: src/sys/dev/bluetooth: btms.c Log Message: Added quirk for ELECOM M-XG2BB. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/dev/bluetooth/btms.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btms.c diff -u src/sys/dev/bluetooth/btms.c:1.11 src/sys/dev/bluetooth/btms.c:1.12 --- src/sys/dev/bluetooth/btms.c:1.11 Sat Oct 27 17:18:15 2012 +++ src/sys/dev/bluetooth/btms.c Sat Dec 13 19:28:55 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: btms.c,v 1.11 2012/10/27 17:18:15 chs Exp $ */ +/* $NetBSD: btms.c,v 1.12 2014/12/13 19:28:55 nonaka Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btms.c,v 1.11 2012/10/27 17:18:15 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btms.c,v 1.12 2014/12/13 19:28:55 nonaka Exp $"); #include #include @@ -86,6 +86,15 @@ __KERNEL_RCSID(0, "$NetBSD: btms.c,v 1.1 #include #include +#ifdef BTMS_DEBUG +int btms_debug = 0; +#define BTMSDBG(s) if (btms_debug) printf s +#define BTMSDBGN(n,s) if (btms_debug > (n)) printf s +#else +#define BTMSDBG(s) +#define BTMSDBGN(n,s) +#endif + #define MAX_BUTTONS 31 #define BUTTON(n) (1 << (((n) == 1 || (n) == 2) ? 3 - (n) : (n))) #define NOTMOUSE(f) (((f) & (HIO_CONST | HIO_RELATIVE)) != HIO_RELATIVE) @@ -135,6 +144,40 @@ static const struct wsmouse_accessops bt /* bthid methods */ static void btms_input(struct bthidev *, uint8_t *, int); +#ifdef BTMS_DEBUG +static void btms_print_device(struct btms_softc *); +#endif + +/* + * quirks + */ +static const struct btms_quirk { + int vendor; + int product; + + uint32_t flags; +#define BTMS_QUIRK_ELECOM __BIT(0) +} btms_quirk_table[] = { + /* ELECOM M-XG2BB */ + { 0x056e, 0x00d2, BTMS_QUIRK_ELECOM }, +}; + +static uint32_t +btms_lookup_quirk_flags(int vendor, int product) +{ + const struct btms_quirk *q; + int i; + + for (i = 0; i < __arraycount(btms_quirk_table); ++i) { + q = &btms_quirk_table[i]; + if (vendor == q->vendor && product == q->product) + return q->flags; + } + return 0; +} + +static void btms_fixup_elecom(struct bthidev_attach_args *,struct btms_softc *); + /* * * btms autoconf(9) routines @@ -159,11 +202,13 @@ btms_attach(device_t parent, device_t se struct bthidev_attach_args *ba = aux; struct wsmousedev_attach_args wsma; struct hid_location *zloc; - uint32_t flags; + uint32_t flags, quirks; int i, hl; ba->ba_input = btms_input; + quirks = btms_lookup_quirk_flags(ba->ba_vendor, ba->ba_product); + /* control the horizontal */ hl = hid_locate(ba->ba_desc, ba->ba_dlen, @@ -265,12 +310,19 @@ btms_attach(device_t parent, device_t se } sc->sc_num_buttons = i - 1; + if (ISSET(quirks, BTMS_QUIRK_ELECOM)) + btms_fixup_elecom(ba, sc); + aprint_normal(": %d button%s%s%s%s.\n", sc->sc_num_buttons, sc->sc_num_buttons == 1 ? "" : "s", sc->sc_flags & BTMS_HASW ? ", W" : "", sc->sc_flags & BTMS_HASZ ? " and Z dir" : "", sc->sc_flags & BTMS_HASW ? "s" : ""); +#ifdef BTMS_DEBUG + if (btms_debug) + btms_print_device(sc); +#endif wsma.accessops = &btms_wsmouse_accessops; wsma.accesscookie = sc; @@ -354,6 +406,16 @@ btms_input(struct bthidev *hidev, uint8_ if (sc->sc_wsmouse == NULL || sc->sc_enabled == 0) return; +#ifdef BTMS_DEBUG + if (btms_debug > 9) { + printf("%s: data: ", __func__); + for (i = 0; i < len; ++i) { + printf("%02x", data[i]); + } + printf("\n"); + } +#endif + dx = hid_get_data(data, &sc->sc_loc_x); dy = -hid_get_data(data, &sc->sc_loc_y); dz = hid_get_data(data, &sc->sc_loc_z); @@ -367,6 +429,8 @@ btms_input(struct bthidev *hidev, uint8_ if (hid_get_data(data, &sc->sc_loc_button[i])) buttons |= BUTTON(i); + BTMSDBGN(9,("%s: dx=%d, dy=%d, dz=%d, dw=%d, buttons=0x%08x\n", + __func__, dx, dy, dz, dw, buttons)); if (dx != 0 || dy != 0 || dz != 0 || dw != 0 || buttons != sc->sc_buttons) { sc->sc_buttons = buttons; @@ -378,3 +442,51 @@ btms_input(struct bthidev *hidev, uint8_ splx(s); } } + +#ifdef BTMS_DEBUG +static void +btms_print_device(struct btms_softc *sc) +{ + int i; + + printf("btms: X: pos=%d, size=%d\n", + sc->sc_loc_x.pos, sc->sc_loc_x.size); + printf("btms: Y: pos=%d, size=%d\n", + sc->sc_loc_y.pos, sc->sc_loc_y.size); + if (sc->sc_flags & BTMS_HASZ) { + printf("btms: Z: pos=%d, size=%d%s\n", + sc->sc_loc_z.pos, sc->sc_loc_z.size, + ((sc->sc_flags & BTMS_REVZ) ? ", REVZ" : "")); + } + if (sc->sc_flags & BTMS_HASW) { + printf("btms: W: pos=%d, size=%d\n", + sc->sc_loc_w.pos, sc->sc_loc_w.size); + } + + for (i = 0; i < sc->sc_num_buttons; ++i) { + printf("btms: button%d: pos=%d, size=%d\n", i, + sc->sc_loc_button[i].pos, sc->sc_loc_button[i].s
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: christos Date: Thu Oct 17 21:22:02 UTC 2013 Modified Files: src/sys/dev/bluetooth: bcsp.c Log Message: add __USE for debugging variables To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/bluetooth/bcsp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.21 src/sys/dev/bluetooth/bcsp.c:1.22 --- src/sys/dev/bluetooth/bcsp.c:1.21 Sat Jun 2 17:36:43 2012 +++ src/sys/dev/bluetooth/bcsp.c Thu Oct 17 17:22:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.21 2012/06/02 21:36:43 dsl Exp $ */ +/* $NetBSD: bcsp.c,v 1.22 2013/10/17 21:22:01 christos Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.21 2012/06/02 21:36:43 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.22 2013/10/17 21:22:01 christos Exp $"); #include #include @@ -722,8 +722,12 @@ bcsp_slip_receive(int c, struct tty *tp) } if (discard) { discarded: +#ifdef BCSP_DEBUG DPRINTFN(4, ("%s: receives unexpected byte 0x%02x: %s\n", device_xname(sc->sc_dev), c, errstr)); +#else + __USE(errstr); +#endif } sc->sc_stats.byte_rx++; @@ -782,7 +786,7 @@ bcsp_pktintegrity_receive(struct bcsp_so u_int pldlen; int discard = 0; uint16_t crc = 0x; - const char *errstr; + const char *errstr DPRINTFN(3, ("%s: pi receive\n", device_xname(sc->sc_dev))); #ifdef BCSP_DEBUG @@ -836,8 +840,12 @@ bcsp_pktintegrity_receive(struct bcsp_so if (discard) { discarded: +#ifdef BCSP_DEBUG DPRINTFN(3, ("%s: receives unexpected packet: %s\n", device_xname(sc->sc_dev), errstr)); +#else + __USE(errstr); +#endif m_freem(m); } else bcsp_mux_receive(sc, m);
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: martin Date: Thu Sep 12 12:20:01 UTC 2013 Modified Files: src/sys/dev/bluetooth: btkbd.c Log Message: #ifdef the "npress" variable, so it is only defined (and initialized) when it is also used. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/bluetooth/btkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btkbd.c diff -u src/sys/dev/bluetooth/btkbd.c:1.15 src/sys/dev/bluetooth/btkbd.c:1.16 --- src/sys/dev/bluetooth/btkbd.c:1.15 Sat Oct 27 17:18:15 2012 +++ src/sys/dev/bluetooth/btkbd.c Thu Sep 12 12:20:01 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: btkbd.c,v 1.15 2012/10/27 17:18:15 chs Exp $ */ +/* $NetBSD: btkbd.c,v 1.16 2013/09/12 12:20:01 martin Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.15 2012/10/27 17:18:15 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.16 2013/09/12 12:20:01 martin Exp $"); #include #include @@ -541,9 +541,11 @@ btkbd_input(struct bthidev *hidev, uint8 if (sc->sc_rawkbd) { u_char cbuf[MAXKEYS * 2]; int c; - int npress; +#ifdef BTKBD_REPEAT + int npress = 0; +#endif - for (npress = i = j = 0 ; i < nkeys ; i++) { + for (i = j = 0 ; i < nkeys ; i++) { key = ibuf[i]; c = btkbd_trtab[key & CODEMASK]; if (c == NN)
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Thu Dec 20 11:17:48 UTC 2012 Modified Files: src/sys/dev/bluetooth: bthidev.c btmagic.c Log Message: increase some diagnostics To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/bluetooth/btmagic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.23 src/sys/dev/bluetooth/bthidev.c:1.24 --- src/sys/dev/bluetooth/bthidev.c:1.23 Thu Dec 20 11:13:53 2012 +++ src/sys/dev/bluetooth/bthidev.c Thu Dec 20 11:17:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.23 2012/12/20 11:13:53 plunky Exp $ */ +/* $NetBSD: bthidev.c,v 1.24 2012/12/20 11:17:47 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.23 2012/12/20 11:13:53 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.24 2012/12/20 11:17:47 plunky Exp $"); #include #include @@ -193,6 +193,7 @@ bthidev_attach(device_t parent, device_t int locs[BTHIDBUSCF_NLOCS]; int maxid, rep, dlen; int vendor, product; + int err; /* * Init softc @@ -337,8 +338,9 @@ bthidev_attach(device_t parent, device_t * start bluetooth connections */ mutex_enter(bt_lock); - if ((sc->sc_flags & BTHID_RECONNECT) == 0) - bthidev_listen(sc); + if ((sc->sc_flags & BTHID_RECONNECT) == 0 + && (err = bthidev_listen(sc)) != 0) + aprint_error_dev(self, "failed to listen (%d)\n", err); if (sc->sc_flags & BTHID_CONNECTING) bthidev_connect(sc); @@ -561,8 +563,10 @@ bthidev_connect(struct bthidev_softc *sc } err = l2cap_setopt(sc->sc_ctl, &sc->sc_mode); - if (err) + if (err) { + aprint_error_dev(sc->sc_dev, "l2cap_setopt failed (%d)\n", err); return err; + } bdaddr_copy(&sa.bt_bdaddr, &sc->sc_laddr); err = l2cap_bind(sc->sc_ctl, &sa); @@ -802,7 +806,7 @@ bthidev_ctl_disconnected(void *arg, int sc->sc_state = BTHID_CLOSED; if (sc->sc_int == NULL) { - aprint_normal_dev(sc->sc_dev, "disconnected\n"); + aprint_normal_dev(sc->sc_dev, "disconnected (%d)\n", err); sc->sc_flags &= ~BTHID_CONNECTING; if (sc->sc_flags & BTHID_RECONNECT) @@ -834,7 +838,7 @@ bthidev_int_disconnected(void *arg, int sc->sc_state = BTHID_CLOSED; if (sc->sc_ctl == NULL) { - aprint_normal_dev(sc->sc_dev, "disconnected\n"); + aprint_normal_dev(sc->sc_dev, "disconnected (%d)\n", err); sc->sc_flags &= ~BTHID_CONNECTING; if (sc->sc_flags & BTHID_RECONNECT) Index: src/sys/dev/bluetooth/btmagic.c diff -u src/sys/dev/bluetooth/btmagic.c:1.4 src/sys/dev/bluetooth/btmagic.c:1.5 --- src/sys/dev/bluetooth/btmagic.c:1.4 Thu Dec 20 11:13:53 2012 +++ src/sys/dev/bluetooth/btmagic.c Thu Dec 20 11:17:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: btmagic.c,v 1.4 2012/12/20 11:13:53 plunky Exp $ */ +/* $NetBSD: btmagic.c,v 1.5 2012/12/20 11:17:47 plunky Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.4 2012/12/20 11:13:53 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.5 2012/12/20 11:17:47 plunky Exp $"); #include #include @@ -272,6 +272,7 @@ btmagic_attach(device_t parent, device_t struct wsmousedev_attach_args wsma; const struct sysctlnode *node; prop_object_t obj; + int err; /* * Init softc @@ -392,7 +393,8 @@ btmagic_attach(device_t parent, device_t * start bluetooth connections */ mutex_enter(bt_lock); - btmagic_listen(sc); + if ((err = btmagic_listen(sc)) != 0) + aprint_error_dev(self, "failed to listen (%d)\n", err); btmagic_connect(sc); mutex_exit(bt_lock); } @@ -533,8 +535,11 @@ btmagic_connect(struct btmagic_softc *sc } err = l2cap_setopt(sc->sc_ctl, &sc->sc_mode); - if (err) + if (err) { + printf("%s: l2cap_setopt failed (%d)\n", + device_xname(sc->sc_dev), err); return err; + } bdaddr_copy(&sa.bt_bdaddr, &sc->sc_laddr); err = l2cap_bind(sc->sc_ctl, &sa); @@ -885,7 +890,7 @@ btmagic_ctl_disconnected(void *arg, int } if (sc->sc_int == NULL) { - printf("%s: disconnected\n", device_xname(sc->sc_dev)); + printf("%s: disconnected (%d)\n", device_xname(sc->sc_dev), err); CLR(sc->sc_flags, BTMAGIC_CONNECTING); sc->sc_state = BTMAGIC_WAIT_CTL; } else { @@ -911,7 +916,7 @@ btmagic_int_disconnected(void *arg, int } if (sc->sc_ctl == NULL) { - printf("%s: disconnected\n", device_xname(sc->sc_dev)); + printf("%s: disconnected (%d)\n", device_xname(sc->sc_dev), err); CLR(sc->sc_flags, BTMAGIC_CONNECTING); sc->sc_state = BTMAGIC_WAIT_CTL; } else {
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Thu Dec 20 11:13:54 UTC 2012 Modified Files: src/sys/dev/bluetooth: bthidev.c btmagic.c Log Message: when no link-mode is specified, explicitly set a mode of (int)0 otherwise l2cap_setmode() will fail during connection setup for bthidev.c, this fixes a problem with Microsoft Wedge Touch mouse (which may not be able to authenticate) for btmagic.c, include this fix in case somebody tries that related to PR/47286 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/bluetooth/btmagic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.22 src/sys/dev/bluetooth/bthidev.c:1.23 --- src/sys/dev/bluetooth/bthidev.c:1.22 Tue Apr 3 09:32:53 2012 +++ src/sys/dev/bluetooth/bthidev.c Thu Dec 20 11:13:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.22 2012/04/03 09:32:53 plunky Exp $ */ +/* $NetBSD: bthidev.c,v 1.23 2012/12/20 11:13:53 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.22 2012/04/03 09:32:53 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.23 2012/12/20 11:13:53 plunky Exp $"); #include #include @@ -241,7 +241,8 @@ bthidev_attach(device_t parent, device_t aprint_verbose(" %s %s", BTDEVmode, prop_string_cstring_nocopy(obj)); - } + } else + sockopt_setint(&sc->sc_mode, 0); obj = prop_dictionary_get(dict, BTHIDEVcontrolpsm); if (prop_object_type(obj) == PROP_TYPE_NUMBER) { Index: src/sys/dev/bluetooth/btmagic.c diff -u src/sys/dev/bluetooth/btmagic.c:1.3 src/sys/dev/bluetooth/btmagic.c:1.4 --- src/sys/dev/bluetooth/btmagic.c:1.3 Sat Jun 2 21:36:43 2012 +++ src/sys/dev/bluetooth/btmagic.c Thu Dec 20 11:13:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: btmagic.c,v 1.3 2012/06/02 21:36:43 dsl Exp $ */ +/* $NetBSD: btmagic.c,v 1.4 2012/12/20 11:13:53 plunky Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.3 2012/06/02 21:36:43 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.4 2012/12/20 11:13:53 plunky Exp $"); #include #include @@ -306,7 +306,8 @@ btmagic_attach(device_t parent, device_t aprint_verbose(" %s %s", BTDEVmode, prop_string_cstring_nocopy(obj)); - } + } else + sockopt_setint(&sc->sc_mode, 0); aprint_normal(": 3 buttons, W and Z dirs\n"); aprint_naive("\n");
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Tue Apr 3 09:32:54 UTC 2012 Modified Files: src/sys/dev/bluetooth: bthidev.c bthub.c btkbd.c btmagic.c btms.c btsco.c Log Message: register/deregister pmf(9) NULL handlers for bthub(4) and bluetooth devices which attach there, to fix PR/39006 To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.17 -r1.18 src/sys/dev/bluetooth/bthub.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/bluetooth/btkbd.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/bluetooth/btmagic.c cvs rdiff -u -r1.9 -r1.10 src/sys/dev/bluetooth/btms.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/bluetooth/btsco.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.21 src/sys/dev/bluetooth/bthidev.c:1.22 --- src/sys/dev/bluetooth/bthidev.c:1.21 Wed Jan 11 17:27:45 2012 +++ src/sys/dev/bluetooth/bthidev.c Tue Apr 3 09:32:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.21 2012/01/11 17:27:45 plunky Exp $ */ +/* $NetBSD: bthidev.c,v 1.22 2012/04/03 09:32:53 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.21 2012/01/11 17:27:45 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.22 2012/04/03 09:32:53 plunky Exp $"); #include #include @@ -330,6 +330,8 @@ bthidev_attach(device_t parent, device_t } } + pmf_device_register(self, NULL, NULL); + /* * start bluetooth connections */ @@ -382,6 +384,8 @@ bthidev_detach(device_t self, int flags) mutex_exit(bt_lock); + pmf_device_deregister(self); + /* kill off the input processor */ if (sc->sc_lwp != NULL) { mutex_enter(&sc->sc_lock); Index: src/sys/dev/bluetooth/bthub.c diff -u src/sys/dev/bluetooth/bthub.c:1.17 src/sys/dev/bluetooth/bthub.c:1.18 --- src/sys/dev/bluetooth/bthub.c:1.17 Sun Jul 31 13:51:53 2011 +++ src/sys/dev/bluetooth/bthub.c Tue Apr 3 09:32:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bthub.c,v 1.17 2011/07/31 13:51:53 uebayasi Exp $ */ +/* $NetBSD: bthub.c,v 1.18 2012/04/03 09:32:53 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.17 2011/07/31 13:51:53 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.18 2012/04/03 09:32:53 plunky Exp $"); #include #include @@ -110,12 +110,16 @@ bthub_attach(device_t parent, device_t s addr->b[2], addr->b[1], addr->b[0]); aprint_normal("\n"); + + pmf_device_register(self, NULL, NULL); } static int bthub_detach(device_t self, int flags) { + pmf_device_deregister(self); + return config_detach_children(self, flags); } Index: src/sys/dev/bluetooth/btkbd.c diff -u src/sys/dev/bluetooth/btkbd.c:1.13 src/sys/dev/bluetooth/btkbd.c:1.14 --- src/sys/dev/bluetooth/btkbd.c:1.13 Wed Jan 11 17:27:45 2012 +++ src/sys/dev/bluetooth/btkbd.c Tue Apr 3 09:32:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: btkbd.c,v 1.13 2012/01/11 17:27:45 plunky Exp $ */ +/* $NetBSD: btkbd.c,v 1.14 2012/04/03 09:32:53 plunky Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.13 2012/01/11 17:27:45 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.14 2012/04/03 09:32:53 plunky Exp $"); #include #include @@ -237,6 +237,8 @@ btkbd_attach(device_t parent, device_t s wska.accesscookie = sc; sc->sc_wskbd = config_found(self, &wska, wskbddevprint); + + pmf_device_register(self, NULL, NULL); } static int @@ -245,6 +247,8 @@ btkbd_detach(device_t self, int flags) struct btkbd_softc *sc = device_private(self); int err = 0; + pmf_device_deregister(self); + #ifdef WSDISPLAY_COMPAT_RAWKBD #ifdef BTKBD_REPEAT callout_stop(&sc->sc_repeat); Index: src/sys/dev/bluetooth/btmagic.c diff -u src/sys/dev/bluetooth/btmagic.c:1.1 src/sys/dev/bluetooth/btmagic.c:1.2 --- src/sys/dev/bluetooth/btmagic.c:1.1 Sat May 22 18:56:01 2010 +++ src/sys/dev/bluetooth/btmagic.c Tue Apr 3 09:32:53 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: btmagic.c,v 1.1 2010/05/22 18:56:01 plunky Exp $ */ +/* $NetBSD: btmagic.c,v 1.2 2012/04/03 09:32:53 plunky Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -85,7 +85,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.1 2010/05/22 18:56:01 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.2 2012/04/03 09:32:53 plunky Exp $"); #include #include @@ -385,6 +385,8 @@ btmagic_attach(device_t parent, device_t return; } + pmf_device_register(self, NULL, NULL); + /* * start bluetooth connections */ @@ -433,6 +435,8 @@ btmagic_detach(device_t self, int flags) mutex_exit(bt_lock); + pmf_device_deregister(self); + sockopt_dest
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: mrg Date: Mon Mar 26 06:49:16 UTC 2012 Modified Files: src/sys/dev/bluetooth: btsco.c Log Message: don't use mutex_spin*() on an IPL_NONE mutex. fixes PR#46120. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/bluetooth/btsco.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btsco.c diff -u src/sys/dev/bluetooth/btsco.c:1.26 src/sys/dev/bluetooth/btsco.c:1.27 --- src/sys/dev/bluetooth/btsco.c:1.26 Sat Dec 10 16:16:11 2011 +++ src/sys/dev/bluetooth/btsco.c Mon Mar 26 06:49:15 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: btsco.c,v 1.26 2011/12/10 16:16:11 jmcneill Exp $ */ +/* $NetBSD: btsco.c,v 1.27 2012/03/26 06:49:15 mrg Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.26 2011/12/10 16:16:11 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.27 2012/03/26 06:49:15 mrg Exp $"); #include #include @@ -458,7 +458,7 @@ btsco_sco_disconnected(void *arg, int er * has completed so that when it tries to send more, we * can indicate an error. */ - mutex_spin_enter(&sc->sc_intr_lock); + mutex_enter(&sc->sc_intr_lock); if (sc->sc_tx_pending > 0) { sc->sc_tx_pending = 0; (*sc->sc_tx_intr)(sc->sc_tx_intrarg); @@ -467,7 +467,7 @@ btsco_sco_disconnected(void *arg, int er sc->sc_rx_want = 0; (*sc->sc_rx_intr)(sc->sc_rx_intrarg); } - mutex_spin_exit(&sc->sc_intr_lock); + mutex_exit(&sc->sc_intr_lock); break; default: @@ -501,13 +501,13 @@ btsco_sco_complete(void *arg, int count) DPRINTFN(10, "%s count %d\n", sc->sc_name, count); - mutex_spin_enter(&sc->sc_intr_lock); + mutex_enter(&sc->sc_intr_lock); if (sc->sc_tx_pending > 0) { sc->sc_tx_pending -= count; if (sc->sc_tx_pending == 0) (*sc->sc_tx_intr)(sc->sc_tx_intrarg); } - mutex_spin_exit(&sc->sc_intr_lock); + mutex_exit(&sc->sc_intr_lock); } static void @@ -526,7 +526,7 @@ btsco_sco_input(void *arg, struct mbuf * DPRINTFN(10, "%s len=%d\n", sc->sc_name, m->m_pkthdr.len); - mutex_spin_enter(&sc->sc_intr_lock); + mutex_enter(&sc->sc_intr_lock); if (sc->sc_rx_want == 0) { m_freem(m); } else { @@ -552,7 +552,7 @@ btsco_sco_input(void *arg, struct mbuf * if (sc->sc_rx_want == 0) (*sc->sc_rx_intr)(sc->sc_rx_intrarg); } - mutex_spin_exit(&sc->sc_intr_lock); + mutex_exit(&sc->sc_intr_lock); }
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Wed Jan 11 17:27:45 UTC 2012 Modified Files: src/sys/dev/bluetooth: bthidev.c btkbd.c Log Message: offset processing of input reports to a kernel thread, to avoid locking issues when a child device needs to call back into the Bluetooth stack (eg when caps-lock is pressed, and wskbd wants to change a LED) (as discussed with Radoslaw Kujawa) To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.12 -r1.13 src/sys/dev/bluetooth/btkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.20 src/sys/dev/bluetooth/bthidev.c:1.21 --- src/sys/dev/bluetooth/bthidev.c:1.20 Sat Dec 31 01:16:09 2011 +++ src/sys/dev/bluetooth/bthidev.c Wed Jan 11 17:27:45 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.20 2011/12/31 01:16:09 rkujawa Exp $ */ +/* $NetBSD: bthidev.c,v 1.21 2012/01/11 17:27:45 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,16 +32,19 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.20 2011/12/31 01:16:09 rkujawa Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.21 2012/01/11 17:27:45 plunky Exp $"); #include +#include #include #include #include #include +#include #include #include #include +#include #include #include #include @@ -83,6 +86,12 @@ struct bthidev_softc { struct l2cap_channel *sc_int; /* interrupt channel */ struct l2cap_channel *sc_int_l; /* interrupt listen */ + MBUFQ_HEAD() sc_inq; /* input queue */ + kmutex_t sc_lock; /* input queue lock */ + kcondvar_t sc_cv; /* input queue trigger */ + lwp_t *sc_lwp; /* input queue processor */ + int sc_detach; + LIST_HEAD(,bthidev) sc_list; /* child list */ callout_t sc_reconnect; @@ -107,6 +116,8 @@ static int bthidev_listen(struct bthide static int bthidev_connect(struct bthidev_softc *); static int bthidev_output(struct bthidev *, uint8_t *, int); static void bthidev_null(struct bthidev *, uint8_t *, int); +static void bthidev_process(void *); +static void bthidev_process_one(struct bthidev_softc *, struct mbuf *); /* autoconf(9) glue */ static int bthidev_match(device_t, cfdata_t, void *); @@ -188,6 +199,7 @@ bthidev_attach(device_t parent, device_t */ sc->sc_dev = self; LIST_INIT(&sc->sc_list); + MBUFQ_INIT(&sc->sc_inq); callout_init(&sc->sc_reconnect, 0); callout_setfunc(&sc->sc_reconnect, bthidev_timeout, sc); sc->sc_state = BTHID_CLOSED; @@ -196,6 +208,8 @@ bthidev_attach(device_t parent, device_t sc->sc_intpsm = L2CAP_PSM_HID_INTR; sockopt_init(&sc->sc_mode, BTPROTO_L2CAP, SO_L2CAP_LM, 0); + mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(&sc->sc_cv, device_xname(self)); /* * extract config from proplist @@ -280,6 +294,12 @@ bthidev_attach(device_t parent, device_t aprint_normal("\n"); + if (kthread_create(PRI_NONE, KTHREAD_MUSTJOIN, NULL, bthidev_process, + sc, &sc->sc_lwp, "%s", device_xname(self)) != 0) { + aprint_error_dev(self, "failed to create input thread\n"); + return; + } + for (rep = 0 ; rep <= maxid ; rep++) { if (hid_report_size(desc, dlen, hid_feature, rep) == 0 && hid_report_size(desc, dlen, hid_input, rep) == 0 @@ -362,12 +382,25 @@ bthidev_detach(device_t self, int flags) mutex_exit(bt_lock); + /* kill off the input processor */ + if (sc->sc_lwp != NULL) { + mutex_enter(&sc->sc_lock); + sc->sc_detach = 1; + cv_signal(&sc->sc_cv); + mutex_exit(&sc->sc_lock); + kthread_join(sc->sc_lwp); + sc->sc_lwp = NULL; + } + /* detach children */ while ((hidev = LIST_FIRST(&sc->sc_list)) != NULL) { LIST_REMOVE(hidev, sc_next); config_detach(hidev->sc_dev, flags); } + MBUFQ_DRAIN(&sc->sc_inq); + cv_destroy(&sc->sc_cv); + mutex_destroy(&sc->sc_lock); sockopt_destroy(&sc->sc_mode); return 0; @@ -545,6 +578,123 @@ bthidev_connect(struct bthidev_softc *sc return 0; } +/* + * The LWP which processes input reports, forwarding to child devices. + * We are always either processing input reports, holding the lock, or + * waiting for a signal on condvar. + */ +static void +bthidev_process(void *arg) +{ + struct bthidev_softc *sc = arg; + struct mbuf *m; + + mutex_enter(&sc->sc_lock); + while (sc->sc_detach == 0) { + MBUFQ_DEQUEUE(&sc->sc_inq, m); + if (m == NULL) { + cv_wait(&sc->sc_cv, &sc->sc_lock); + continue; + } + + mutex_exit(&sc->sc_lock); + bthidev_process_one(sc, m); + m_freem(m); + mutex_enter(&sc->sc_lock); + } + mutex_exit(&sc->sc_lock); + kthread_exit(0); +} + +static void +bthidev_process_one(struct bthidev_softc *sc, struct mbuf *m) +{ + struct bthidev *hidev; + uint8_t *data; + int len; + + if (sc->sc_state != BTHID_OPEN) + return; + + if (m->m_pkthdr.len > m->m_len) + aprint_error_dev(sc->sc_dev, "truncating HID report\n"); + + len = m->m_len; + data
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: rkujawa Date: Sat Dec 31 01:16:09 UTC 2011 Modified Files: src/sys/dev/bluetooth: bthidev.c btkbd.c Log Message: Fix panic triggered by pressing the caps lock key: http://c0ff33.net/drop/bt_caps_panic.jpg OK'd mrg. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/bluetooth/btkbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.19 src/sys/dev/bluetooth/bthidev.c:1.20 --- src/sys/dev/bluetooth/bthidev.c:1.19 Wed Apr 28 06:13:51 2010 +++ src/sys/dev/bluetooth/bthidev.c Sat Dec 31 01:16:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.19 2010/04/28 06:13:51 plunky Exp $ */ +/* $NetBSD: bthidev.c,v 1.20 2011/12/31 01:16:09 rkujawa Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.19 2010/04/28 06:13:51 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.20 2011/12/31 01:16:09 rkujawa Exp $"); #include #include @@ -919,9 +919,8 @@ bthidev_output(struct bthidev *hidev, ui memcpy(mtod(m, uint8_t *) + 2, report, rlen); m->m_pkthdr.len = m->m_len = rlen + 2; - mutex_enter(bt_lock); + KASSERT(mutex_owned(bt_lock)); err = l2cap_send(sc->sc_int, m); - mutex_exit(bt_lock); return err; } Index: src/sys/dev/bluetooth/btkbd.c diff -u src/sys/dev/bluetooth/btkbd.c:1.11 src/sys/dev/bluetooth/btkbd.c:1.12 --- src/sys/dev/bluetooth/btkbd.c:1.11 Tue May 12 12:10:46 2009 +++ src/sys/dev/bluetooth/btkbd.c Sat Dec 31 01:16:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: btkbd.c,v 1.11 2009/05/12 12:10:46 cegger Exp $ */ +/* $NetBSD: btkbd.c,v 1.12 2011/12/31 01:16:09 rkujawa Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.11 2009/05/12 12:10:46 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btkbd.c,v 1.12 2011/12/31 01:16:09 rkujawa Exp $"); #include #include @@ -378,7 +378,9 @@ btkbd_ioctl(void *self, unsigned long cm break; case WSKBDIO_SETLEDS: + mutex_enter(bt_lock); btkbd_set_leds(sc, *(int *)data); + mutex_exit(bt_lock); break; case WSKBDIO_GETLEDS:
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: jmcneill Date: Sat Dec 10 16:16:11 UTC 2011 Modified Files: src/sys/dev/bluetooth: btsco.c Log Message: no need to acquire thread lock in btsco_open / btsco_close, as they are already held by MI audio when these methods are called To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/bluetooth/btsco.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btsco.c diff -u src/sys/dev/bluetooth/btsco.c:1.25 src/sys/dev/bluetooth/btsco.c:1.26 --- src/sys/dev/bluetooth/btsco.c:1.25 Wed Nov 23 23:07:31 2011 +++ src/sys/dev/bluetooth/btsco.c Sat Dec 10 16:16:11 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: btsco.c,v 1.25 2011/11/23 23:07:31 jmcneill Exp $ */ +/* $NetBSD: btsco.c,v 1.26 2011/12/10 16:16:11 jmcneill Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.25 2011/11/23 23:07:31 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.26 2011/12/10 16:16:11 jmcneill Exp $"); #include #include @@ -576,7 +576,7 @@ btsco_open(void *hdl, int flags) if (sc->sc_sco != NULL || sc->sc_sco_l != NULL) return EIO; - mutex_enter(bt_lock); + KASSERT(mutex_owned(bt_lock)); memset(&sa, 0, sizeof(sa)); sa.bt_len = sizeof(sa); @@ -653,8 +653,6 @@ btsco_open(void *hdl, int flags) } done: - mutex_exit(bt_lock); - DPRINTF("done err=%d, sc_state=%d, sc_mtu=%d\n", err, sc->sc_state, sc->sc_mtu); return err; @@ -667,7 +665,8 @@ btsco_close(void *hdl) DPRINTF("%s\n", sc->sc_name); - mutex_enter(bt_lock); + KASSERT(mutex_owned(bt_lock)); + if (sc->sc_sco != NULL) { sco_disconnect(sc->sc_sco, 0); sco_detach(&sc->sc_sco); @@ -676,7 +675,6 @@ btsco_close(void *hdl) if (sc->sc_sco_l != NULL) { sco_detach(&sc->sc_sco_l); } - mutex_exit(bt_lock); if (sc->sc_rx_mbuf != NULL) { m_freem(sc->sc_rx_mbuf);
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: jakllsch Date: Wed Jul 20 22:42:59 UTC 2011 Added Files: src/sys/dev/bluetooth: bluetoothdevices.config Log Message: Add config(5) fragment for MI bluetooth(4) drivers. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/dev/bluetooth/bluetoothdevices.config Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/dev/bluetooth/bluetoothdevices.config diff -u /dev/null src/sys/dev/bluetooth/bluetoothdevices.config:1.1 --- /dev/null Wed Jul 20 22:42:59 2011 +++ src/sys/dev/bluetooth/bluetoothdevices.config Wed Jul 20 22:42:59 2011 @@ -0,0 +1,46 @@ +# $NetBSD: bluetoothdevices.config,v 1.1 2011/07/20 22:42:59 jakllsch Exp $ +# +# Bluetooth devices for config(5) file inclusion. + +# Bluetooth Controller and Device support + +# Bluetooth PCMCIA Controllers +#bt3c* at pcmcia? function ? # 3Com 3CRWB6096-A +#btbc* at pcmcia? function ? # AnyCom BlueCard LSE041/039/139 + +# Bluetooth SDIO Controller +#sbt* at sdmmc? + +# Bluetooth USB Controllers +#ubt* at uhub? port ? + +# Bluetooth Device Hub +#bthub* at bcsp? +#bthub* at bt3c? +#bthub* at btbc? +#bthub* at btuart? +#bthub* at sbt? +#bthub* at ubt? + + +# Bluetooth HID support +bthidev* at bthub? + +# Bluetooth Mouse +btms* at bthidev? reportid ? +wsmouse* at btms? mux 0 + +# Bluetooth Keyboard +btkbd* at bthidev? reportid ? +wskbd* at btkbd? console ? mux 1 + +# Bluetooth Apple Magic Mouse +btmagic* at bthub? +wsmouse* at btmagic? mux 0 + +# Bluetooth Audio support +btsco* at bthub? + +# Bluetooth pseudo devices +pseudo-device bcsp # BlueCore Serial Protocol +pseudo-device btuart # Bluetooth HCI UART (H4)
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Wed Mar 16 21:38:54 UTC 2011 Modified Files: src/sys/dev/bluetooth: btsco.c Log Message: use C99 style for variadic macro arguments To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/bluetooth/btsco.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btsco.c diff -u src/sys/dev/bluetooth/btsco.c:1.23 src/sys/dev/bluetooth/btsco.c:1.24 --- src/sys/dev/bluetooth/btsco.c:1.23 Tue May 12 12:10:46 2009 +++ src/sys/dev/bluetooth/btsco.c Wed Mar 16 21:38:54 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: btsco.c,v 1.23 2009/05/12 12:10:46 cegger Exp $ */ +/* $NetBSD: btsco.c,v 1.24 2011/03/16 21:38:54 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.23 2009/05/12 12:10:46 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btsco.c,v 1.24 2011/03/16 21:38:54 plunky Exp $"); #include #include @@ -66,14 +66,18 @@ #ifdef BTSCO_DEBUG int btsco_debug = BTSCO_DEBUG; -#define DPRINTF(fmt, args...) do { \ - if (btsco_debug)\ - printf("%s: "fmt, __func__ , ##args); \ +#define DPRINTF(...) do { \ + if (btsco_debug) { \ + printf("%s: ", __func__); \ + printf(__VA_ARGS__); \ + } \ } while (/* CONSTCOND */0) -#define DPRINTFN(n, fmt, args...) do { \ - if (btsco_debug > (n))\ - printf("%s: "fmt, __func__ , ##args); \ +#define DPRINTFN(n, ...) do { \ + if (btsco_debug > (n)) { \ + printf("%s: ", __func__); \ + printf(__VA_ARGS__); \ + } \ } while (/* CONSTCOND */0) #else #define DPRINTF(...)
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Wed Apr 28 06:13:51 UTC 2010 Modified Files: src/sys/dev/bluetooth: btdev.h bthidev.c bthidev.h Log Message: allow for vendor-id and product-id properties, passing them through to child devices To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/dev/bluetooth/btdev.h cvs rdiff -u -r1.18 -r1.19 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/bluetooth/bthidev.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btdev.h diff -u src/sys/dev/bluetooth/btdev.h:1.8 src/sys/dev/bluetooth/btdev.h:1.9 --- src/sys/dev/bluetooth/btdev.h:1.8 Fri Mar 28 21:17:37 2008 +++ src/sys/dev/bluetooth/btdev.h Wed Apr 28 06:13:51 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: btdev.h,v 1.8 2008/03/28 21:17:37 plunky Exp $ */ +/* $NetBSD: btdev.h,v 1.9 2010/04/28 06:13:51 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -39,6 +39,8 @@ #define BTDEV_DETACH _IOW('b', 15, struct plistref) /* btdev properties */ +#define BTDEVvendor "vendor-id" +#define BTDEVproduct "product-id" #define BTDEVtype "device-type" #define BTDEVladdr "local-bdaddr" #define BTDEVraddr "remote-bdaddr" Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.18 src/sys/dev/bluetooth/bthidev.c:1.19 --- src/sys/dev/bluetooth/bthidev.c:1.18 Fri Aug 21 10:01:25 2009 +++ src/sys/dev/bluetooth/bthidev.c Wed Apr 28 06:13:51 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.18 2009/08/21 10:01:25 plunky Exp $ */ +/* $NetBSD: bthidev.c,v 1.19 2010/04/28 06:13:51 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.18 2009/08/21 10:01:25 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.19 2010/04/28 06:13:51 plunky Exp $"); #include #include @@ -181,6 +181,7 @@ const void *desc; int locs[BTHIDBUSCF_NLOCS]; int maxid, rep, dlen; + int vendor, product; /* * Init softc @@ -205,6 +206,12 @@ obj = prop_dictionary_get(dict, BTDEVraddr); bdaddr_copy(&sc->sc_raddr, prop_data_data_nocopy(obj)); + obj = prop_dictionary_get(dict, BTDEVvendor); + vendor = (int)prop_number_integer_value(obj); + + obj = prop_dictionary_get(dict, BTDEVproduct); + product = (int)prop_number_integer_value(obj); + obj = prop_dictionary_get(dict, BTDEVmode); if (prop_object_type(obj) == PROP_TYPE_STRING) { if (prop_string_equals_cstring(obj, BTDEVauth)) @@ -279,6 +286,8 @@ && hid_report_size(desc, dlen, hid_output, rep) == 0) continue; + bha.ba_vendor = vendor; + bha.ba_product = product; bha.ba_desc = desc; bha.ba_dlen = dlen; bha.ba_input = bthidev_null; Index: src/sys/dev/bluetooth/bthidev.h diff -u src/sys/dev/bluetooth/bthidev.h:1.4 src/sys/dev/bluetooth/bthidev.h:1.5 --- src/sys/dev/bluetooth/bthidev.h:1.4 Sat Nov 3 17:41:03 2007 +++ src/sys/dev/bluetooth/bthidev.h Wed Apr 28 06:13:51 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.h,v 1.4 2007/11/03 17:41:03 plunky Exp $ */ +/* $NetBSD: bthidev.h,v 1.5 2010/04/28 06:13:51 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -60,6 +60,8 @@ /* HID device attach arguments */ struct bthidev_attach_args { + int ba_vendor; /* USB Forum Vendor ID */ + int ba_product; /* USB Forum Product ID */ const void *ba_desc; /* descriptor */ int ba_dlen; /* descriptor length */ int ba_id; /* report id */
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: kiyohara Date: Thu Feb 18 07:24:17 UTC 2010 Modified Files: src/sys/dev/bluetooth: btuart.c Log Message: Remove unnecessary line-feed. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/dev/bluetooth/btuart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/btuart.c diff -u src/sys/dev/bluetooth/btuart.c:1.23 src/sys/dev/bluetooth/btuart.c:1.24 --- src/sys/dev/bluetooth/btuart.c:1.23 Tue May 12 12:10:46 2009 +++ src/sys/dev/bluetooth/btuart.c Thu Feb 18 07:24:16 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: btuart.c,v 1.23 2009/05/12 12:10:46 cegger Exp $ */ +/* $NetBSD: btuart.c,v 1.24 2010/02/18 07:24:16 kiyohara Exp $ */ /*- * Copyright (c) 2006, 2007 KIYOHARA Takashi @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.23 2009/05/12 12:10:46 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.24 2010/02/18 07:24:16 kiyohara Exp $"); #include #include @@ -351,8 +351,7 @@ /* new packet */ MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) { -aprint_error_dev(sc->sc_dev, -"out of memory\n"); +aprint_error_dev(sc->sc_dev, "out of memory\n"); sc->sc_stats.err_rx++; return 0; /* (lost sync) */ } @@ -367,8 +366,7 @@ /* extend mbuf */ MGET(m->m_next, M_DONTWAIT, MT_DATA); if (m->m_next == NULL) { -aprint_error_dev(sc->sc_dev, -"out of memory\n"); +aprint_error_dev(sc->sc_dev, "out of memory\n"); sc->sc_stats.err_rx++; return 0; /* (lost sync) */ }
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: plunky Date: Fri Aug 21 10:01:25 UTC 2009 Modified Files: src/sys/dev/bluetooth: bthidev.c Log Message: I had a complaint that it was difficult to reconnect a device after system crashes and reboots and I wonder if the reason was that we were rejecting the connection for some reason. So, notify the console if that happens. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/bluetooth/bthidev.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.17 src/sys/dev/bluetooth/bthidev.c:1.18 --- src/sys/dev/bluetooth/bthidev.c:1.17 Tue May 12 12:10:46 2009 +++ src/sys/dev/bluetooth/bthidev.c Fri Aug 21 10:01:25 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.17 2009/05/12 12:10:46 cegger Exp $ */ +/* $NetBSD: bthidev.c,v 1.18 2009/08/21 10:01:25 plunky Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.17 2009/05/12 12:10:46 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.18 2009/08/21 10:01:25 plunky Exp $"); #include #include @@ -700,12 +700,21 @@ { struct bthidev_softc *sc = arg; - if (bdaddr_same(&raddr->bt_bdaddr, &sc->sc_raddr) == 0 - || (sc->sc_flags & BTHID_CONNECTING) + if (bdaddr_same(&raddr->bt_bdaddr, &sc->sc_raddr) == 0) + return NULL; + + if ((sc->sc_flags & BTHID_CONNECTING) || sc->sc_state != BTHID_WAIT_CTL || sc->sc_ctl != NULL - || sc->sc_int != NULL) + || sc->sc_int != NULL) { + aprint_verbose_dev(sc->sc_dev, "reject ctl newconn %s%s%s%s\n", + (sc->sc_flags & BTHID_CONNECTING) ? " (CONNECTING)" : "", + (sc->sc_state == BTHID_WAIT_CTL) ? " (WAITING)": "", + (sc->sc_ctl != NULL) ? " (GOT CONTROL)" : "", + (sc->sc_int != NULL) ? " (GOT INTERRUPT)" : ""); + return NULL; + } l2cap_attach(&sc->sc_ctl, &bthidev_ctl_proto, sc); return sc->sc_ctl; @@ -717,12 +726,21 @@ { struct bthidev_softc *sc = arg; - if (bdaddr_same(&raddr->bt_bdaddr, &sc->sc_raddr) == 0 - || (sc->sc_flags & BTHID_CONNECTING) + if (bdaddr_same(&raddr->bt_bdaddr, &sc->sc_raddr) == 0) + return NULL; + + if ((sc->sc_flags & BTHID_CONNECTING) || sc->sc_state != BTHID_WAIT_INT || sc->sc_ctl == NULL - || sc->sc_int != NULL) + || sc->sc_int != NULL) { + aprint_verbose_dev(sc->sc_dev, "reject int newconn %s%s%s%s\n", + (sc->sc_flags & BTHID_CONNECTING) ? " (CONNECTING)" : "", + (sc->sc_state == BTHID_WAIT_INT) ? " (WAITING)": "", + (sc->sc_ctl == NULL) ? " (NO CONTROL)" : "", + (sc->sc_int != NULL) ? " (GOT INTERRUPT)" : ""); + return NULL; + } l2cap_attach(&sc->sc_int, &bthidev_int_proto, sc); return sc->sc_int;
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: cegger Date: Tue May 12 12:10:46 UTC 2009 Modified Files: src/sys/dev/bluetooth: bcsp.c bthidev.c bthub.c btkbd.c btms.c btsco.c btuart.c Log Message: struct cfdata * -> cfdata_t, no functional changes intended. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/dev/bluetooth/bcsp.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/bluetooth/bthidev.c cvs rdiff -u -r1.14 -r1.15 src/sys/dev/bluetooth/bthub.c cvs rdiff -u -r1.10 -r1.11 src/sys/dev/bluetooth/btkbd.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/bluetooth/btms.c cvs rdiff -u -r1.22 -r1.23 src/sys/dev/bluetooth/btsco.c \ src/sys/dev/bluetooth/btuart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.17 src/sys/dev/bluetooth/bcsp.c:1.18 --- src/sys/dev/bluetooth/bcsp.c:1.17 Thu May 7 18:01:57 2009 +++ src/sys/dev/bluetooth/bcsp.c Tue May 12 12:10:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.17 2009/05/07 18:01:57 elad Exp $ */ +/* $NetBSD: bcsp.c,v 1.18 2009/05/12 12:10:46 cegger Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.17 2009/05/07 18:01:57 elad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.18 2009/05/12 12:10:46 cegger Exp $"); #include #include @@ -132,7 +132,7 @@ #define BCSP_ENABLED (1 << 1) /* is enabled */ void bcspattach(int); -static int bcsp_match(device_t, struct cfdata *, void *); +static int bcsp_match(device_t, cfdata_t, void *); static void bcsp_attach(device_t, device_t, void *); static int bcsp_detach(device_t, int); @@ -246,7 +246,7 @@ */ /* ARGSUSED */ static int -bcsp_match(device_t self __unused, struct cfdata *cfdata __unused, +bcsp_match(device_t self __unused, cfdata_t cfdata __unused, void *arg __unused) { @@ -373,7 +373,7 @@ { struct bcsp_softc *sc; device_t dev; - struct cfdata *cfdata; + cfdata_t cfdata; struct lwp *l = curlwp; /* XXX */ int error, unit, s; static char name[] = "bcsp"; @@ -436,7 +436,7 @@ bcspclose(struct tty *tp, int flag __unused) { struct bcsp_softc *sc = tp->t_sc; - struct cfdata *cfdata; + cfdata_t cfdata; int s; /* terminate link-establishment */ Index: src/sys/dev/bluetooth/bthidev.c diff -u src/sys/dev/bluetooth/bthidev.c:1.16 src/sys/dev/bluetooth/bthidev.c:1.17 --- src/sys/dev/bluetooth/bthidev.c:1.16 Wed Aug 6 15:01:23 2008 +++ src/sys/dev/bluetooth/bthidev.c Tue May 12 12:10:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: bthidev.c,v 1.16 2008/08/06 15:01:23 plunky Exp $ */ +/* $NetBSD: bthidev.c,v 1.17 2009/05/12 12:10:46 cegger Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.16 2008/08/06 15:01:23 plunky Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.17 2009/05/12 12:10:46 cegger Exp $"); #include #include @@ -109,7 +109,7 @@ static void bthidev_null(struct bthidev *, uint8_t *, int); /* autoconf(9) glue */ -static int bthidev_match(device_t, struct cfdata *, void *); +static int bthidev_match(device_t, cfdata_t, void *); static void bthidev_attach(device_t, device_t, void *); static int bthidev_detach(device_t, int); static int bthidev_print(void *, const char *); @@ -155,7 +155,7 @@ */ static int -bthidev_match(device_t self, struct cfdata *cfdata, void *aux) +bthidev_match(device_t self, cfdata_t cfdata, void *aux) { prop_dictionary_t dict = aux; prop_object_t obj; Index: src/sys/dev/bluetooth/bthub.c diff -u src/sys/dev/bluetooth/bthub.c:1.14 src/sys/dev/bluetooth/bthub.c:1.15 --- src/sys/dev/bluetooth/bthub.c:1.14 Thu Jun 12 21:47:11 2008 +++ src/sys/dev/bluetooth/bthub.c Tue May 12 12:10:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: bthub.c,v 1.14 2008/06/12 21:47:11 cegger Exp $ */ +/* $NetBSD: bthub.c,v 1.15 2009/05/12 12:10:46 cegger Exp $ */ /*- * Copyright (c) 2006 Itronix Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.14 2008/06/12 21:47:11 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bthub.c,v 1.15 2009/05/12 12:10:46 cegger Exp $"); #include #include @@ -59,7 +59,7 @@ */ /* autoconf(9) glue */ -static int bthub_match(device_t, struct cfdata *, void *); +static int bthub_match(device_t, cfdata_t, void *); static void bthub_attach(device_t, device_t, void *); static int bthub_detach(device_t, int); @@ -86,7 +86,7 @@ */ static int -bthub_match(device_t self, struct cfdata *cfdata, void *arg) +bthub_match(device_t self, cfdata_t cfdata, void *arg) { return 1; Index: src/sys/dev/bluetooth/btkbd.c diff -u src/sys/dev/bluetooth/btkbd.c:1.10 src/sys/dev/bluetooth/btkbd.c:1.11 --- src/sys/dev/bluetooth/btkbd.c:1.10 Tue Sep 9 03:54:56 2008 +++ src/sys/dev/bluetooth/btkbd.c Tue May 12 12:10:46 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: btkbd
CVS commit: src/sys/dev/bluetooth
Module Name:src Committed By: elad Date: Sun Apr 26 07:53:43 UTC 2009 Modified Files: src/sys/dev/bluetooth: bcsp.c btuart.c Log Message: Authorizing actions from the generic scope using a device scope wrapper is a big no-no. As painful as it is, use kauth_authorize_generic() for now. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/bluetooth/bcsp.c cvs rdiff -u -r1.20 -r1.21 src/sys/dev/bluetooth/btuart.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/bluetooth/bcsp.c diff -u src/sys/dev/bluetooth/bcsp.c:1.15 src/sys/dev/bluetooth/bcsp.c:1.16 --- src/sys/dev/bluetooth/bcsp.c:1.15 Sun Mar 15 15:43:40 2009 +++ src/sys/dev/bluetooth/bcsp.c Sun Apr 26 07:53:43 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: bcsp.c,v 1.15 2009/03/15 15:43:40 cegger Exp $ */ +/* $NetBSD: bcsp.c,v 1.16 2009/04/26 07:53:43 elad Exp $ */ /* * Copyright (c) 2007 KIYOHARA Takashi * All rights reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.15 2009/03/15 15:43:40 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bcsp.c,v 1.16 2009/04/26 07:53:43 elad Exp $"); #include #include @@ -378,8 +378,8 @@ int error, unit, s; static char name[] = "bcsp"; - if ((error = kauth_authorize_device_tty(l->l_cred, - KAUTH_GENERIC_ISSUSER, tp)) != 0) + if ((error = kauth_authorize_generic(l->l_cred, + KAUTH_GENERIC_ISSUSER, NULL)) != 0) return error; s = spltty(); Index: src/sys/dev/bluetooth/btuart.c diff -u src/sys/dev/bluetooth/btuart.c:1.20 src/sys/dev/bluetooth/btuart.c:1.21 --- src/sys/dev/bluetooth/btuart.c:1.20 Sun Jan 11 02:45:51 2009 +++ src/sys/dev/bluetooth/btuart.c Sun Apr 26 07:53:43 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: btuart.c,v 1.20 2009/01/11 02:45:51 christos Exp $ */ +/* $NetBSD: btuart.c,v 1.21 2009/04/26 07:53:43 elad Exp $ */ /*- * Copyright (c) 2006, 2007 KIYOHARA Takashi @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.20 2009/01/11 02:45:51 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: btuart.c,v 1.21 2009/04/26 07:53:43 elad Exp $"); #include #include @@ -226,8 +226,8 @@ struct lwp *l = curlwp; /* XXX */ int error, unit, s; - if ((error = kauth_authorize_device_tty(l->l_cred, - KAUTH_GENERIC_ISSUSER, tp)) != 0) + if ((error = kauth_authorize_generic(l->l_cred, + KAUTH_GENERIC_ISSUSER, NULL)) != 0) return error; s = spltty();