Only install the sensors once as multiple devices can be paired with the
authoranton <anton@openbsd.org>
Sat, 5 Feb 2022 07:31:40 +0000 (07:31 +0000)
committeranton <anton@openbsd.org>
Sat, 5 Feb 2022 07:31:40 +0000 (07:31 +0000)
same receiver. Prevents a newly added assertion from triggering.

Problem reported by Joel Carnat <joel at carnat dot net> on bugs@

sys/dev/usb/uhidpp.c

index a0c470d..174b593 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uhidpp.c,v 1.25 2022/01/26 06:05:59 anton Exp $       */
+/*     $OpenBSD: uhidpp.c,v 1.26 2022/02/05 07:31:40 anton Exp $       */
 
 /*
  * Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org>
@@ -637,6 +637,13 @@ uhidpp_device_connect(struct uhidpp_softc *sc, struct uhidpp_device *dev)
 
        uhidpp_device_refresh(sc, dev);
 
+       /*
+        * There could be many devices connected to the same receiver, therefore
+        * only install the sensors once.
+        */
+       if (uhidpp_has_sensors(sc))
+               return;
+
        strlcpy(sc->sc_sensdev.xname, sc->sc_hdev.sc_dev.dv_xname,
            sizeof(sc->sc_sensdev.xname));
        sensordev_install(&sc->sc_sensdev);