Module Name:    src
Committed By:   bouyer
Date:           Sun Jan 20 12:10:53 UTC 2013

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

Log Message:
Pull up following revision(s) (requested by plunky in ticket #1835):
        sys/dev/bluetooth/bthidev.c: revision 1.23 via patch
        sys/dev/bluetooth/bthidev.c: revision 1.24 via patch
        usr.sbin/btdevctl/btdevctl.8: revision 1.8 via patch
        sys/dev/bluetooth/btmagic.c: revision 1.4 via patch
        sys/dev/bluetooth/btmagic.c: revision 1.5 via patch
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.16 -r1.16.4.1 src/sys/dev/bluetooth/bthidev.c
cvs rdiff -u -r1.1.8.2 -r1.1.8.3 src/sys/dev/bluetooth/btmagic.c
cvs rdiff -u -r1.5 -r1.5.12.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.16 src/sys/dev/bluetooth/bthidev.c:1.16.4.1
--- src/sys/dev/bluetooth/bthidev.c:1.16	Wed Aug  6 15:01:23 2008
+++ src/sys/dev/bluetooth/bthidev.c	Sun Jan 20 12:10:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bthidev.c,v 1.16 2008/08/06 15:01:23 plunky Exp $	*/
+/*	$NetBSD: bthidev.c,v 1.16.4.1 2013/01/20 12:10:51 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__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.16.4.1 2013/01/20 12:10:51 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/conf.h>
@@ -181,6 +181,7 @@ bthidev_attach(device_t parent, device_t
 	const void *desc;
 	int locs[BTHIDBUSCF_NLOCS];
 	int maxid, rep, dlen;
+	int err;
 
 	/*
 	 * Init softc
@@ -220,7 +221,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) {
@@ -305,8 +307,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);
@@ -514,8 +517,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);
@@ -638,7 +643,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)
@@ -670,7 +675,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.8.2 src/sys/dev/bluetooth/btmagic.c:1.1.8.3
--- src/sys/dev/bluetooth/btmagic.c:1.1.8.2	Sun Nov 21 03:05:03 2010
+++ src/sys/dev/bluetooth/btmagic.c	Sun Jan 20 12:10:52 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: btmagic.c,v 1.1.8.2 2010/11/21 03:05:03 riz Exp $	*/
+/*	$NetBSD: btmagic.c,v 1.1.8.3 2013/01/20 12:10:52 bouyer 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.8.2 2010/11/21 03:05:03 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: btmagic.c,v 1.1.8.3 2013/01/20 12:10:52 bouyer 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");
@@ -389,7 +391,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);
 }
@@ -528,8 +531,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);
@@ -880,7 +886,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 {
@@ -906,7 +912,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.5 src/usr.sbin/btdevctl/btdevctl.8:1.5.12.1
--- src/usr.sbin/btdevctl/btdevctl.8:1.5	Sun Dec  2 20:59:29 2007
+++ src/usr.sbin/btdevctl/btdevctl.8	Sun Jan 20 12:10:52 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: btdevctl.8,v 1.5 2007/12/02 20:59:29 wiz Exp $
+.\" $NetBSD: btdevctl.8,v 1.5.12.1 2013/01/20 12:10:52 bouyer Exp $
 .\"
 .\" Copyright (c) 2006 Itronix Inc.
 .\" All rights reserved.
@@ -51,10 +51,10 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $Id: btdevctl.8,v 1.5 2007/12/02 20:59:29 wiz Exp $
+.\" $Id: btdevctl.8,v 1.5.12.1 2013/01/20 12:10:52 bouyer Exp $
 .\" $FreeBSD: src/usr.sbin/bluetooth/bthidcontrol/bthidcontrol.8,v 1.3 2005/01/18 20:02:30 ru Exp $
 .\"
-.Dd April 10, 2007
+.Dd December 26, 2012
 .Dt BTDEVCTL 8
 .Os
 .Sh NAME
@@ -104,7 +104,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
@@ -123,6 +123,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