From 44fe0a2d74f3e81de0ca94424f06d5ec625ca5cb Mon Sep 17 00:00:00 2001 From: mpi Date: Fri, 16 May 2014 18:17:03 +0000 Subject: [PATCH] There is no need to remember which usb(4) device is the child of an USB host controller because autoconf(9) already does it. --- sys/dev/cardbus/ehci_cardbus.c | 7 +++---- sys/dev/cardbus/ohci_cardbus.c | 7 +++---- sys/dev/cardbus/uhci_cardbus.c | 7 +++---- sys/dev/pci/ehci_pci.c | 12 +++--------- sys/dev/pci/ohci_pci.c | 7 +++---- sys/dev/pci/uhci_pci.c | 8 +++----- sys/dev/usb/ehci.c | 14 ++++++-------- sys/dev/usb/ehcivar.h | 6 ++---- sys/dev/usb/ohci.c | 14 ++++++-------- sys/dev/usb/ohcivar.h | 6 ++---- sys/dev/usb/uhci.c | 14 ++++++-------- sys/dev/usb/uhcivar.h | 6 ++---- 12 files changed, 42 insertions(+), 66 deletions(-) diff --git a/sys/dev/cardbus/ehci_cardbus.c b/sys/dev/cardbus/ehci_cardbus.c index edb642c0679..49ed81cac8c 100644 --- a/sys/dev/cardbus/ehci_cardbus.c +++ b/sys/dev/cardbus/ehci_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci_cardbus.c,v 1.17 2013/04/15 09:23:00 mglocker Exp $ */ +/* $OpenBSD: ehci_cardbus.c,v 1.18 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ehci_cardbus.c,v 1.6.6.3 2004/09/21 13:27:25 skrll Exp $ */ /* @@ -162,8 +162,7 @@ ehci_cardbus_attach(struct device *parent, struct device *self, void *aux) } /* Attach usb device. */ - sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, - usbctlprint); + config_found(self, &sc->sc.sc_bus, usbctlprint); } int @@ -173,7 +172,7 @@ ehci_cardbus_detach(struct device *self, int flags) struct cardbus_devfunc *ct = sc->sc_ct; int rv; - rv = ehci_detach(&sc->sc, flags); + rv = ehci_detach(self, flags); if (rv) return (rv); if (sc->sc_ih != NULL) { diff --git a/sys/dev/cardbus/ohci_cardbus.c b/sys/dev/cardbus/ohci_cardbus.c index 7de068f889b..eab2f310964 100644 --- a/sys/dev/cardbus/ohci_cardbus.c +++ b/sys/dev/cardbus/ohci_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci_cardbus.c,v 1.18 2013/04/15 09:23:00 mglocker Exp $ */ +/* $OpenBSD: ohci_cardbus.c,v 1.19 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ohci_cardbus.c,v 1.19 2004/08/02 19:14:28 mycroft Exp $ */ /* @@ -168,8 +168,7 @@ ohci_cardbus_attach(struct device *parent, struct device *self, void *aux) } /* Attach usb device. */ - sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, - usbctlprint); + config_found(self, &sc->sc.sc_bus, usbctlprint); } int @@ -179,7 +178,7 @@ ohci_cardbus_detach(struct device *self, int flags) struct cardbus_devfunc *ct = sc->sc_ct; int rv; - rv = ohci_detach(&sc->sc, flags); + rv = ohci_detach(self, flags); if (rv) return (rv); diff --git a/sys/dev/cardbus/uhci_cardbus.c b/sys/dev/cardbus/uhci_cardbus.c index 52e11c7869b..df2c0c6161a 100644 --- a/sys/dev/cardbus/uhci_cardbus.c +++ b/sys/dev/cardbus/uhci_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci_cardbus.c,v 1.12 2013/04/15 09:23:01 mglocker Exp $ */ +/* $OpenBSD: uhci_cardbus.c,v 1.13 2014/05/16 18:17:03 mpi Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -170,8 +170,7 @@ uhci_cardbus_attach(struct device *parent, struct device *self, void *aux) } /* Attach usb device. */ - sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, - usbctlprint); + config_found(self, &sc->sc.sc_bus, usbctlprint); } int @@ -181,7 +180,7 @@ uhci_cardbus_detach(struct device *self, int flags) struct cardbus_devfunc *ct = sc->sc_ct; int rv; - rv = uhci_detach(&sc->sc, flags); + rv = uhci_detach(self, flags); if (rv) return (rv); diff --git a/sys/dev/pci/ehci_pci.c b/sys/dev/pci/ehci_pci.c index 563477bf02a..60928caa089 100644 --- a/sys/dev/pci/ehci_pci.c +++ b/sys/dev/pci/ehci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci_pci.c,v 1.26 2013/04/15 09:23:01 mglocker Exp $ */ +/* $OpenBSD: ehci_pci.c,v 1.27 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ehci_pci.c,v 1.15 2004/04/23 21:13:06 itojun Exp $ */ /* @@ -219,9 +219,7 @@ ehci_pci_attach(struct device *parent, struct device *self, void *aux) splx(s); /* Attach usb device. */ - sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, - usbctlprint); - + config_found(self, &sc->sc.sc_bus, usbctlprint); return; disestablish_ret: @@ -237,10 +235,6 @@ ehci_pci_activate(struct device *self, int act) struct ehci_pci_softc *sc = (struct ehci_pci_softc *)self; int rv; - /* ehci_pci_attach previously failed in some way */ - if (sc->sc.sc_child == NULL) - return (0); - switch (act) { case DVACT_RESUME: ehci_pci_takecontroller(sc, 1); @@ -265,7 +259,7 @@ ehci_pci_detach(struct device *self, int flags) struct ehci_pci_softc *sc = (struct ehci_pci_softc *)self; int rv; - rv = ehci_detach(&sc->sc, flags); + rv = ehci_detach(self, flags); if (rv) return (rv); if (sc->sc_ih != NULL) { diff --git a/sys/dev/pci/ohci_pci.c b/sys/dev/pci/ohci_pci.c index 4290d305208..86b6d979c09 100644 --- a/sys/dev/pci/ohci_pci.c +++ b/sys/dev/pci/ohci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci_pci.c,v 1.39 2013/04/15 09:23:01 mglocker Exp $ */ +/* $OpenBSD: ohci_pci.c,v 1.40 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ohci_pci.c,v 1.23 2002/10/02 16:51:47 thorpej Exp $ */ /* @@ -194,8 +194,7 @@ ohci_pci_attach_deferred(struct device *self) splx(s); /* Attach usb device. */ - sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, - usbctlprint); + config_found(self, &sc->sc.sc_bus, usbctlprint); } int @@ -204,7 +203,7 @@ ohci_pci_detach(struct device *self, int flags) struct ohci_pci_softc *sc = (struct ohci_pci_softc *)self; int rv; - rv = ohci_detach(&sc->sc, flags); + rv = ohci_detach(self, flags); if (rv) return (rv); diff --git a/sys/dev/pci/uhci_pci.c b/sys/dev/pci/uhci_pci.c index c14f0fefab9..ecf629cbfa2 100644 --- a/sys/dev/pci/uhci_pci.c +++ b/sys/dev/pci/uhci_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci_pci.c,v 1.32 2013/04/15 09:23:01 mglocker Exp $ */ +/* $OpenBSD: uhci_pci.c,v 1.33 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: uhci_pci.c,v 1.24 2002/10/02 16:51:58 thorpej Exp $ */ /* @@ -212,9 +212,7 @@ uhci_pci_attach_deferred(struct device *self) splx(s); /* Attach usb device. */ - sc->sc.sc_child = config_found((void *)sc, &sc->sc.sc_bus, - usbctlprint); - + config_found(self, &sc->sc.sc_bus, usbctlprint); return; unmap_ret: @@ -229,7 +227,7 @@ uhci_pci_detach(struct device *self, int flags) struct uhci_pci_softc *sc = (struct uhci_pci_softc *)self; int rv; - rv = uhci_detach(&sc->sc, flags); + rv = uhci_detach(self, flags); if (rv) return (rv); if (sc->sc_ih != NULL) { diff --git a/sys/dev/usb/ehci.c b/sys/dev/usb/ehci.c index d9f83687d29..423c408144c 100644 --- a/sys/dev/usb/ehci.c +++ b/sys/dev/usb/ehci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ehci.c,v 1.153 2014/05/09 11:01:06 mpi Exp $ */ +/* $OpenBSD: ehci.c,v 1.154 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ehci.c,v 1.66 2004/06/30 03:11:56 mycroft Exp $ */ /* @@ -1006,13 +1006,12 @@ ehci_poll(struct usbd_bus *bus) } int -ehci_detach(struct ehci_softc *sc, int flags) +ehci_detach(struct device *self, int flags) { - int rv = 0; - - if (sc->sc_child != NULL) - rv = config_detach(sc->sc_child, flags); + struct ehci_softc *sc = (struct ehci_softc *)self; + int rv; + rv = config_detach_children(self, flags); if (rv != 0) return (rv); @@ -1138,8 +1137,7 @@ ehci_activate(struct device *self, int act) rv = config_activate_children(self, act); break; case DVACT_DEACTIVATE: - if (sc->sc_child != NULL) - rv = config_deactivate(sc->sc_child); + rv = config_activate_children(self, act); sc->sc_bus.dying = 1; break; case DVACT_POWERDOWN: diff --git a/sys/dev/usb/ehcivar.h b/sys/dev/usb/ehcivar.h index 4af43570373..c65fee0be6f 100644 --- a/sys/dev/usb/ehcivar.h +++ b/sys/dev/usb/ehcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ehcivar.h,v 1.31 2014/04/29 12:45:29 mpi Exp $ */ +/* $OpenBSD: ehcivar.h,v 1.32 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ehcivar.h,v 1.19 2005/04/29 15:04:29 augustss Exp $ */ /* @@ -150,8 +150,6 @@ struct ehci_softc { struct rwlock sc_doorbell_lock; struct timeout sc_tmo_intrlist; - - struct device *sc_child; /* /dev/usb# device */ }; #define EREAD1(sc, a) bus_space_read_1((sc)->iot, (sc)->ioh, (a)) @@ -169,7 +167,7 @@ struct ehci_softc { usbd_status ehci_init(struct ehci_softc *); int ehci_intr(void *); -int ehci_detach(struct ehci_softc *, int); +int ehci_detach(struct device *, int); int ehci_activate(struct device *, int); usbd_status ehci_reset(struct ehci_softc *); diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c index f0aa949be77..0a9b0d31437 100644 --- a/sys/dev/usb/ohci.c +++ b/sys/dev/usb/ohci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ohci.c,v 1.129 2014/05/09 11:01:06 mpi Exp $ */ +/* $OpenBSD: ohci.c,v 1.130 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ohci.c,v 1.139 2003/02/22 05:24:16 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */ @@ -366,8 +366,7 @@ ohci_activate(struct device *self, int act) rv = config_activate_children(self, act); break; case DVACT_DEACTIVATE: - if (sc->sc_child != NULL) - rv = config_deactivate(sc->sc_child); + rv = config_activate_children(self, act); sc->sc_bus.dying = 1; break; case DVACT_POWERDOWN: @@ -382,13 +381,12 @@ ohci_activate(struct device *self, int act) } int -ohci_detach(struct ohci_softc *sc, int flags) +ohci_detach(struct device *self, int flags) { - int rv = 0; - - if (sc->sc_child != NULL) - rv = config_detach(sc->sc_child, flags); + struct ohci_softc *sc = (struct ohci_softc *)self; + int rv; + rv = config_detach_children(self, flags); if (rv != 0) return (rv); diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h index 62505f8dd99..cadb224580a 100644 --- a/sys/dev/usb/ohcivar.h +++ b/sys/dev/usb/ohcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ohcivar.h,v 1.36 2014/04/29 21:51:18 mpi Exp $ */ +/* $OpenBSD: ohcivar.h,v 1.37 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: ohcivar.h,v 1.32 2003/02/22 05:24:17 tsutsui Exp $ */ /* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -121,8 +121,6 @@ struct ohci_softc { struct timeval sc_overrun_ntc; struct timeout sc_tmo_rhsc; - - struct device *sc_child; }; struct ohci_xfer { @@ -133,5 +131,5 @@ usbd_status ohci_checkrev(struct ohci_softc *); usbd_status ohci_handover(struct ohci_softc *); usbd_status ohci_init(struct ohci_softc *); int ohci_intr(void *); -int ohci_detach(struct ohci_softc *, int); +int ohci_detach(struct device *, int); int ohci_activate(struct device *, int); diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c index 7451e0dca60..d119400592c 100644 --- a/sys/dev/usb/uhci.c +++ b/sys/dev/usb/uhci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhci.c,v 1.116 2014/05/09 11:01:06 mpi Exp $ */ +/* $OpenBSD: uhci.c,v 1.117 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: uhci.c,v 1.172 2003/02/23 04:19:26 simonb Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -570,8 +570,7 @@ uhci_activate(struct device *self, int act) rv = config_activate_children(self, act); break; case DVACT_DEACTIVATE: - if (sc->sc_child != NULL) - rv = config_deactivate(sc->sc_child); + rv = config_activate_children(self, act); sc->sc_bus.dying = 1; break; } @@ -579,13 +578,12 @@ uhci_activate(struct device *self, int act) } int -uhci_detach(struct uhci_softc *sc, int flags) +uhci_detach(struct device *self, int flags) { - int rv = 0; - - if (sc->sc_child != NULL) - rv = config_detach(sc->sc_child, flags); + struct uhci_softc *sc = (struct uhci_softc *)self; + int rv; + rv = config_detach_children(self, flags); if (rv != 0) return (rv); diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h index e1b5e3cfae0..8e4c45c11f0 100644 --- a/sys/dev/usb/uhcivar.h +++ b/sys/dev/usb/uhcivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: uhcivar.h,v 1.31 2014/04/29 21:51:18 mpi Exp $ */ +/* $OpenBSD: uhcivar.h,v 1.32 2014/05/16 18:17:03 mpi Exp $ */ /* $NetBSD: uhcivar.h,v 1.36 2002/12/31 00:39:11 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $ */ @@ -157,12 +157,10 @@ struct uhci_softc { char sc_vendor[32]; /* vendor string for root hub */ int sc_id_vendor; /* vendor ID for root hub */ - - struct device *sc_child; /* /dev/usb# device */ }; usbd_status uhci_init(struct uhci_softc *); usbd_status uhci_run(struct uhci_softc *, int run); int uhci_intr(void *); -int uhci_detach(struct uhci_softc *, int); +int uhci_detach(struct device *, int); int uhci_activate(struct device *, int); -- 2.20.1