Module Name:    src
Committed By:   riz
Date:           Mon Jan  7 04:15:12 UTC 2013

Modified Files:
        src/sys/dev/bluetooth [netbsd-6]: bthidev.c btmagic.c
        src/usr.sbin/btdevctl [netbsd-6]: btdevctl.8

Log Message:
Pull up following revision(s) (requested by plunky in ticket #769):
        sys/dev/bluetooth/bthidev.c: revision 1.23
        sys/dev/bluetooth/bthidev.c: revision 1.24
        usr.sbin/btdevctl/btdevctl.8: revision 1.8
        sys/dev/bluetooth/btmagic.c: revision 1.4
        sys/dev/bluetooth/btmagic.c: revision 1.5
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
increase some diagnostics
add a comment pointing out that the link-mode may need to be
changed manually, for devices which cannot authenticate
for PR/47286


To generate a diff of this commit:
cvs rdiff -u -r1.21.2.1 -r1.21.2.2 src/sys/dev/bluetooth/bthidev.c
cvs rdiff -u -r1.1.22.1 -r1.1.22.2 src/sys/dev/bluetooth/btmagic.c
cvs rdiff -u -r1.7 -r1.7.8.1 src/usr.sbin/btdevctl/btdevctl.8

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.2.1 src/sys/dev/bluetooth/bthidev.c:1.21.2.2
--- src/sys/dev/bluetooth/bthidev.c:1.21.2.1	Tue Apr  3 17:31:19 2012
+++ src/sys/dev/bluetooth/bthidev.c	Mon Jan  7 04:15:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bthidev.c,v 1.21.2.1 2012/04/03 17:31:19 riz Exp $	*/
+/*	$NetBSD: bthidev.c,v 1.21.2.2 2013/01/07 04:15:12 riz Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.21.2.1 2012/04/03 17:31:19 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bthidev.c,v 1.21.2.2 2013/01/07 04:15:12 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/condvar.h>
@@ -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
@@ -241,7 +242,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) {
@@ -336,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);
@@ -560,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);
@@ -801,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)
@@ -833,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.1.22.1 src/sys/dev/bluetooth/btmagic.c:1.1.22.2
--- src/sys/dev/bluetooth/btmagic.c:1.1.22.1	Tue Apr  3 17:31:20 2012
+++ src/sys/dev/bluetooth/btmagic.c	Mon Jan  7 04:15:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: btmagic.c,v 1.1.22.1 2012/04/03 17:31:20 riz Exp $	*/
+/*	$NetBSD: btmagic.c,v 1.1.22.2 2013/01/07 04:15:12 riz Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -85,7 +85,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.1.22.1 2012/04/03 17:31:20 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.1.22.2 2013/01/07 04:15:12 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -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
@@ -306,7 +307,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");
@@ -391,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);
 }
@@ -532,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);
@@ -884,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 {
@@ -910,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 {

Index: src/usr.sbin/btdevctl/btdevctl.8
diff -u src/usr.sbin/btdevctl/btdevctl.8:1.7 src/usr.sbin/btdevctl/btdevctl.8:1.7.8.1
--- src/usr.sbin/btdevctl/btdevctl.8:1.7	Tue Oct 12 21:49:08 2010
+++ src/usr.sbin/btdevctl/btdevctl.8	Mon Jan  7 04:15:12 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.7 2010/10/12 21:49:08 wiz Exp $
+.\" $NetBSD: btdevctl.8,v 1.7.8.1 2013/01/07 04:15:12 riz Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -51,7 +51,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd October 11, 2010
+.Dd December 26, 2012
 .Dt BTDEVCTL 8
 .Os
 .Sh NAME
@@ -101,7 +101,7 @@ May be given as BDADDR or device name.
 Connection link mode.
 The following modes are supported:
 .Pp
-.Bl -tag -compact
+.Bl -tag -width encrypt -compact
 .It none
 clear previously set mode.
 .It auth
@@ -120,6 +120,8 @@ will set
 by default, or
 .Sq encrypt
 for keyboard devices.
+If the device cannot handle authentication, then the mode will need
+to be cleared manually.
 .It Fl q
 Ignore any cached data and perform a SDP query for the given
 .Ar service .

Reply via email to