Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/dkwedge dk(4): dkunit is no longer needed; nix it.



details:   https://anonhg.NetBSD.org/src/rev/2cd3c1b0a81a
branches:  trunk
changeset: 375928:2cd3c1b0a81a
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon May 22 14:58:41 2023 +0000

description:
dk(4): dkunit is no longer needed; nix it.

dkwedges array indexing now coincides with autoconf device numbering.

diffstat:

 sys/dev/dkwedge/dk.c |  40 ++++------------------------------------
 1 files changed, 4 insertions(+), 36 deletions(-)

diffs (82 lines):

diff -r 3a48eaa5509d -r 2cd3c1b0a81a sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Mon May 22 14:58:32 2023 +0000
+++ b/sys/dev/dkwedge/dk.c      Mon May 22 14:58:41 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.159 2023/05/22 14:58:32 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.160 2023/05/22 14:58:41 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.159 2023/05/22 14:58:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.160 2023/05/22 14:58:41 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -114,8 +114,6 @@ static int  dkwedge_del1(struct dkwedge_i
 static int     dk_open_parent(dev_t, int, struct vnode **);
 static int     dk_close_parent(struct vnode *, int);
 
-static int     dkunit(dev_t);
-
 static dev_type_open(dkopen);
 static dev_type_close(dkclose);
 static dev_type_cancel(dkcancel);
@@ -142,7 +140,7 @@ const struct bdevsw dk_bdevsw = {
        .d_psize = dksize,
        .d_discard = dkdiscard,
        .d_cfdriver = &dk_cd,
-       .d_devtounit = dkunit,
+       .d_devtounit = dev_minor_unit,
        .d_flag = D_DISK | D_MPSAFE
 };
 
@@ -160,7 +158,7 @@ const struct cdevsw dk_cdevsw = {
        .d_kqfilter = nokqfilter,
        .d_discard = dkdiscard,
        .d_cfdriver = &dk_cd,
-       .d_devtounit = dkunit,
+       .d_devtounit = dev_minor_unit,
        .d_flag = D_DISK | D_MPSAFE
 };
 
@@ -1224,36 +1222,6 @@ dk_close_parent(struct vnode *vp, int mo
 }
 
 /*
- * dkunit:             [devsw entry point]
- *
- *     Return the autoconf device_t unit number of a wedge by its
- *     devsw dev_t number, or -1 if there is none.
- *
- *     XXX This is a temporary hack until dkwedge numbering is made to
- *     correspond 1:1 to autoconf device numbering.
- */
-static int
-dkunit(dev_t dev)
-{
-       int mn = minor(dev);
-       struct dkwedge_softc *sc;
-       device_t dv;
-       int unit = -1;
-
-       if (mn < 0)
-               return -1;
-
-       rw_enter(&dkwedges_lock, RW_READER);
-       if (mn < ndkwedges &&
-           (sc = dkwedges[minor(dev)]) != NULL &&
-           (dv = sc->sc_dev) != NULL)
-               unit = device_unit(dv);
-       rw_exit(&dkwedges_lock);
-
-       return unit;
-}
-
-/*
  * dkopen:             [devsw entry point]
  *
  *     Open a wedge.



Home | Main Index | Thread Index | Old Index