On Thu, Nov 11, 2021 at 03:29:15PM +0100, Anton Lindqvist wrote:
> 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?

... and here's the actual fix applied on top of the previous diff.

diff --git sys/dev/usb/uhidev.c sys/dev/usb/uhidev.c
index 60d1874322a..eb9bc927670 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 = 0;
        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)
                printf(" reportid %d", uha->reportid);
        return (UNCONF);
 }
diff --git sys/dev/usb/uhidev.h sys/dev/usb/uhidev.h
index 86217fb8880..fda59b2a139 100644
--- sys/dev/usb/uhidev.h
+++ sys/dev/usb/uhidev.h
@@ -75,13 +75,11 @@ struct uhidev_attach_arg {
        struct usb_attach_arg   *uaa;
        struct uhidev_softc     *parent;
        uint8_t                  reportid;
-       uint8_t                  nreports;
+       u_int                    nreports;
        uint8_t                 *claimed;
 };
 
-#define UHIDEV_CLAIM_MULTIPLE_REPORTID(u) \
-       ((u)->reportid == __UHIDEV_CLAIM_MULTIPLE_REPORTID)
-#define        __UHIDEV_CLAIM_MULTIPLE_REPORTID        255     /* XXX */
+#define UHIDEV_CLAIM_MULTIPLE_REPORTID(u)      ((u)->claimed != NULL)
 
 int uhidev_report_type_conv(int);
 void uhidev_get_report_desc(struct uhidev_softc *, void **, int *);

Reply via email to