diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-03-19 08:59:38 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2014-03-19 08:59:38 +0000 |
commit | d1669317a6061f891563c1bbbd503b2e45d077c0 (patch) | |
tree | c990ec5e2bf09e26c116561c8fa30ef3aace7b63 /sys/dev | |
parent | 28c348dc9a8d89d1383d58a02ca11268337de586 (diff) |
Add a temporary hack to let a subdriver claim all the reportIDs of
a device. This should be removed once all the drivers attaching to
uhidev(4) are converted.
ok andre@, sthen@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/usb/ucycom.c | 6 | ||||
-rw-r--r-- | sys/dev/usb/ugold.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/uhid.c | 9 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.c | 36 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.h | 10 | ||||
-rw-r--r-- | sys/dev/usb/uoaklux.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/uoakrh.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/uoakv.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/uthum.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/utrh.c | 8 | ||||
-rw-r--r-- | sys/dev/usb/utwitch.c | 8 |
11 files changed, 72 insertions, 42 deletions
diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c index 4e8b7b5b7a1..80fa2e1b13e 100644 --- a/sys/dev/usb/ucycom.c +++ b/sys/dev/usb/ucycom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucycom.c,v 1.24 2013/11/15 08:25:31 pirofti Exp $ */ +/* $OpenBSD: ucycom.c,v 1.25 2014/03/19 08:59:36 mpi Exp $ */ /* $NetBSD: ucycom.c,v 1.3 2005/08/05 07:27:47 skrll Exp $ */ /* @@ -174,7 +174,9 @@ ucycom_match(struct device *parent, void *match, void *aux) { struct uhidev_attach_arg *uha = aux; - DPRINTF(("ucycom match\n")); + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); + return (usb_lookup(ucycom_devs, uha->uaa->vendor, uha->uaa->product) != NULL ? UMATCH_VENDOR_PRODUCT : UMATCH_NONE); } diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c index e37d2ee157e..ad688c9d688 100644 --- a/sys/dev/usb/ugold.c +++ b/sys/dev/usb/ugold.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugold.c,v 1.3 2013/11/04 11:51:33 mpi Exp $ */ +/* $OpenBSD: ugold.c,v 1.4 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2013 Takayoshi SASANO <sasano@openbsd.org> @@ -102,6 +102,9 @@ ugold_match(struct device *parent, void *match, void *aux) int size; void *desc; + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); + if (usb_lookup(ugold_devs, uha->uaa->vendor, uha->uaa->product) == NULL) return (UMATCH_NONE); diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c index f16bf5c1670..a2966a1ecf9 100644 --- a/sys/dev/usb/uhid.c +++ b/sys/dev/usb/uhid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhid.c,v 1.55 2013/11/19 14:04:07 pirofti Exp $ */ +/* $OpenBSD: uhid.c,v 1.56 2014/03/19 08:59:37 mpi Exp $ */ /* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -114,11 +114,10 @@ const struct cfattach uhid_ca = { int uhid_match(struct device *parent, void *match, void *aux) { -#ifdef UHID_DEBUG - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)aux; -#endif + struct uhidev_attach_arg *uha = aux; - DPRINTF(("uhid_match: report=%d\n", uha->reportid)); + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); return (UMATCH_IFACECLASS_GENERIC); } diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index 259621d1073..4323335fe68 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.55 2014/03/16 10:54:40 mpi Exp $ */ +/* $OpenBSD: uhidev.c,v 1.56 2014/03/19 08:59:37 mpi Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -128,6 +128,7 @@ uhidev_attach(struct device *parent, struct device *self, void *aux) int size, nrepid, repid, repsz; int i, repsizes[256]; void *desc = NULL; + struct device *dev; sc->sc_udev = uaa->device; sc->sc_iface = uaa->iface; @@ -217,19 +218,25 @@ uhidev_attach(struct device *parent, struct device *self, void *aux) repsz = hid_report_size(desc, size, hid_input, repid); DPRINTF(("uhidev_match: repid=%d, repsz=%d\n", repid, repsz)); repsizes[repid] = repsz; - if (repsz > 0) { - if (repsz > sc->sc_isize) - sc->sc_isize = repsz; - } + if (repsz > sc->sc_isize) + sc->sc_isize = repsz; } - sc->sc_isize += nrepid != 1; /* space for report ID */ + sc->sc_isize += (nrepid != 1); /* one byte for the report ID */ DPRINTF(("uhidev_attach: isize=%d\n", sc->sc_isize)); uha.uaa = uaa; uha.parent = sc; - for (repid = 0; repid < nrepid; repid++) { - struct device *dev; + uha.reportid = UHIDEV_CLAIM_ALLREPORTID; + + /* Look for a driver claiming all report IDs first. */ + dev = config_found_sm(self, &uha, NULL, uhidevsubmatch); + if (dev != NULL) { + for (repid = 0; repid < nrepid; repid++) + sc->sc_subdevs[repid] = (struct uhidev *)dev; + return; + } + for (repid = 0; repid < nrepid; repid++) { DPRINTF(("%s: try repid=%d\n", __func__, repid)); if (hid_report_size(desc, size, hid_input, repid) == 0 && hid_report_size(desc, size, hid_output, repid) == 0 && @@ -315,7 +322,7 @@ uhidevprint(void *aux, const char *pnp) if (pnp) printf("uhid at %s", pnp); - if (uha->reportid != 0) + if (uha->reportid != 0 && uha->reportid != UHIDEV_CLAIM_ALLREPORTID) printf(" reportid %d", uha->reportid); return (UNCONF); } @@ -356,7 +363,7 @@ int uhidev_detach(struct device *self, int flags) { struct uhidev_softc *sc = (struct uhidev_softc *)self; - int i, rv; + int i, rv = 0; DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags)); @@ -375,7 +382,14 @@ uhidev_detach(struct device *self, int flags) if (sc->sc_repdesc != NULL) free(sc->sc_repdesc, M_USBDEV); - rv = 0; + /* + * XXX Check if we have only one children claiming all the Report + * IDs, this is a hack since we need a dev -> Report ID mapping + * for uhidev_intr(). + */ + if (sc->sc_nrepid > 0 && sc->sc_subdevs[0] == sc->sc_subdevs[1]) + return (config_detach(&sc->sc_subdevs[0]->sc_dev, flags)); + for (i = 0; i < sc->sc_nrepid; i++) { if (sc->sc_subdevs[i] != NULL) { rv |= config_detach(&sc->sc_subdevs[i]->sc_dev, flags); diff --git a/sys/dev/usb/uhidev.h b/sys/dev/usb/uhidev.h index b5f24b19113..eb8f97a285d 100644 --- a/sys/dev/usb/uhidev.h +++ b/sys/dev/usb/uhidev.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.h,v 1.17 2014/03/15 09:50:26 mpi Exp $ */ +/* $OpenBSD: uhidev.h,v 1.18 2014/03/19 08:59:37 mpi Exp $ */ /* $NetBSD: uhidev.h,v 1.3 2002/10/08 09:56:17 dan Exp $ */ /* @@ -77,10 +77,10 @@ struct uhidev { }; struct uhidev_attach_arg { - struct usb_attach_arg *uaa; - struct uhidev_softc *parent; - int reportid; - int reportsize; + struct usb_attach_arg *uaa; + struct uhidev_softc *parent; + uint8_t reportid; +#define UHIDEV_CLAIM_ALLREPORTID 255 }; void uhidev_get_report_desc(struct uhidev_softc *, void **, int *); diff --git a/sys/dev/usb/uoaklux.c b/sys/dev/usb/uoaklux.c index 148191fa2c9..ad0761b2367 100644 --- a/sys/dev/usb/uoaklux.c +++ b/sys/dev/usb/uoaklux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoaklux.c,v 1.6 2014/03/07 18:39:02 mpi Exp $ */ +/* $OpenBSD: uoaklux.c,v 1.7 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -106,8 +106,10 @@ struct uoak_methods uoaklux_methods = { int uoaklux_match(struct device *parent, void *match, void *aux) { - struct usb_attach_arg *uaa = aux; - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct uhidev_attach_arg *uha = aux; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); if (uoaklux_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) return UMATCH_NONE; diff --git a/sys/dev/usb/uoakrh.c b/sys/dev/usb/uoakrh.c index facca70b206..580fe3002aa 100644 --- a/sys/dev/usb/uoakrh.c +++ b/sys/dev/usb/uoakrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoakrh.c,v 1.7 2014/03/07 18:39:02 mpi Exp $ */ +/* $OpenBSD: uoakrh.c,v 1.8 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -109,8 +109,10 @@ struct uoak_methods uoakrh_methods = { int uoakrh_match(struct device *parent, void *match, void *aux) { - struct usb_attach_arg *uaa = aux; - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct uhidev_attach_arg *uha = aux; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); if (uoakrh_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) return UMATCH_NONE; diff --git a/sys/dev/usb/uoakv.c b/sys/dev/usb/uoakv.c index d2a5b208a87..aaa43f61df3 100644 --- a/sys/dev/usb/uoakv.c +++ b/sys/dev/usb/uoakv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uoakv.c,v 1.6 2014/03/07 18:39:02 mpi Exp $ */ +/* $OpenBSD: uoakv.c,v 1.7 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2012 Yojiro UO <yuo@nui.org> @@ -109,8 +109,10 @@ struct uoak_methods uoakv_methods = { int uoakv_match(struct device *parent, void *match, void *aux) { - struct usb_attach_arg *uaa = aux; - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct uhidev_attach_arg *uha = aux; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); if (uoakv_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) return UMATCH_NONE; diff --git a/sys/dev/usb/uthum.c b/sys/dev/usb/uthum.c index 16ebf725dea..8abbb0ad4f0 100644 --- a/sys/dev/usb/uthum.c +++ b/sys/dev/usb/uthum.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthum.c,v 1.25 2014/03/07 18:39:02 mpi Exp $ */ +/* $OpenBSD: uthum.c,v 1.26 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2009, 2010 Yojiro UO <yuo@nui.org> @@ -167,8 +167,10 @@ const struct cfattach uthum_ca = { int uthum_match(struct device *parent, void *match, void *aux) { - struct usb_attach_arg *uaa = aux; - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct uhidev_attach_arg *uha = aux; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); if (uthum_lookup(uha->uaa->vendor, uha->uaa->product) == NULL) return UMATCH_NONE; diff --git a/sys/dev/usb/utrh.c b/sys/dev/usb/utrh.c index 0ba3cfd82ea..5fc8b92e5d2 100644 --- a/sys/dev/usb/utrh.c +++ b/sys/dev/usb/utrh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utrh.c,v 1.12 2014/03/07 18:39:02 mpi Exp $ */ +/* $OpenBSD: utrh.c,v 1.13 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2009 Yojiro UO <yuo@nui.org> @@ -92,8 +92,10 @@ const struct cfattach utrh_ca = { int utrh_match(struct device *parent, void *match, void *aux) { - struct usb_attach_arg *uaa = aux; - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct uhidev_attach_arg *uha = aux; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); return (usb_lookup(utrh_devs, uha->uaa->vendor, uha->uaa->product) != NULL ? UMATCH_VENDOR_PRODUCT : UMATCH_NONE); diff --git a/sys/dev/usb/utwitch.c b/sys/dev/usb/utwitch.c index 6045f1ef28a..2230211f092 100644 --- a/sys/dev/usb/utwitch.c +++ b/sys/dev/usb/utwitch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utwitch.c,v 1.9 2014/03/07 18:39:02 mpi Exp $ */ +/* $OpenBSD: utwitch.c,v 1.10 2014/03/19 08:59:37 mpi Exp $ */ /* * Copyright (c) 2010 Yojiro UO <yuo@nui.org> @@ -107,8 +107,10 @@ const struct cfattach utwitch_ca = { int utwitch_match(struct device *parent, void *match, void *aux) { - struct usb_attach_arg *uaa = aux; - struct uhidev_attach_arg *uha = (struct uhidev_attach_arg *)uaa; + struct uhidev_attach_arg *uha = aux; + + if (uha->reportid == UHIDEV_CLAIM_ALLREPORTID) + return (UMATCH_NONE); return (usb_lookup(utwitch_devs, uha->uaa->vendor, uha->uaa->product) != NULL ? UMATCH_VENDOR_PRODUCT : UMATCH_NONE); |