Module Name:    src
Committed By:   riastradh
Date:           Fri Apr 21 18:26:36 UTC 2023

Modified Files:
        src/sys/dev/dkwedge: dk.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sys/dev/dkwedge/dk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.135 src/sys/dev/dkwedge/dk.c:1.136
--- src/sys/dev/dkwedge/dk.c:1.135	Fri Apr 21 18:25:49 2023
+++ src/sys/dev/dkwedge/dk.c	Fri Apr 21 18:26:35 2023
@@ -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:
  *

Reply via email to