Module Name:    src
Committed By:   martin
Date:           Fri Aug 23 15:29:32 UTC 2024

Modified Files:
        src/sys/netbt [netbsd-10]: bt_proto.c

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #788):

        sys/netbt/bt_proto.c: revision 1.17

netbt(4): Initialize bt_lock earlier.

Use a driver-class module modcmd init function, instead of a socket
domain init function; the socket-domain ones don't run until after
configure, but we need this to be initialized before configure so
that Bluetooth HCI drivers like ubt(4) can use it.

This is suboptimal but it's the least intrusive way I've thought of
to get this working, even if it's a little grody to make netbt a
`driver-class' (builtin) module.  Note that this doesn't mean netbt
becomes dynamically loadable or unloadable; we're just using a module
for initialization ordering.

PR kern/56988


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.16.48.1 src/sys/netbt/bt_proto.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/netbt/bt_proto.c
diff -u src/sys/netbt/bt_proto.c:1.16 src/sys/netbt/bt_proto.c:1.16.48.1
--- src/sys/netbt/bt_proto.c:1.16	Thu Jan 21 15:41:30 2016
+++ src/sys/netbt/bt_proto.c	Fri Aug 23 15:29:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: bt_proto.c,v 1.16 2016/01/21 15:41:30 riastradh Exp $	*/
+/*	$NetBSD: bt_proto.c,v 1.16.48.1 2024/08/23 15:29:32 martin Exp $	*/
 
 /*-
  * Copyright (c) 2005 Iain Hibbert.
@@ -31,11 +31,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bt_proto.c,v 1.16 2016/01/21 15:41:30 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bt_proto.c,v 1.16.48.1 2024/08/23 15:29:32 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/domain.h>
 #include <sys/kernel.h>
+#include <sys/module.h>
 #include <sys/protosw.h>
 #include <sys/socket.h>
 #include <sys/systm.h>
@@ -113,6 +114,21 @@ kmutex_t *bt_lock;
 static void
 bt_init(void)
 {
+}
+
+MODULE(MODULE_CLASS_DRIVER, netbt, NULL);
+
+static int
+netbt_modcmd(modcmd_t cmd, void *aux)
+{
 
-	bt_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
+	switch (cmd) {
+	case MODULE_CMD_INIT:
+		bt_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
+		return 0;
+	case MODULE_CMD_FINI:
+		return EBUSY;	/* XXX */
+	default:
+		return ENOTTY;
+	}
 }

Reply via email to