Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb uhidev(9): Omit needless sc_dying.



details:   https://anonhg.NetBSD.org/src/rev/4b1276e18317
branches:  trunk
changeset: 364545:4b1276e18317
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Mar 28 12:44:28 2022 +0000

description:
uhidev(9): Omit needless sc_dying.

diffstat:

 sys/dev/usb/uhidev.c |  55 +++++----------------------------------------------
 1 files changed, 6 insertions(+), 49 deletions(-)

diffs (163 lines):

diff -r ddeca4aec129 -r 4b1276e18317 sys/dev/usb/uhidev.c
--- a/sys/dev/usb/uhidev.c      Mon Mar 28 12:44:17 2022 +0000
+++ b/sys/dev/usb/uhidev.c      Mon Mar 28 12:44:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhidev.c,v 1.90 2022/03/28 12:44:17 riastradh Exp $    */
+/*     $NetBSD: uhidev.c,v 1.91 2022/03/28 12:44:28 riastradh Exp $    */
 
 /*
  * Copyright (c) 2001, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.90 2022/03/28 12:44:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhidev.c,v 1.91 2022/03/28 12:44:28 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -110,7 +110,6 @@
        int sc_refcnt;
        int sc_writereportid;
        int sc_stopreportid;
-       u_char sc_dying;
 
        /*
         * - Read under sc_lock, provided sc_refcnt > 0.
@@ -146,10 +145,9 @@
 static void uhidev_attach(device_t, device_t, void *);
 static void uhidev_childdet(device_t, device_t);
 static int uhidev_detach(device_t, int);
-static int uhidev_activate(device_t, enum devact);
 
 CFATTACH_DECL2_NEW(uhidev, sizeof(struct uhidev_softc), uhidev_match,
-    uhidev_attach, uhidev_detach, uhidev_activate, NULL, uhidev_childdet);
+    uhidev_attach, uhidev_detach, NULL, NULL, uhidev_childdet);
 
 static int
 uhidev_match(device_t parent, cfdata_t match, void *aux)
@@ -203,7 +201,6 @@
        sc->sc_refcnt = 0;
        sc->sc_writereportid = -1;
        sc->sc_stopreportid = -1;
-       sc->sc_dying = false;
 
        id = usbd_get_interface_descriptor(iface);
 
@@ -244,7 +241,6 @@
                if (ed == NULL) {
                        aprint_error_dev(self,
                            "could not read endpoint descriptor\n");
-                       sc->sc_dying = 1;
                        return;
                }
 
@@ -275,7 +271,6 @@
         */
        if (sc->sc_iep_addr == -1) {
                aprint_error_dev(self, "no input interrupt endpoint\n");
-               sc->sc_dying = 1;
                return;
        }
 
@@ -336,7 +331,6 @@
        }
        if (err) {
                aprint_error_dev(self, "no report descriptor\n");
-               sc->sc_dying = 1;
                return;
        }
 
@@ -479,20 +473,6 @@
        return UNCONF;
 }
 
-static int
-uhidev_activate(device_t self, enum devact act)
-{
-       struct uhidev_softc *sc = device_private(self);
-
-       switch (act) {
-       case DVACT_DEACTIVATE:
-               sc->sc_dying = 1;
-               return 0;
-       default:
-               return EOPNOTSUPP;
-       }
-}
-
 static void
 uhidev_childdet(device_t self, device_t child)
 {
@@ -523,26 +503,17 @@
 
        DPRINTF(("uhidev_detach: sc=%p flags=%d\n", sc, flags));
 
-       /* Notify that we are going away.  */
-       mutex_enter(&sc->sc_lock);
-       sc->sc_dying = 1;
-       cv_broadcast(&sc->sc_cv);
-       mutex_exit(&sc->sc_lock);
-
        /*
         * Try to detach all our children.  If anything fails, bail.
         * Failure can happen if this is from drvctl -d; of course, if
         * this is a USB device being yanked, flags will have
         * DETACH_FORCE and the children will not have the option of
-        * refusing detachment.
+        * refusing detachment.  If they do detach, the pipes can no
+        * longer be in use.
         */
        rv = config_detach_children(self, flags);
-       if (rv) {
-               mutex_enter(&sc->sc_lock);
-               sc->sc_dying = 0;
-               mutex_exit(&sc->sc_lock);
+       if (rv)
                return rv;
-       }
 
        KASSERTMSG(sc->sc_refcnt == 0,
            "%s: %d refs remain", device_xname(sc->sc_dev), sc->sc_refcnt);
@@ -650,8 +621,6 @@
        KASSERT(mutex_owned(&sc->sc_lock));
 
        for (;;) {
-               if (sc->sc_dying)
-                       return ENXIO;
                if (sc->sc_configlock == NULL)
                        break;
                error = cv_wait_sig(&sc->sc_cv, &sc->sc_lock);
@@ -700,10 +669,6 @@
 
        KASSERT(mutex_owned(&sc->sc_lock));
 
-       /* If the device is dying, refuse.  */
-       if (sc->sc_dying)
-               return ENXIO;
-
        /*
         * If the pipes are already open, just increment the reference
         * count, or fail if it would overflow.
@@ -1122,10 +1087,6 @@
        mutex_enter(&sc->sc_lock);
        KASSERT(sc->sc_refcnt);
        for (;;) {
-               if (sc->sc_dying) {
-                       err = USBD_IOERROR;
-                       goto out;
-               }
                if (scd->sc_state & UHIDEV_STOPPED) {
                        err = USBD_CANCELLED;
                        goto out;
@@ -1210,10 +1171,6 @@
 
        mutex_enter(&sc->sc_lock);
        KASSERT(sc->sc_refcnt);
-       if (sc->sc_dying) {
-               err = USBD_IOERROR;
-               goto out;
-       }
        if (scd->sc_state & UHIDEV_STOPPED) {
                err = USBD_CANCELLED;
                goto out;



Home | Main Index | Thread Index | Old Index