diff --git a/sys/dev/bluetooth/bthidev.c b/sys/dev/bluetooth/bthidev.c index be6c3a053069..929e5137a983 100644 --- a/sys/dev/bluetooth/bthidev.c +++ b/sys/dev/bluetooth/bthidev.c @@ -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 @@ bthidev_ctl_newconn(void *arg, struct sockaddr_bt *laddr, { 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 @@ bthidev_int_newconn(void *arg, struct sockaddr_bt *laddr, { 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;