Module Name: src Committed By: riastradh Date: Mon Aug 7 13:31:54 UTC 2023
Modified Files: src/sys/netbt: bt_proto.c Log Message: 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 XXX pullup-10 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 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.17 --- src/sys/netbt/bt_proto.c:1.16 Thu Jan 21 15:41:30 2016 +++ src/sys/netbt/bt_proto.c Mon Aug 7 13:31:54 2023 @@ -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.17 2023/08/07 13:31:54 riastradh 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.17 2023/08/07 13:31:54 riastradh 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; + } }