Revert recent uhidev report size changes. It's reported to break fido devices
authoranton <anton@openbsd.org>
Sun, 12 Sep 2021 06:58:08 +0000 (06:58 +0000)
committeranton <anton@openbsd.org>
Sun, 12 Sep 2021 06:58:08 +0000 (06:58 +0000)
for as of now unknown reasons.

sys/dev/usb/ucc.c
sys/dev/usb/ugold.c
sys/dev/usb/uhid.c
sys/dev/usb/uhidev.c
sys/dev/usb/uhidev.h
sys/dev/usb/ukbd.c
sys/dev/usb/ums.c
sys/dev/usb/umstc.c
sys/dev/usb/uwacom.c

index a6eabf8..e74aca1 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ucc.c,v 1.25 2021/09/10 05:47:38 anton Exp $  */
+/*     $OpenBSD: ucc.c,v 1.26 2021/09/12 06:58:08 anton Exp $  */
 
 /*
  * Copyright (c) 2021 Anton Lindqvist <anton@openbsd.org>
@@ -633,9 +633,9 @@ ucc_match(struct device *parent, void *match, void *aux)
        void *desc;
        int size;
 
-       if (uha->isize == 0)
-               return UMATCH_NONE;
        uhidev_get_report_desc(uha->parent, &desc, &size);
+       if (hid_report_size(desc, size, hid_input, uha->reportid) == 0)
+               return UMATCH_NONE;
        if (!ucc_hid_match(desc, size, uha->reportid))
                return UMATCH_NONE;
 
@@ -648,7 +648,7 @@ ucc_attach(struct device *parent, struct device *self, void *aux)
        struct ucc_softc *sc = (struct ucc_softc *)self;
        struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
        void *desc;
-       int error, size;
+       int error, repid, size;
 
        sc->sc_mode = WSKBD_TRANSLATED;
        sc->sc_last_translate = -1;
@@ -659,9 +659,10 @@ ucc_attach(struct device *parent, struct device *self, void *aux)
        sc->sc_hdev.sc_report_id = uha->reportid;
 
        uhidev_get_report_desc(uha->parent, &desc, &size);
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       repid = uha->reportid;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
 
        error = ucc_hid_parse(sc, desc, size);
        if (error) {
index c77ce29..b83d8ed 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ugold.c,v 1.18 2021/09/10 05:47:38 anton Exp $   */
+/*     $OpenBSD: ugold.c,v 1.19 2021/09/12 06:58:08 anton Exp $   */
 
 /*
  * Copyright (c) 2013 Takayoshi SASANO <uaa@openbsd.org>
@@ -139,7 +139,7 @@ ugold_attach(struct device *parent, struct device *self, void *aux)
 {
        struct ugold_softc *sc = (struct ugold_softc *)self;
        struct uhidev_attach_arg *uha = aux;
-       int size;
+       int size, repid;
        void *desc;
 
        sc->sc_udev = uha->parent->sc_udev;
@@ -159,9 +159,10 @@ ugold_attach(struct device *parent, struct device *self, void *aux)
        }
 
        uhidev_get_report_desc(uha->parent, &desc, &size);
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       repid = uha->reportid;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
 
        if (uhidev_open(&sc->sc_hdev)) {
                printf(", unable to open interrupt pipe\n");
index 0d6b8a5..883a65c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uhid.c,v 1.85 2021/09/10 05:47:38 anton Exp $ */
+/*     $OpenBSD: uhid.c,v 1.86 2021/09/12 06:58:08 anton Exp $ */
 /*     $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $       */
 
 /*
@@ -126,7 +126,7 @@ uhid_attach(struct device *parent, struct device *self, void *aux)
 {
        struct uhid_softc *sc = (struct uhid_softc *)self;
        struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
-       int size;
+       int size, repid;
        void *desc;
 
        sc->sc_hdev.sc_intr = uhid_intr;
@@ -135,9 +135,10 @@ uhid_attach(struct device *parent, struct device *self, void *aux)
        sc->sc_hdev.sc_report_id = uha->reportid;
 
        uhidev_get_report_desc(uha->parent, &desc, &size);
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       repid = uha->reportid;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
 
        printf(": input=%d, output=%d, feature=%d\n",
            sc->sc_hdev.sc_isize, sc->sc_hdev.sc_osize, sc->sc_hdev.sc_fsize);
index 2e5837f..014dc05 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uhidev.c,v 1.94 2021/09/10 05:47:38 anton Exp $       */
+/*     $OpenBSD: uhidev.c,v 1.95 2021/09/12 06:58:08 anton Exp $       */
 /*     $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $     */
 
 /*
@@ -252,7 +252,6 @@ uhidev_attach(struct device *parent, struct device *self, void *aux)
        uha.reportid = UHIDEV_CLAIM_MULTIPLE_REPORTID;
        uha.nreports = nrepid;
        uha.claimed = malloc(nrepid, M_TEMP, M_WAITOK|M_ZERO);
-       uha.isize = uha.osize = uha.fsize = 0;
 
        /* Look for a driver claiming multiple report IDs first. */
        dev = config_found_sm(self, &uha, NULL, uhidevsubmatch);
@@ -273,12 +272,10 @@ uhidev_attach(struct device *parent, struct device *self, void *aux)
        uha.claimed = NULL;
 
        for (repid = 0; repid < nrepid; repid++) {
-               int isize, osize, fsize;
-
                DPRINTF(("%s: try repid=%d\n", __func__, repid));
-               if ((isize = hid_report_size(desc, size, hid_input, repid)) == 0 &&
-                   (osize = hid_report_size(desc, size, hid_output, repid)) == 0 &&
-                   (fsize = hid_report_size(desc, size, hid_feature, repid)) == 0)
+               if (hid_report_size(desc, size, hid_input, repid) == 0 &&
+                   hid_report_size(desc, size, hid_output, repid) == 0 &&
+                   hid_report_size(desc, size, hid_feature, repid) == 0)
                        continue;
 
                /* Could already be assigned by uhidev_set_report_dev(). */
@@ -286,9 +283,6 @@ uhidev_attach(struct device *parent, struct device *self, void *aux)
                        continue;
 
                uha.reportid = repid;
-               uha.isize = isize;
-               uha.osize = osize;
-               uha.fsize = fsize;
                dev = config_found_sm(self, &uha, uhidevprint, uhidevsubmatch);
                sc->sc_subdevs[repid] = (struct uhidev *)dev;
        }
index b750a00..eb78943 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uhidev.h,v 1.31 2021/09/10 05:48:43 anton Exp $       */
+/*     $OpenBSD: uhidev.h,v 1.32 2021/09/12 06:58:08 anton Exp $       */
 /*     $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $   */
 
 /*
@@ -84,9 +84,6 @@ struct uhidev_attach_arg {
 #define        UHIDEV_CLAIM_MULTIPLE_REPORTID  255
        uint8_t                  nreports;
        uint8_t                 *claimed;
-       int                      isize;
-       int                      osize;
-       int                      fsize;
 };
 
 int uhidev_report_type_conv(int);
index b2901e9..5854373 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ukbd.c,v 1.83 2021/09/10 05:47:38 anton Exp $ */
+/*     $OpenBSD: ukbd.c,v 1.84 2021/09/12 06:58:08 anton Exp $ */
 /*      $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $        */
 
 /*
@@ -231,9 +231,9 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
 
        uhidev_get_report_desc(uha->parent, &desc, &dlen);
        repid = uha->reportid;
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, dlen, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, dlen, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, dlen, hid_feature, repid);
 
         /*
          * Since the HID-Proxy is always detected before any
index 8421c27..12f47bb 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ums.c,v 1.49 2021/09/10 05:47:38 anton Exp $ */
+/*     $OpenBSD: ums.c,v 1.50 2021/09/12 06:58:08 anton Exp $ */
 /*     $NetBSD: ums.c,v 1.60 2003/03/11 16:44:00 augustss Exp $        */
 
 /*
@@ -121,7 +121,7 @@ ums_attach(struct device *parent, struct device *self, void *aux)
        struct hidms *ms = &sc->sc_ms;
        struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
        struct usb_attach_arg *uaa = uha->uaa;
-       int size;
+       int size, repid;
        void *desc;
        u_int32_t qflags = 0;
 
@@ -138,9 +138,10 @@ ums_attach(struct device *parent, struct device *self, void *aux)
        if (uaa->vendor == USB_VENDOR_ELECOM)
                ums_fix_elecom_descriptor(sc, desc, size, uaa->product);
 
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       repid = uha->reportid;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
 
        if (sc->sc_quirks & UQ_MS_REVZ)
                qflags |= HIDMS_REVZ;
index 14e8d30..47c0848 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: umstc.c,v 1.5 2021/09/10 05:47:38 anton Exp $ */
+/*     $OpenBSD: umstc.c,v 1.6 2021/09/12 06:58:08 anton Exp $ */
 
 /*
  * Copyright (c) 2020 joshua stein <jcs@jcs.org>
@@ -98,7 +98,7 @@ umstc_attach(struct device *parent, struct device *self, void *aux)
        struct umstc_softc *sc = (struct umstc_softc *)self;
        struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
        struct usb_attach_arg *uaa = uha->uaa;
-       int size;
+       int size, repid;
        void *desc;
 
        sc->sc_hdev.sc_intr = umstc_intr;
@@ -109,9 +109,10 @@ umstc_attach(struct device *parent, struct device *self, void *aux)
        usbd_set_idle(uha->parent->sc_udev, uha->parent->sc_ifaceno, 0, 0);
 
        uhidev_get_report_desc(uha->parent, &desc, &size);
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       repid = uha->reportid;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
 
        uhidev_open(&sc->sc_hdev);
 
index eeabe94..ff67e39 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: uwacom.c,v 1.3 2021/09/10 05:47:38 anton Exp $        */
+/*     $OpenBSD: uwacom.c,v 1.4 2021/09/12 06:58:08 anton Exp $        */
 
 /*
  * Copyright (c) 2016 Frank Groeneveld <frank@frankgroeneveld.nl>
@@ -95,7 +95,7 @@ uwacom_attach(struct device *parent, struct device *self, void *aux)
        struct hidms *ms = &sc->sc_ms;
        struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux;
        struct usb_attach_arg *uaa = uha->uaa;
-       int size;
+       int size, repid;
        void *desc;
 
        sc->sc_hdev.sc_intr = uwacom_intr;
@@ -106,9 +106,10 @@ uwacom_attach(struct device *parent, struct device *self, void *aux)
        usbd_set_idle(uha->parent->sc_udev, uha->parent->sc_ifaceno, 0, 0);
 
        uhidev_get_report_desc(uha->parent, &desc, &size);
-       sc->sc_hdev.sc_isize = uha->isize;
-       sc->sc_hdev.sc_osize = uha->osize;
-       sc->sc_hdev.sc_fsize = uha->fsize;
+       repid = uha->reportid;
+       sc->sc_hdev.sc_isize = hid_report_size(desc, size, hid_input, repid);
+       sc->sc_hdev.sc_osize = hid_report_size(desc, size, hid_output, repid);
+       sc->sc_hdev.sc_fsize = hid_report_size(desc, size, hid_feature, repid);
 
        ms->sc_device = self;
        ms->sc_rawmode = 1;