The new cinematic to get sensor information as soon as possible sometimes
authormiod <miod@openbsd.org>
Sun, 10 Dec 2023 19:03:37 +0000 (19:03 +0000)
committermiod <miod@openbsd.org>
Sun, 10 Dec 2023 19:03:37 +0000 (19:03 +0000)
runs too fast for the device and causes it to stutter its identification
string. Check if the second string chunk matches the first one, and ignore
it in this case, the correct data will come later.

sys/dev/usb/ugold.c

index 9d1a30b..7f7dfad 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ugold.c,v 1.25 2023/12/08 06:33:48 miod Exp $   */
+/*     $OpenBSD: ugold.c,v 1.26 2023/12/10 19:03:37 miod Exp $   */
 
 /*
  * Copyright (c) 2013 Takayoshi SASANO <uaa@openbsd.org>
@@ -609,6 +609,18 @@ ugold_intr(struct uhidev *addr, void *ibuf, u_int len)
                break;
        default:
                if (!sc->sc_type) {
+                       /*
+                        * During initialization, some devices need a bit
+                        * more time to submit their identification string.
+                        */
+                       if (len == sc->sc_model_len &&
+                           !memcmp(sc->sc_model, buf, len)) {
+#ifdef UGOLD_DEBUG
+                               printf("%s: duplicate string component\n",
+                                   sc->sc_hdev.sc_dev.dv_xname);
+#endif
+                               break;
+                       }
                        /*
                         * Exact sensor type is not known yet, type command
                         * returns arbitrary string.