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): Move CFDRIVER_DECL and CFATTACH_DECL3...



details:   https://anonhg.NetBSD.org/src/rev/287c26dcfb13
branches:  trunk
changeset: 374381:287c26dcfb13
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 21 18:26:35 2023 +0000

description:
dk(4): Move CFDRIVER_DECL and CFATTACH_DECL3_NEW earlier in file.

Follows the pattern of most drivers, and will be necessary for
referencing dk_cd in dk_bdevsw and dk_cdevsw soon, to prevent
open/detach races.

No functional change intended.

diffstat:

 sys/dev/dkwedge/dk.c |  18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diffs (53 lines):

diff -r 55f202dedaa7 -r 287c26dcfb13 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c      Fri Apr 21 18:25:49 2023 +0000
+++ b/sys/dev/dkwedge/dk.c      Fri Apr 21 18:26:35 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dk.c,v 1.135 2023/04/21 18:25:49 riastradh Exp $       */
+/*     $NetBSD: dk.c,v 1.136 2023/04/21 18:26:35 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.135 2023/04/21 18:25:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.136 2023/04/21 18:26:35 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -96,6 +96,10 @@ struct dkwedge_softc {
        int             sc_mode;        /* parent open mode */
 };
 
+static int     dkwedge_match(device_t, cfdata_t, void *);
+static void    dkwedge_attach(device_t, device_t, void *);
+static int     dkwedge_detach(device_t, int);
+
 static void    dkstart(struct dkwedge_softc *);
 static void    dkiodone(struct buf *);
 static void    dkrestart(void *);
@@ -120,6 +124,11 @@ static dev_type_dump(dkdump);
 static dev_type_size(dksize);
 static dev_type_discard(dkdiscard);
 
+CFDRIVER_DECL(dk, DV_DISK, NULL);
+CFATTACH_DECL3_NEW(dk, 0,
+    dkwedge_match, dkwedge_attach, dkwedge_detach, NULL, NULL, NULL,
+    DVF_DETACH_SHUTDOWN);
+
 const struct bdevsw dk_bdevsw = {
        .d_open = dkopen,
        .d_close = dkclose,
@@ -179,11 +188,6 @@ dkwedge_attach(device_t parent, device_t
                aprint_error_dev(self, "couldn't establish power handler\n");
 }
 
-CFDRIVER_DECL(dk, DV_DISK, NULL);
-CFATTACH_DECL3_NEW(dk, 0,
-    dkwedge_match, dkwedge_attach, dkwedge_detach, NULL, NULL, NULL,
-    DVF_DETACH_SHUTDOWN);
-
 /*
  * dkwedge_wait_drain:
  *



Home | Main Index | Thread Index | Old Index