diff options
author | Paul Irofti <pirofti@cvs.openbsd.org> | 2013-11-15 08:25:32 +0000 |
---|---|---|
committer | Paul Irofti <pirofti@cvs.openbsd.org> | 2013-11-15 08:25:32 +0000 |
commit | 3ab67e413a613e17c0a2eb67b3dbf371317b313a (patch) | |
tree | 18a1ece0f978eaee642125d0908130a245fb8291 /sys | |
parent | 19f5dcfcec57bffc7080845213bea362120f4c04 (diff) |
Sort-out activate functionality for ucom(4) and it's parents.
The child should not have to call the parent for deactivation.
The parent should handle it.
So kill the activate routine in ucom(4) and adapt the parents
to no longer call it.
Also remove sc_dying in ucom(4) and use usbd_is_dying() instead.
Okay mpi@.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/moscom.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uark.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/ubsa.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uchcom.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/ucom.c | 46 | ||||
-rw-r--r-- | sys/dev/usb/ucycom.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uftdi.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uipaq.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/umct.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/umodem.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/umsm.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uplcom.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uslcom.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uticom.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/uvisor.c | 11 | ||||
-rw-r--r-- | sys/dev/usb/uvscom.c | 7 |
16 files changed, 44 insertions, 111 deletions
diff --git a/sys/dev/usb/moscom.c b/sys/dev/usb/moscom.c index d18f8550cd8..0bbc2f92ed2 100644 --- a/sys/dev/usb/moscom.c +++ b/sys/dev/usb/moscom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: moscom.c,v 1.18 2013/11/07 12:52:42 pirofti Exp $ */ +/* $OpenBSD: moscom.c,v 1.19 2013/11/15 08:25:30 pirofti Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -280,16 +280,13 @@ int moscom_activate(struct device *self, int act) { struct moscom_softc *sc = (struct moscom_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uark.c b/sys/dev/usb/uark.c index 10fb2fdbbe0..2999298c1e7 100644 --- a/sys/dev/usb/uark.c +++ b/sys/dev/usb/uark.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uark.c,v 1.18 2013/11/07 11:50:38 pirofti Exp $ */ +/* $OpenBSD: uark.c,v 1.19 2013/11/15 08:25:31 pirofti Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -207,16 +207,13 @@ int uark_activate(struct device *self, int act) { struct uark_softc *sc = (struct uark_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } void diff --git a/sys/dev/usb/ubsa.c b/sys/dev/usb/ubsa.c index 8de970dba89..52db4218839 100644 --- a/sys/dev/usb/ubsa.c +++ b/sys/dev/usb/ubsa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ubsa.c,v 1.58 2013/11/07 07:32:36 pirofti Exp $ */ +/* $OpenBSD: ubsa.c,v 1.59 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: ubsa.c,v 1.5 2002/11/25 00:51:33 fvdl Exp $ */ /*- * Copyright (c) 2002, Alexander Kabaev <kan.FreeBSD.org>. @@ -396,16 +396,13 @@ int ubsa_activate(struct device *self, int act) { struct ubsa_softc *sc = (struct ubsa_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uchcom.c b/sys/dev/usb/uchcom.c index 3ef17be23ba..1f2ac628219 100644 --- a/sys/dev/usb/uchcom.c +++ b/sys/dev/usb/uchcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uchcom.c,v 1.17 2013/11/07 10:33:27 pirofti Exp $ */ +/* $OpenBSD: uchcom.c,v 1.18 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */ /* @@ -331,17 +331,14 @@ int uchcom_activate(struct device *self, int act) { struct uchcom_softc *sc = (struct uchcom_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: uchcom_close_intr_pipe(sc); usbd_deactivate(sc->sc_udev); - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); break; } - return rv; + return 0; } int diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c index 93a8cd0c252..3e138808e8a 100644 --- a/sys/dev/usb/ucom.c +++ b/sys/dev/usb/ucom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucom.c,v 1.61 2013/07/15 13:52:05 mpi Exp $ */ +/* $OpenBSD: ucom.c,v 1.62 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: ucom.c,v 1.49 2003/01/01 00:10:25 thorpej Exp $ */ /* @@ -80,7 +80,7 @@ int ucomdebug = 0; struct ucom_softc { struct device sc_dev; /* base device */ - struct usbd_device *sc_udev; /* USB device */ + struct usbd_device *sc_uparent; /* USB device */ struct uhidev_softc *sc_uhidev; /* hid device (if deeper) */ struct usbd_interface *sc_iface; /* data interface */ @@ -119,7 +119,6 @@ struct ucom_softc { struct rwlock sc_lock; /* lock during open */ int sc_open; int sc_refcnt; - u_char sc_dying; /* disconnecting */ }; void ucom_cleanup(struct ucom_softc *); @@ -144,7 +143,6 @@ void ucom_unlock(struct ucom_softc *); int ucom_match(struct device *, void *, void *); void ucom_attach(struct device *, struct device *, void *); int ucom_detach(struct device *, int); -int ucom_activate(struct device *, int); struct cfdriver ucom_cd = { NULL, "ucom", DV_TTY @@ -155,7 +153,6 @@ const struct cfattach ucom_ca = { ucom_match, ucom_attach, ucom_detach, - ucom_activate, }; void @@ -187,7 +184,7 @@ ucom_attach(struct device *parent, struct device *self, void *aux) printf(", %s", uca->info); printf("\n"); - sc->sc_udev = uca->device; + sc->sc_uparent = uca->device; sc->sc_iface = uca->iface; sc->sc_bulkout_no = uca->bulkout; sc->sc_bulkin_no = uca->bulkin; @@ -279,21 +276,6 @@ ucom_detach(struct device *self, int flags) return (0); } -int -ucom_activate(struct device *self, int act) -{ - struct ucom_softc *sc = (struct ucom_softc *)self; - - DPRINTFN(5,("ucom_activate: %d\n", act)); - - switch (act) { - case DVACT_DEACTIVATE: - sc->sc_dying = 1; - break; - } - return (0); -} - void ucom_shutdown(struct ucom_softc *sc) { @@ -323,7 +305,7 @@ ucomopen(dev_t dev, int flag, int mode, struct proc *p) if (sc == NULL) return (ENXIO); - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_uparent)) return (EIO); if (ISSET(sc->sc_dev.dv_flags, DVF_ACTIVE) == 0) @@ -378,7 +360,7 @@ ucom_do_open(dev_t dev, int flag, int mode, struct proc *p) } /* Allocate a request and an input buffer and start reading. */ - sc->sc_ixfer = usbd_alloc_xfer(sc->sc_udev); + sc->sc_ixfer = usbd_alloc_xfer(sc->sc_uparent); if (sc->sc_ixfer == NULL) { error = ENOMEM; goto fail_2; @@ -391,7 +373,7 @@ ucom_do_open(dev_t dev, int flag, int mode, struct proc *p) goto fail_2; } - sc->sc_oxfer = usbd_alloc_xfer(sc->sc_udev); + sc->sc_oxfer = usbd_alloc_xfer(sc->sc_uparent); if (sc->sc_oxfer == NULL) { error = ENOMEM; goto fail_3; @@ -563,7 +545,7 @@ ucomclose(dev_t dev, int flag, int mode, struct proc *p) struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)]; int error; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || usbd_is_dying(sc->sc_uparent)) return (EIO); sc->sc_refcnt++; @@ -609,7 +591,7 @@ ucomread(dev_t dev, struct uio *uio, int flag) struct tty *tp; int error; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || usbd_is_dying(sc->sc_uparent)) return (EIO); sc->sc_refcnt++; @@ -627,7 +609,7 @@ ucomwrite(dev_t dev, struct uio *uio, int flag) struct tty *tp; int error; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || usbd_is_dying(sc->sc_uparent)) return (EIO); sc->sc_refcnt++; @@ -659,7 +641,7 @@ ucomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)]; int error; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || usbd_is_dying(sc->sc_uparent)) return (EIO); sc->sc_refcnt++; @@ -873,7 +855,7 @@ ucomparam(struct tty *tp, struct termios *t) struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(tp->t_dev)]; int error; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || usbd_is_dying(sc->sc_uparent)) return (EIO); /* Check requested parameters. */ @@ -970,7 +952,7 @@ ucomstart(struct tty *tp) u_char *data; int cnt; - if (sc == NULL || sc->sc_dying) + if (sc == NULL || usbd_is_dying(sc->sc_uparent)) return; s = spltty(); @@ -1063,7 +1045,7 @@ ucomwritecb(struct usbd_xfer *xfer, void *p, usbd_status status) DPRINTFN(5,("ucomwritecb: %p %p status=%d\n", xfer, p, status)); - if (status == USBD_CANCELLED || sc->sc_dying) + if (status == USBD_CANCELLED || usbd_is_dying(sc->sc_uparent)) goto error; if (sc->sc_bulkin_pipe != NULL) { @@ -1141,7 +1123,7 @@ ucomreadcb(struct usbd_xfer *xfer, void *p, usbd_status status) DPRINTFN(5,("ucomreadcb: status=%d\n", status)); if (status == USBD_CANCELLED || status == USBD_IOERROR || - sc->sc_dying) { + usbd_is_dying(sc->sc_uparent)) { DPRINTF(("ucomreadcb: dying\n")); /* Send something to wake upper layer */ s = spltty(); diff --git a/sys/dev/usb/ucycom.c b/sys/dev/usb/ucycom.c index a45e24bda7e..4e8b7b5b7a1 100644 --- a/sys/dev/usb/ucycom.c +++ b/sys/dev/usb/ucycom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ucycom.c,v 1.23 2013/11/07 12:52:15 pirofti Exp $ */ +/* $OpenBSD: ucycom.c,v 1.24 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: ucycom.c,v 1.3 2005/08/05 07:27:47 skrll Exp $ */ /* @@ -587,16 +587,13 @@ int ucycom_activate(struct device *self, int act) { struct ucycom_softc *sc = (struct ucycom_softc *)self; - int rv = 0; DPRINTFN(5,("ucycom_activate: %d\n", act)); switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } diff --git a/sys/dev/usb/uftdi.c b/sys/dev/usb/uftdi.c index 1656718c3a6..14cf59300ea 100644 --- a/sys/dev/usb/uftdi.c +++ b/sys/dev/usb/uftdi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uftdi.c,v 1.66 2013/11/07 11:13:31 pirofti Exp $ */ +/* $OpenBSD: uftdi.c,v 1.67 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: uftdi.c,v 1.14 2003/02/23 04:20:07 simonb Exp $ */ /* @@ -896,16 +896,13 @@ int uftdi_activate(struct device *self, int act) { struct uftdi_softc *sc = (struct uftdi_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uipaq.c b/sys/dev/usb/uipaq.c index 818c7dca247..e2a2ed8fdd0 100644 --- a/sys/dev/usb/uipaq.c +++ b/sys/dev/usb/uipaq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipaq.c,v 1.22 2013/11/07 12:07:18 pirofti Exp $ */ +/* $OpenBSD: uipaq.c,v 1.23 2013/11/15 08:25:31 pirofti Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -356,16 +356,13 @@ int uipaq_activate(struct device *self, int act) { struct uipaq_softc *sc = (struct uipaq_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/umct.c b/sys/dev/usb/umct.c index e0f32d2b9c3..680568f27d3 100644 --- a/sys/dev/usb/umct.c +++ b/sys/dev/usb/umct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umct.c,v 1.37 2013/11/07 07:32:07 pirofti Exp $ */ +/* $OpenBSD: umct.c,v 1.38 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: umct.c,v 1.10 2003/02/23 04:20:07 simonb Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -331,16 +331,13 @@ int umct_activate(struct device *self, int act) { struct umct_softc *sc = (struct umct_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } void diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c index 256bffc6a7a..06ec7d42bdf 100644 --- a/sys/dev/usb/umodem.c +++ b/sys/dev/usb/umodem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umodem.c,v 1.51 2013/11/07 12:53:14 pirofti Exp $ */ +/* $OpenBSD: umodem.c,v 1.52 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: umodem.c,v 1.45 2002/09/23 05:51:23 simonb Exp $ */ /* @@ -745,16 +745,13 @@ int umodem_activate(struct device *self, int act) { struct umodem_softc *sc = (struct umodem_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: usbd_deactivate(sc->sc_udev); - if (sc->sc_subdev) - rv = config_deactivate(sc->sc_subdev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/umsm.c b/sys/dev/usb/umsm.c index d76e52568d6..755c3d83bac 100644 --- a/sys/dev/usb/umsm.c +++ b/sys/dev/usb/umsm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umsm.c,v 1.93 2013/11/07 10:34:20 pirofti Exp $ */ +/* $OpenBSD: umsm.c,v 1.94 2013/11/15 08:25:31 pirofti Exp $ */ /* * Copyright (c) 2008 Yojiro UO <yuo@nui.org> @@ -436,16 +436,13 @@ int umsm_activate(struct device *self, int act) { struct umsm_softc *sc = (struct umsm_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uplcom.c b/sys/dev/usb/uplcom.c index 3bf196e4166..3de4b2f4525 100644 --- a/sys/dev/usb/uplcom.c +++ b/sys/dev/usb/uplcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uplcom.c,v 1.60 2013/11/06 16:59:02 pirofti Exp $ */ +/* $OpenBSD: uplcom.c,v 1.61 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: uplcom.c,v 1.29 2002/09/23 05:51:23 simonb Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -438,16 +438,13 @@ int uplcom_activate(struct device *self, int act) { struct uplcom_softc *sc = (struct uplcom_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } usbd_status diff --git a/sys/dev/usb/uslcom.c b/sys/dev/usb/uslcom.c index 782ce69dfff..eae0879c937 100644 --- a/sys/dev/usb/uslcom.c +++ b/sys/dev/usb/uslcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uslcom.c,v 1.29 2013/11/07 10:34:02 pirofti Exp $ */ +/* $OpenBSD: uslcom.c,v 1.30 2013/11/15 08:25:31 pirofti Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -338,16 +338,13 @@ int uslcom_activate(struct device *self, int act) { struct uslcom_softc *sc = (struct uslcom_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uticom.c b/sys/dev/usb/uticom.c index 5ce26e2093e..9beddabfdbc 100644 --- a/sys/dev/usb/uticom.c +++ b/sys/dev/usb/uticom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uticom.c,v 1.21 2013/11/07 10:32:51 pirofti Exp $ */ +/* $OpenBSD: uticom.c,v 1.22 2013/11/15 08:25:31 pirofti Exp $ */ /* * Copyright (c) 2005 Dmitry Komissaroff <dxi@mail.ru>. * @@ -462,16 +462,13 @@ int uticom_activate(struct device *self, int act) { struct uticom_softc *sc = (struct uticom_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uvisor.c b/sys/dev/usb/uvisor.c index d053ec62f1a..1ff82b0d30b 100644 --- a/sys/dev/usb/uvisor.c +++ b/sys/dev/usb/uvisor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvisor.c,v 1.47 2013/11/07 12:54:35 pirofti Exp $ */ +/* $OpenBSD: uvisor.c,v 1.48 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: uvisor.c,v 1.21 2003/08/03 21:59:26 nathanw Exp $ */ /* @@ -377,20 +377,13 @@ int uvisor_activate(struct device *self, int act) { struct uvisor_softc *sc = (struct uvisor_softc *)self; - int i, rv = 0, r; switch (act) { case DVACT_DEACTIVATE: - for (i = 0; i < sc->sc_numcon; i++) - if (sc->sc_subdevs[i] != NULL) { - r = config_deactivate(sc->sc_subdevs[i]); - if (r) - rv = r; - } usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } int diff --git a/sys/dev/usb/uvscom.c b/sys/dev/usb/uvscom.c index ea1bc4c422e..2fb1d9c81fb 100644 --- a/sys/dev/usb/uvscom.c +++ b/sys/dev/usb/uvscom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvscom.c,v 1.28 2013/11/07 10:33:09 pirofti Exp $ */ +/* $OpenBSD: uvscom.c,v 1.29 2013/11/15 08:25:31 pirofti Exp $ */ /* $NetBSD: uvscom.c,v 1.9 2003/02/12 15:36:20 ichiro Exp $ */ /*- * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. @@ -388,16 +388,13 @@ int uvscom_activate(struct device *self, int act) { struct uvscom_softc *sc = (struct uvscom_softc *)self; - int rv = 0; switch (act) { case DVACT_DEACTIVATE: - if (sc->sc_subdev != NULL) - rv = config_deactivate(sc->sc_subdev); usbd_deactivate(sc->sc_udev); break; } - return (rv); + return (0); } usbd_status |