Hi, The second attempt to solve the uhidev claim multiple report ids conflict didn't work out either as it broke fido(4). Signalling claim multiple report ids to the match routines using the report id does not work as all 256 values already have semantic meaning. I instead want to use `uha->claimed != NULL' to signal that multiple report ids can be claimed. Before doing so, refactor in order to make an upcoming diff with the actual fix significantly smaller.
No intended^W functional change. Comments? OK? diff --git sys/dev/usb/fido.c sys/dev/usb/fido.c index c6d846aaa84..0232694b55a 100644 --- sys/dev/usb/fido.c +++ sys/dev/usb/fido.c @@ -63,7 +63,7 @@ fido_match(struct device *parent, void *match, void *aux) void *desc; int ret = UMATCH_NONE; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (ret); /* Find the FIDO usage page and U2F collection */ diff --git sys/dev/usb/ucycom.c sys/dev/usb/ucycom.c index ca8636f0a7f..621f6af2d5d 100644 --- sys/dev/usb/ucycom.c +++ sys/dev/usb/ucycom.c @@ -165,7 +165,7 @@ ucycom_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); return (usb_lookup(ucycom_devs, uha->uaa->vendor, uha->uaa->product) != NULL ? diff --git sys/dev/usb/ugold.c sys/dev/usb/ugold.c index b83d8edd8e8..aafaa1712cc 100644 --- sys/dev/usb/ugold.c +++ sys/dev/usb/ugold.c @@ -113,7 +113,7 @@ ugold_match(struct device *parent, void *match, void *aux) int size; void *desc; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); if (usb_lookup(ugold_devs, uha->uaa->vendor, uha->uaa->product) == NULL) diff --git sys/dev/usb/uhid.c sys/dev/usb/uhid.c index 90a75d878e3..c2f97dd833a 100644 --- sys/dev/usb/uhid.c +++ sys/dev/usb/uhid.c @@ -115,7 +115,7 @@ uhid_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); return (UMATCH_IFACECLASS_GENERIC); diff --git sys/dev/usb/uhidev.c sys/dev/usb/uhidev.c index 3ce1684893b..60d1874322a 100644 --- sys/dev/usb/uhidev.c +++ sys/dev/usb/uhidev.c @@ -248,7 +248,7 @@ uhidev_attach(struct device *parent, struct device *self, void *aux) uha.uaa = uaa; uha.parent = sc; - uha.reportid = UHIDEV_CLAIM_MULTIPLE_REPORTID; + uha.reportid = __UHIDEV_CLAIM_MULTIPLE_REPORTID; uha.nreports = nrepid; uha.claimed = malloc(nrepid, M_TEMP, M_WAITOK|M_ZERO); @@ -360,7 +360,7 @@ uhidevprint(void *aux, const char *pnp) if (pnp) printf("uhid at %s", pnp); - if (uha->reportid != 0 && uha->reportid != UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (uha->reportid != 0 && uha->reportid != __UHIDEV_CLAIM_MULTIPLE_REPORTID) printf(" reportid %d", uha->reportid); return (UNCONF); } diff --git sys/dev/usb/uhidev.h sys/dev/usb/uhidev.h index b2b7608b083..86217fb8880 100644 --- sys/dev/usb/uhidev.h +++ sys/dev/usb/uhidev.h @@ -75,11 +75,14 @@ struct uhidev_attach_arg { struct usb_attach_arg *uaa; struct uhidev_softc *parent; uint8_t reportid; -#define UHIDEV_CLAIM_MULTIPLE_REPORTID 255 uint8_t nreports; uint8_t *claimed; }; +#define UHIDEV_CLAIM_MULTIPLE_REPORTID(u) \ + ((u)->reportid == __UHIDEV_CLAIM_MULTIPLE_REPORTID) +#define __UHIDEV_CLAIM_MULTIPLE_REPORTID 255 /* XXX */ + int uhidev_report_type_conv(int); void uhidev_get_report_desc(struct uhidev_softc *, void **, int *); int uhidev_open(struct uhidev *); diff --git sys/dev/usb/ujoy.c sys/dev/usb/ujoy.c index ca461e5969a..11d77f9daba 100644 --- sys/dev/usb/ujoy.c +++ sys/dev/usb/ujoy.c @@ -104,7 +104,7 @@ ujoy_match(struct device *parent, void *match, void *aux) void *desc; int ret = UMATCH_NONE; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (ret); /* Find the general usage page and gamecontroller collections */ diff --git sys/dev/usb/umt.c sys/dev/usb/umt.c index 3aa45bf298a..0915b38de5c 100644 --- sys/dev/usb/umt.c +++ sys/dev/usb/umt.c @@ -90,7 +90,7 @@ umt_match(struct device *parent, void *match, void *aux) int size; void *desc; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) { + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) { uhidev_get_report_desc(uha->parent, &desc, &size); if (umt_find_winptp_reports(uha->parent, desc, size, &input, &conf, &cap)) { diff --git sys/dev/usb/uoaklux.c sys/dev/usb/uoaklux.c index c97bdf57285..7539100e802 100644 --- sys/dev/usb/uoaklux.c +++ sys/dev/usb/uoaklux.c @@ -107,7 +107,7 @@ uoaklux_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); if (uoaklux_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) diff --git sys/dev/usb/uoakrh.c sys/dev/usb/uoakrh.c index 1e1e49a426c..5349d3ad65e 100644 --- sys/dev/usb/uoakrh.c +++ sys/dev/usb/uoakrh.c @@ -110,7 +110,7 @@ uoakrh_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); if (uoakrh_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) diff --git sys/dev/usb/uoakv.c sys/dev/usb/uoakv.c index 2963e47da0d..096f9b89d94 100644 --- sys/dev/usb/uoakv.c +++ sys/dev/usb/uoakv.c @@ -110,7 +110,7 @@ uoakv_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); if (uoakv_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) diff --git sys/dev/usb/upd.c sys/dev/usb/upd.c index b4eb6f9bb31..8c6605b3eb0 100644 --- sys/dev/usb/upd.c +++ sys/dev/usb/upd.c @@ -155,7 +155,7 @@ upd_match(struct device *parent, void *match, void *aux) int ret = UMATCH_NONE; int i; - if (uha->reportid != UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (!UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (ret); DPRINTF(("upd: vendor=0x%04x, product=0x%04x\n", uha->uaa->vendor, diff --git sys/dev/usb/uslhcom.c sys/dev/usb/uslhcom.c index 15291aae645..cdc4a70529e 100644 --- sys/dev/usb/uslhcom.c +++ sys/dev/usb/uslhcom.c @@ -115,7 +115,7 @@ uslhcom_match(struct device *parent, void *match, void *aux) struct uhidev_attach_arg *uha = aux; /* use all report IDs */ - if (uha->reportid != UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (!UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return UMATCH_NONE; return (usb_lookup(uslhcom_devs, diff --git sys/dev/usb/uthum.c sys/dev/usb/uthum.c index 280cb177ecf..27742fab6cb 100644 --- sys/dev/usb/uthum.c +++ sys/dev/usb/uthum.c @@ -168,7 +168,7 @@ uthum_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); if (uthum_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) diff --git sys/dev/usb/utrh.c sys/dev/usb/utrh.c index c74ca0746ca..ea9a1bdad7b 100644 --- sys/dev/usb/utrh.c +++ sys/dev/usb/utrh.c @@ -93,7 +93,7 @@ utrh_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); return (usb_lookup(utrh_devs, uha->uaa->vendor, uha->uaa->product) != NULL ? diff --git sys/dev/usb/utwitch.c sys/dev/usb/utwitch.c index a7a5479700f..0cb8bbc5a68 100644 --- sys/dev/usb/utwitch.c +++ sys/dev/usb/utwitch.c @@ -107,7 +107,7 @@ utwitch_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - if (uha->reportid == UHIDEV_CLAIM_MULTIPLE_REPORTID) + if (UHIDEV_CLAIM_MULTIPLE_REPORTID(uha)) return (UMATCH_NONE); return (usb_lookup(utwitch_devs, uha->uaa->vendor, uha->uaa->product) != NULL ?