diff options
author | 2013-11-07 10:32:51 +0000 | |
---|---|---|
committer | 2013-11-07 10:32:51 +0000 | |
commit | cbb8e2d402387c84ae554cf2009f248cdb0a0db3 (patch) | |
tree | ed8301753af7aa1fc0ff4b1b2672bfd1ec0e2047 | |
parent | Make sure to mark the controller as dying in order to stop processing (diff) | |
download | wireguard-openbsd-cbb8e2d402387c84ae554cf2009f248cdb0a0db3.tar.xz wireguard-openbsd-cbb8e2d402387c84ae554cf2009f248cdb0a0db3.zip |
Replace sc_dying in favour of usbd_is_dying() and usbd_deactivate().
Okay mpi@
-rw-r--r-- | sys/dev/usb/uchcom.c | 22 | ||||
-rw-r--r-- | sys/dev/usb/umsm.c | 17 | ||||
-rw-r--r-- | sys/dev/usb/uslcom.c | 18 | ||||
-rw-r--r-- | sys/dev/usb/uticom.c | 45 | ||||
-rw-r--r-- | sys/dev/usb/uts.c | 17 | ||||
-rw-r--r-- | sys/dev/usb/uvscom.c | 27 |
6 files changed, 69 insertions, 77 deletions
diff --git a/sys/dev/usb/uchcom.c b/sys/dev/usb/uchcom.c index 21cce2cd147..3ef17be23ba 100644 --- a/sys/dev/usb/uchcom.c +++ b/sys/dev/usb/uchcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uchcom.c,v 1.16 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: uchcom.c,v 1.17 2013/11/07 10:33:27 pirofti Exp $ */ /* $NetBSD: uchcom.c,v 1.1 2007/09/03 17:57:37 tshiozak Exp $ */ /* @@ -112,7 +112,6 @@ struct uchcom_softc struct usbd_device *sc_udev; struct device *sc_subdev; struct usbd_interface *sc_iface; - int sc_dying; /* */ int sc_intr_endpoint; int sc_intr_size; @@ -262,7 +261,6 @@ uchcom_attach(struct device *parent, struct device *self, void *aux) struct uchcom_endpoints endpoints; sc->sc_udev = dev; - sc->sc_dying = 0; sc->sc_dtr = sc->sc_rts = -1; sc->sc_lsr = sc->sc_msr = 0; @@ -308,7 +306,7 @@ uchcom_attach(struct device *parent, struct device *self, void *aux) return; failed: - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); } int @@ -338,7 +336,7 @@ uchcom_activate(struct device *self, int act) switch (act) { case DVACT_DEACTIVATE: uchcom_close_intr_pipe(sc); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); if (sc->sc_subdev != NULL) rv = config_deactivate(sc->sc_subdev); break; @@ -896,7 +894,7 @@ uchcom_close_intr_pipe(struct uchcom_softc *sc) { usbd_status err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (sc->sc_intr_pipe != NULL) { @@ -922,7 +920,7 @@ uchcom_get_status(void *arg, int portno, u_char *rlsr, u_char *rmsr) { struct uchcom_softc *sc = arg; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; *rlsr = sc->sc_lsr; @@ -934,7 +932,7 @@ uchcom_set(void *arg, int portno, int reg, int onoff) { struct uchcom_softc *sc = arg; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; switch (reg) { @@ -958,7 +956,7 @@ uchcom_param(void *arg, int portno, struct termios *t) struct uchcom_softc *sc = arg; int ret; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return 0; ret = uchcom_set_line_control(sc, t->c_cflag); @@ -978,7 +976,7 @@ uchcom_open(void *arg, int portno) int ret; struct uchcom_softc *sc = arg; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return EIO; ret = uchcom_setup_intr_pipe(sc); @@ -997,7 +995,7 @@ uchcom_close(void *arg, int portno) { struct uchcom_softc *sc = arg; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; uchcom_close_intr_pipe(sc); @@ -1013,7 +1011,7 @@ uchcom_intr(struct usbd_xfer *xfer, void *priv, usbd_status status) struct uchcom_softc *sc = priv; u_char *buf = sc->sc_intr_buf; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (status != USBD_NORMAL_COMPLETION) { diff --git a/sys/dev/usb/umsm.c b/sys/dev/usb/umsm.c index 14fb7b3bec0..d76e52568d6 100644 --- a/sys/dev/usb/umsm.c +++ b/sys/dev/usb/umsm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umsm.c,v 1.92 2013/09/20 15:34:51 mpi Exp $ */ +/* $OpenBSD: umsm.c,v 1.93 2013/11/07 10:34:20 pirofti Exp $ */ /* * Copyright (c) 2008 Yojiro UO <yuo@nui.org> @@ -71,7 +71,6 @@ struct umsm_softc { struct usbd_interface *sc_iface; int sc_iface_no; struct device *sc_subdev; - u_char sc_dying; uint16_t sc_flag; /* interrupt ep */ @@ -370,7 +369,7 @@ umsm_attach(struct device *parent, struct device *self, void *aux) if (ed == NULL) { printf("%s: no endpoint descriptor found for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -389,7 +388,7 @@ umsm_attach(struct device *parent, struct device *self, void *aux) } if (uca.bulkin == -1 || uca.bulkout == -1) { printf("%s: missing endpoint\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -424,7 +423,7 @@ umsm_detach(struct device *self, int flags) sc->sc_intr_pipe = NULL; } - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); if (sc->sc_subdev != NULL) { rv = config_detach(sc->sc_subdev, flags); sc->sc_subdev = NULL; @@ -443,7 +442,7 @@ umsm_activate(struct device *self, int act) case DVACT_DEACTIVATE: if (sc->sc_subdev != NULL) rv = config_deactivate(sc->sc_subdev); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return (rv); @@ -455,7 +454,7 @@ umsm_open(void *addr, int portno) struct umsm_softc *sc = addr; int err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (ENXIO); if (sc->sc_intr_number != -1 && sc->sc_intr_pipe == NULL) { @@ -486,7 +485,7 @@ umsm_close(void *addr, int portno) struct umsm_softc *sc = addr; int err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (sc->sc_intr_pipe != NULL) { @@ -514,7 +513,7 @@ umsm_intr(struct usbd_xfer *xfer, void *priv, u_char mstatus; buf = (struct usb_cdc_notification *)sc->sc_intr_buf; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (status != USBD_NORMAL_COMPLETION) { diff --git a/sys/dev/usb/uslcom.c b/sys/dev/usb/uslcom.c index e6f19b6d0e1..782ce69dfff 100644 --- a/sys/dev/usb/uslcom.c +++ b/sys/dev/usb/uslcom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uslcom.c,v 1.28 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: uslcom.c,v 1.29 2013/11/07 10:34:02 pirofti Exp $ */ /* * Copyright (c) 2006 Jonathan Gray <jsg@openbsd.org> @@ -94,8 +94,6 @@ struct uslcom_softc { u_char sc_msr; u_char sc_lsr; - - u_char sc_dying; }; void uslcom_get_status(void *, int portno, u_char *lsr, u_char *msr); @@ -269,7 +267,7 @@ uslcom_attach(struct device *parent, struct device *self, void *aux) if (usbd_set_config_index(sc->sc_udev, USLCOM_CONFIG_NO, 1) != 0) { printf("%s: could not set configuration no\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -279,7 +277,7 @@ uslcom_attach(struct device *parent, struct device *self, void *aux) if (error != 0) { printf("%s: could not get interface handle\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -291,7 +289,7 @@ uslcom_attach(struct device *parent, struct device *self, void *aux) if (ed == NULL) { printf("%s: no endpoint descriptor found for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -305,7 +303,7 @@ uslcom_attach(struct device *parent, struct device *self, void *aux) if (uca.bulkin == -1 || uca.bulkout == -1) { printf("%s: missing endpoint\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -346,7 +344,7 @@ uslcom_activate(struct device *self, int act) case DVACT_DEACTIVATE: if (sc->sc_subdev != NULL) rv = config_deactivate(sc->sc_subdev); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return (rv); @@ -359,7 +357,7 @@ uslcom_open(void *vsc, int portno) usb_device_request_t req; usbd_status err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); req.bmRequestType = USLCOM_WRITE; @@ -380,7 +378,7 @@ uslcom_close(void *vsc, int portno) struct uslcom_softc *sc = vsc; usb_device_request_t req; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; req.bmRequestType = USLCOM_WRITE; diff --git a/sys/dev/usb/uticom.c b/sys/dev/usb/uticom.c index be374862bb5..5ce26e2093e 100644 --- a/sys/dev/usb/uticom.c +++ b/sys/dev/usb/uticom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uticom.c,v 1.20 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: uticom.c,v 1.21 2013/11/07 10:32:51 pirofti Exp $ */ /* * Copyright (c) 2005 Dmitry Komissaroff <dxi@mail.ru>. * @@ -139,7 +139,6 @@ struct uticom_softc { u_char sc_msr; /* uticom status register */ struct device *sc_subdev; - u_char sc_dying; }; static usbd_status uticom_reset(struct uticom_softc *); @@ -261,7 +260,7 @@ uticom_attach_hook(void *arg) if (err) { printf("%s: failed to set configuration: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -271,7 +270,7 @@ uticom_attach_hook(void *arg) if (cdesc == NULL) { printf("%s: failed to get configuration descriptor\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -280,7 +279,7 @@ uticom_attach_hook(void *arg) if (err) { printf("%s: failed to get interface: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -293,7 +292,7 @@ uticom_attach_hook(void *arg) if (ed == NULL) { printf("%s: no endpoint descriptor for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -307,7 +306,7 @@ uticom_attach_hook(void *arg) if (uca.bulkout == -1) { printf("%s: could not find data bulk out\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } } @@ -317,7 +316,7 @@ uticom_attach_hook(void *arg) if (status) { printf("%s: firmware download failed\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } else { DPRINTF(("%s: firmware download succeeded\n", @@ -328,7 +327,7 @@ uticom_attach_hook(void *arg) if (status) { printf("%s: error reloading device descriptor\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -341,7 +340,7 @@ fwload_done: if (err) { printf("%s: failed to set configuration: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -350,7 +349,7 @@ fwload_done: if (cdesc == NULL) { printf("%s: failed to get configuration descriptor\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -360,7 +359,7 @@ fwload_done: if (err) { printf("%s: failed to get interface: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -373,7 +372,7 @@ fwload_done: if (ed == NULL) { printf("%s: no endpoint descriptor for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -388,7 +387,7 @@ fwload_done: if (sc->sc_intr_number == -1) { printf("%s: could not find interrupt in\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -404,7 +403,7 @@ fwload_done: if (ed == NULL) { printf("%s: no endpoint descriptor for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -420,14 +419,14 @@ fwload_done: if (uca.bulkin == -1) { printf("%s: could not find data bulk in\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } if (uca.bulkout == -1) { printf("%s: could not find data bulk out\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -448,7 +447,7 @@ fwload_done: if (err) { printf("%s: reset failed: %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -469,7 +468,7 @@ uticom_activate(struct device *self, int act) case DVACT_DEACTIVATE: if (sc->sc_subdev != NULL) rv = config_deactivate(sc->sc_subdev); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return (rv); @@ -736,7 +735,7 @@ uticom_open(void *addr, int portno) struct uticom_softc *sc = addr; usbd_status err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (ENXIO); DPRINTF(("%s: uticom_open\n", sc->sc_dev.dv_xname)); @@ -766,7 +765,7 @@ uticom_close(void *addr, int portno) usb_device_request_t req; usbd_status err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; req.bmRequestType = UT_WRITE_VENDOR_DEVICE; @@ -805,7 +804,7 @@ uticom_intr(struct usbd_xfer *xfer, void *priv, usbd_status status) struct uticom_softc *sc = priv; u_char *buf = sc->sc_intr_buf; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (status != USBD_NORMAL_COMPLETION) { @@ -881,7 +880,7 @@ uticom_ioctl(void *addr, int portno, u_long cmd, caddr_t data, int flag, struct uticom_softc *sc = addr; int error = 0; - if (sc->sc_ucom.sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); DPRINTF(("uticom_ioctl: cmd = 0x%08lx\n", cmd)); diff --git a/sys/dev/usb/uts.c b/sys/dev/usb/uts.c index 7d7aedf13bc..7b2c2efa0fe 100644 --- a/sys/dev/usb/uts.c +++ b/sys/dev/usb/uts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uts.c,v 1.31 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: uts.c,v 1.32 2013/11/07 10:33:43 pirofti Exp $ */ /* * Copyright (c) 2007 Robert Nagy <robert@openbsd.org> @@ -78,7 +78,6 @@ struct uts_softc { int sc_enabled; int sc_buttons; - int sc_dying; int sc_oldx; int sc_oldy; int sc_rawmode; @@ -173,7 +172,7 @@ uts_attach(struct device *parent, struct device *self, void *aux) if (usbd_set_config_index(uaa->device, UTS_CONFIG_INDEX, 1) != 0) { printf("%s: could not set configuartion no\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -182,7 +181,7 @@ uts_attach(struct device *parent, struct device *self, void *aux) if (cdesc == NULL) { printf("%s: failed to get configuration descriptor\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -190,7 +189,7 @@ uts_attach(struct device *parent, struct device *self, void *aux) if (usbd_device2interface_handle(uaa->device, 0, &sc->sc_iface) != 0) { printf("%s: failed to get interface\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -203,7 +202,7 @@ uts_attach(struct device *parent, struct device *self, void *aux) if (ed == NULL) { printf("%s: no endpoint descriptor for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -217,7 +216,7 @@ uts_attach(struct device *parent, struct device *self, void *aux) if (sc->sc_intr_number== -1) { printf("%s: Could not find interrupt in\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -257,7 +256,7 @@ uts_activate(struct device *self, int act) case DVACT_DEACTIVATE: if (sc->sc_wsmousedev != NULL) rv = config_deactivate(sc->sc_wsmousedev); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } @@ -270,7 +269,7 @@ uts_enable(void *v) struct uts_softc *sc = v; int err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); if (sc->sc_enabled) diff --git a/sys/dev/usb/uvscom.c b/sys/dev/usb/uvscom.c index c0610c82f14..ea1bc4c422e 100644 --- a/sys/dev/usb/uvscom.c +++ b/sys/dev/usb/uvscom.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvscom.c,v 1.27 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: uvscom.c,v 1.28 2013/11/07 10:33:09 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>. @@ -150,7 +150,6 @@ struct uvscom_softc { u_char sc_usr; /* unit status */ struct device *sc_subdev; /* ucom device */ - u_char sc_dying; /* disconnecting */ }; /* @@ -261,7 +260,7 @@ uvscom_attach(struct device *parent, struct device *self, void *aux) if (err) { printf("%s: failed to set configuration, err=%s\n", devname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -271,7 +270,7 @@ uvscom_attach(struct device *parent, struct device *self, void *aux) if (cdesc == NULL) { printf("%s: failed to get configuration descriptor\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -281,7 +280,7 @@ uvscom_attach(struct device *parent, struct device *self, void *aux) if (err) { printf("%s: failed to get interface, err=%s\n", devname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -294,7 +293,7 @@ uvscom_attach(struct device *parent, struct device *self, void *aux) if (ed == NULL) { printf("%s: no endpoint descriptor for %d\n", sc->sc_dev.dv_xname, i); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -314,19 +313,19 @@ uvscom_attach(struct device *parent, struct device *self, void *aux) if (uca.bulkin == -1) { printf("%s: Could not find data bulk in\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } if (uca.bulkout == -1) { printf("%s: Could not find data bulk out\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } if (sc->sc_intr_number == -1) { printf("%s: Could not find interrupt in\n", sc->sc_dev.dv_xname); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -350,7 +349,7 @@ uvscom_attach(struct device *parent, struct device *self, void *aux) if (err) { printf("%s: reset failed, %s\n", sc->sc_dev.dv_xname, usbd_errstr(err)); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); return; } @@ -395,7 +394,7 @@ uvscom_activate(struct device *self, int act) case DVACT_DEACTIVATE: if (sc->sc_subdev != NULL) rv = config_deactivate(sc->sc_subdev); - sc->sc_dying = 1; + usbd_deactivate(sc->sc_udev); break; } return (rv); @@ -701,7 +700,7 @@ uvscom_open(void *addr, int portno) int err; int i; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return (EIO); DPRINTF(("uvscom_open: sc = %p\n", sc)); @@ -769,7 +768,7 @@ uvscom_close(void *addr, int portno) struct uvscom_softc *sc = addr; int err; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; DPRINTF(("uvscom_close: close\n")); @@ -799,7 +798,7 @@ uvscom_intr(struct usbd_xfer *xfer, void *priv, usbd_status status) u_char *buf = sc->sc_intr_buf; u_char pstatus; - if (sc->sc_dying) + if (usbd_is_dying(sc->sc_udev)) return; if (status != USBD_NORMAL_COMPLETION) { |