Source-Changes-HG archive

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

[.joined/src/trunk]: .joined/src/sys/dev/usb umass(4): Omit needless referenc...



details:   https://anonhg.NetBSD.org/.joined/src/rev/733a725a82a1
branches:  trunk
changeset: 359339:733a725a82a1
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Dec 31 14:24:16 2021 +0000

description:
umass(4): Omit needless reference counting.

autoconf never detaches before attach has completed, so there is no
longer any need for this mechanism.

diffstat:

 sys/dev/usb/umass.c        |  18 ++----------------
 sys/dev/usb/umass_scsipi.c |  23 ++++++-----------------
 sys/dev/usb/umassvar.h     |   4 +---
 3 files changed, 9 insertions(+), 36 deletions(-)

diffs (149 lines):

diff -r 06b9bbf7ea99 -r 733a725a82a1 sys/dev/usb/umass.c
--- a/sys/dev/usb/umass.c       Fri Dec 31 14:24:06 2021 +0000
+++ b/sys/dev/usb/umass.c       Fri Dec 31 14:24:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass.c,v 1.186 2021/09/16 22:19:11 andvar Exp $       */
+/*     $NetBSD: umass.c,v 1.187 2021/12/31 14:24:16 riastradh Exp $    */
 
 /*
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -124,7 +124,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.186 2021/09/16 22:19:11 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.187 2021/12/31 14:24:16 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -392,7 +392,6 @@
        aprint_normal("\n");
 
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SOFTUSB);
-       cv_init(&sc->sc_detach_cv, "umassdet");
 
        devinfop = usbd_devinfo_alloc(uiaa->uiaa_device, 0);
        aprint_normal_dev(self, "%s\n", devinfop);
@@ -872,18 +871,6 @@
        }
        usbd_abort_default_pipe(sc->sc_udev);
 
-       /* Do we really need reference counting?  Perhaps in ioctl() */
-       mutex_enter(&sc->sc_lock);
-       if (--sc->sc_refcnt >= 0) {
-#ifdef DIAGNOSTIC
-               aprint_normal_dev(self, "waiting for refcnt\n");
-#endif
-               /* Wait for processes to go away. */
-               if (cv_timedwait(&sc->sc_detach_cv, &sc->sc_lock, hz * 60))
-                       aprint_error_dev(self, ": didn't detach\n");
-       }
-       mutex_exit(&sc->sc_lock);
-
        scbus = sc->bus;
        if (scbus != NULL) {
                if (scbus->sc_child != NULL)
@@ -925,7 +912,6 @@
        usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev, sc->sc_dev);
 
        mutex_destroy(&sc->sc_lock);
-       cv_destroy(&sc->sc_detach_cv);
 
 out:   SDT_PROBE2(usb, umass, device, detach__done,  sc, rv);
        return rv;
diff -r 06b9bbf7ea99 -r 733a725a82a1 sys/dev/usb/umass_scsipi.c
--- a/sys/dev/usb/umass_scsipi.c        Fri Dec 31 14:24:06 2021 +0000
+++ b/sys/dev/usb/umass_scsipi.c        Fri Dec 31 14:24:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass_scsipi.c,v 1.69 2021/08/07 16:19:17 thorpej Exp $        */
+/*     $NetBSD: umass_scsipi.c,v 1.70 2021/12/31 14:24:16 riastradh Exp $      */
 
 /*
  * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.69 2021/08/07 16:19:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.70 2021/12/31 14:24:16 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -131,6 +131,8 @@
        UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct umass_scsipi_softc *scbus;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        scbus = umass_scsipi_setup(sc);
 
        scbus->sc_channel.chan_bustype = &scsi_bustype;
@@ -139,17 +141,9 @@
        scbus->sc_channel.chan_id = scbus->sc_channel.chan_ntargets - 1;
        DPRINTFM(UDMASS_USB, "sc %#jx: SCSI", (uintptr_t)sc, 0, 0, 0);
 
-       mutex_enter(&sc->sc_lock);
-       sc->sc_refcnt++;
-       mutex_exit(&sc->sc_lock);
        scbus->base.sc_child =
            config_found(sc->sc_dev, &scbus->sc_channel, scsiprint,
                         CFARGS(.iattr = "scsi"));
-       mutex_enter(&sc->sc_lock);
-       if (--sc->sc_refcnt < 0)
-               cv_broadcast(&sc->sc_detach_cv);
-       mutex_exit(&sc->sc_lock);
-
 
        return 0;
 }
@@ -171,6 +165,8 @@
        UMASSHIST_FUNC(); UMASSHIST_CALLED();
        struct umass_scsipi_softc *scbus;
 
+       KASSERT(KERNEL_LOCKED_P());
+
        scbus = umass_scsipi_setup(sc);
        scbus->sc_atapi_adapter.atapi_probe_device =  umass_atapi_probe_device;
 
@@ -181,16 +177,9 @@
        scbus->sc_channel.chan_defquirks |= sc->sc_busquirks;
        DPRINTFM(UDMASS_USB, "sc %#jxp: ATAPI", (uintptr_t)sc, 0, 0, 0);
 
-       mutex_enter(&sc->sc_lock);
-       sc->sc_refcnt++;
-       mutex_exit(&sc->sc_lock);
        scbus->base.sc_child =
            config_found(sc->sc_dev, &scbus->sc_channel, atapiprint,
                         CFARGS(.iattr = "atapi"));
-       mutex_enter(&sc->sc_lock);
-       if (--sc->sc_refcnt < 0)
-               cv_broadcast(&sc->sc_detach_cv);
-       mutex_exit(&sc->sc_lock);
 
        return 0;
 }
diff -r 06b9bbf7ea99 -r 733a725a82a1 sys/dev/usb/umassvar.h
--- a/sys/dev/usb/umassvar.h    Fri Dec 31 14:24:06 2021 +0000
+++ b/sys/dev/usb/umassvar.h    Fri Dec 31 14:24:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umassvar.h,v 1.39 2018/11/13 10:30:57 mlelstv Exp $    */
+/*     $NetBSD: umassvar.h,v 1.40 2021/12/31 14:24:16 riastradh Exp $  */
 
 /*-
  * Copyright (c) 1999 MAEKAWA Masahide <bishop%rr.iij4u.or.jp@localhost>,
@@ -167,7 +167,6 @@
        const struct umass_wire_methods *sc_methods;
 
        kmutex_t                sc_lock;
-       kcondvar_t              sc_detach_cv;
 
        uint8_t                 sc_wire;        /* wire protocol */
 #define        UMASS_WPROTO_UNSPEC     0
@@ -276,7 +275,6 @@
 #endif
 
        char                    sc_dying;
-       int                     sc_refcnt;
        int                     sc_sense;
 
        struct umassbus_softc   *bus;            /* bus dependent data */



Home | Main Index | Thread Index | Old Index