From 4aea176b5c54e440ba02378a523447c2726fe0d5 Mon Sep 17 00:00:00 2001 From: mpi Date: Thu, 21 Aug 2014 14:52:55 +0000 Subject: [PATCH] Now that DVACT_DEACTIVATE is propagated to the children of a device when a driver does not implement a specific *_activate() handler and that our USB stack sets the dying flag before detaching a device, these specific handlers can die. --- sys/dev/usb/uaudio.c | 33 +++++---------------------------- sys/dev/usb/ukbd.c | 27 +++------------------------ sys/dev/usb/umass.c | 38 ++++---------------------------------- sys/dev/usb/ums.c | 43 +++++++++++-------------------------------- 4 files changed, 23 insertions(+), 118 deletions(-) diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c index 23ba515feb8..f942613ab93 100644 --- a/sys/dev/usb/uaudio.c +++ b/sys/dev/usb/uaudio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uaudio.c,v 1.104 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: uaudio.c,v 1.105 2014/08/21 14:52:55 mpi Exp $ */ /* $NetBSD: uaudio.c,v 1.90 2004/10/29 17:12:53 kent Exp $ */ /* @@ -250,7 +250,6 @@ struct uaudio_softc { int sc_nencs; struct mixerctl *sc_ctls; /* mixer controls */ int sc_nctls; /* # of mixer controls */ - struct device *sc_audiodev; int sc_quirks; }; @@ -439,18 +438,13 @@ struct audio_device uaudio_device = { int uaudio_match(struct device *, void *, void *); void uaudio_attach(struct device *, struct device *, void *); int uaudio_detach(struct device *, int); -int uaudio_activate(struct device *, int); struct cfdriver uaudio_cd = { NULL, "uaudio", DV_DULL }; -const struct cfattach uaudio_ca = { - sizeof(struct uaudio_softc), - uaudio_match, - uaudio_attach, - uaudio_detach, - uaudio_activate, +const struct cfattach uaudio_ca = { + sizeof(struct uaudio_softc), uaudio_match, uaudio_attach, uaudio_detach }; int @@ -581,23 +575,7 @@ uaudio_attach(struct device *parent, struct device *self, void *aux) uaudio_create_encodings(sc); DPRINTF(("uaudio_attach: doing audio_attach_mi\n")); - sc->sc_audiodev = audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev); -} - -int -uaudio_activate(struct device *self, int act) -{ - struct uaudio_softc *sc = (struct uaudio_softc *)self; - int rv = 0; - - switch (act) { - case DVACT_DEACTIVATE: - if (sc->sc_audiodev != NULL) - rv = config_deactivate(sc->sc_audiodev); - usbd_deactivate(sc->sc_udev); - break; - } - return (rv); + audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev); } int @@ -617,8 +595,7 @@ uaudio_detach(struct device *self, int flags) /* Wait for outstanding requests to complete. */ uaudio_drain(sc); - if (sc->sc_audiodev != NULL) - rv = config_detach(sc->sc_audiodev, flags); + rv = config_detach_children(self, flags); return (rv); } diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index 10af3c3af7c..856bbe50671 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukbd.c,v 1.67 2014/05/12 09:50:44 mpi Exp $ */ +/* $OpenBSD: ukbd.c,v 1.68 2014/08/21 14:52:55 mpi Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -162,18 +162,13 @@ const struct wskbd_accessops ukbd_accessops = { int ukbd_match(struct device *, void *, void *); void ukbd_attach(struct device *, struct device *, void *); int ukbd_detach(struct device *, int); -int ukbd_activate(struct device *, int); struct cfdriver ukbd_cd = { NULL, "ukbd", DV_DULL }; -const struct cfattach ukbd_ca = { - sizeof(struct ukbd_softc), - ukbd_match, - ukbd_attach, - ukbd_detach, - ukbd_activate, +const struct cfattach ukbd_ca = { + sizeof(struct ukbd_softc), ukbd_match, ukbd_attach, ukbd_detach }; struct ukbd_translation { @@ -307,22 +302,6 @@ ukbd_attach(struct device *parent, struct device *self, void *aux) hidkbd_attach_wskbd(kbd, layout, &ukbd_accessops); } -int -ukbd_activate(struct device *self, int act) -{ - struct ukbd_softc *sc = (struct ukbd_softc *)self; - struct hidkbd *kbd = &sc->sc_kbd; - int rv = 0; - - switch (act) { - case DVACT_DEACTIVATE: - if (kbd->sc_wskbddev != NULL) - rv = config_deactivate(kbd->sc_wskbddev); - break; - } - return (rv); -} - int ukbd_detach(struct device *self, int flags) { diff --git a/sys/dev/usb/umass.c b/sys/dev/usb/umass.c index db62a364596..d4155f68190 100644 --- a/sys/dev/usb/umass.c +++ b/sys/dev/usb/umass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umass.c,v 1.66 2014/07/12 18:48:52 tedu Exp $ */ +/* $OpenBSD: umass.c,v 1.67 2014/08/21 14:52:56 mpi Exp $ */ /* $NetBSD: umass.c,v 1.116 2004/06/30 05:53:46 mycroft Exp $ */ /* @@ -180,19 +180,15 @@ char *states[TSTATE_STATES+1] = { int umass_match(struct device *, void *, void *); void umass_attach(struct device *, struct device *, void *); int umass_detach(struct device *, int); -int umass_activate(struct device *, int); struct cfdriver umass_cd = { NULL, "umass", DV_DULL }; -const struct cfattach umass_ca = { - sizeof(struct umass_softc), - umass_match, - umass_attach, - umass_detach, - umass_activate, +const struct cfattach umass_ca = { + sizeof(struct umass_softc), umass_match, umass_attach, umass_detach }; + void umass_disco(struct umass_softc *sc); /* generic transfer functions */ @@ -668,32 +664,6 @@ umass_detach(struct device *self, int flags) return (rv); } -int -umass_activate(struct device *dev, int act) -{ - struct umass_softc *sc = (struct umass_softc *)dev; - struct umassbus_softc *scbus = sc->bus; - int rv = 0; - - DPRINTF(UDMASS_USB, ("%s: umass_activate: %d\n", - sc->sc_dev.dv_xname, act)); - - switch (act) { - case DVACT_DEACTIVATE: - usbd_deactivate(sc->sc_udev); - if (scbus == NULL || scbus->sc_child == NULL) - break; - rv = config_deactivate(scbus->sc_child); - DPRINTF(UDMASS_USB, ("%s: umass_activate: child " - "returned %d\n", sc->sc_dev.dv_xname, rv)); - break; - default: - rv = config_activate_children(dev, act); - break; - } - return (rv); -} - void umass_disco(struct umass_softc *sc) { diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index 8e6c2add007..8fe5004f60d 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ums.c,v 1.38 2013/11/15 08:17:44 pirofti Exp $ */ +/* $OpenBSD: ums.c,v 1.39 2014/08/21 14:52:56 mpi Exp $ */ /* $NetBSD: ums.c,v 1.60 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -73,21 +73,16 @@ const struct wsmouse_accessops ums_accessops = { ums_disable, }; -int ums_match(struct device *, void *, void *); -void ums_attach(struct device *, struct device *, void *); -int ums_detach(struct device *, int); -int ums_activate(struct device *, int); - -struct cfdriver ums_cd = { - NULL, "ums", DV_DULL -}; - -const struct cfattach ums_ca = { - sizeof(struct ums_softc), - ums_match, - ums_attach, - ums_detach, - ums_activate, +int ums_match(struct device *, void *, void *); +void ums_attach(struct device *, struct device *, void *); +int ums_detach(struct device *, int); + +struct cfdriver ums_cd = { + NULL, "ums", DV_DULL +}; + +const struct cfattach ums_ca = { + sizeof(struct ums_softc), ums_match, ums_attach, ums_detach }; int @@ -163,22 +158,6 @@ ums_attach(struct device *parent, struct device *self, void *aux) hidms_attach(ms, &ums_accessops); } -int -ums_activate(struct device *self, int act) -{ - struct ums_softc *sc = (struct ums_softc *)self; - struct hidms *ms = &sc->sc_ms; - int rv = 0; - - switch (act) { - case DVACT_DEACTIVATE: - if (ms->sc_wsmousedev != NULL) - rv = config_deactivate(ms->sc_wsmousedev); - break; - } - return (rv); -} - int ums_detach(struct device *self, int flags) { -- 2.20.1