From 99fe3072b97fc2476eb0fca229e2f8708b2ffff6 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Mon, 29 Aug 2022 17:46:49 +0000 Subject: [PATCH] WIP: 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. --- sys/netbt/bt_proto.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sys/netbt/bt_proto.c b/sys/netbt/bt_proto.c index 15e2c99d7411..d2ab7ee45161 100644 --- a/sys/netbt/bt_proto.c +++ b/sys/netbt/bt_proto.c @@ -36,6 +36,7 @@ __KERNEL_RCSID(0, "$NetBSD: bt_proto.c,v 1.16 2016/01/21 15:41:30 riastradh Exp #include #include #include +#include #include #include #include @@ -112,7 +113,22 @@ 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; + } }