From 6cdbbe9b1df545495e67ca7668ec021154c068d7 Mon Sep 17 00:00:00 2001 From: anton Date: Sun, 12 Sep 2021 06:58:08 +0000 Subject: [PATCH] Revert recent uhidev report size changes. It's reported to break fido devices for as of now unknown reasons. --- sys/dev/usb/ucc.c | 15 ++++++++------- sys/dev/usb/ugold.c | 11 ++++++----- sys/dev/usb/uhid.c | 11 ++++++----- sys/dev/usb/uhidev.c | 14 ++++---------- sys/dev/usb/uhidev.h | 5 +---- sys/dev/usb/ukbd.c | 8 ++++---- sys/dev/usb/ums.c | 11 ++++++----- sys/dev/usb/umstc.c | 11 ++++++----- sys/dev/usb/uwacom.c | 11 ++++++----- 9 files changed, 47 insertions(+), 50 deletions(-) diff --git a/sys/dev/usb/ucc.c b/sys/dev/usb/ucc.c index a6eabf8686f..e74aca1fce5 100644 --- a/sys/dev/usb/ucc.c +++ b/sys/dev/usb/ucc.c @@ -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 @@ -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) { diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c index c77ce294beb..b83d8edd8e8 100644 --- a/sys/dev/usb/ugold.c +++ b/sys/dev/usb/ugold.c @@ -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 @@ -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"); diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index 0d6b8a5c677..883a65cc264 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -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); diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index 2e5837fab3b..014dc052c1c 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -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; } diff --git a/sys/dev/usb/uhidev.h b/sys/dev/usb/uhidev.h index b750a0028e3..eb7894374cc 100644 --- a/sys/dev/usb/uhidev.h +++ b/sys/dev/usb/uhidev.h @@ -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); diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index b2901e99e67..5854373250b 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -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 diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index 8421c278f70..12f47bba124 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -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; diff --git a/sys/dev/usb/umstc.c b/sys/dev/usb/umstc.c index 14e8d308fca..47c084828af 100644 --- a/sys/dev/usb/umstc.c +++ b/sys/dev/usb/umstc.c @@ -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 @@ -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); diff --git a/sys/dev/usb/uwacom.c b/sys/dev/usb/uwacom.c index eeabe94b33d..ff67e395977 100644 --- a/sys/dev/usb/uwacom.c +++ b/sys/dev/usb/uwacom.c @@ -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 @@ -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; -- 2.20.1