driver(9): devsw_detach never fails. Make it return void.

Prune a whole lotta dead branches as a result of this.  (Some logic
calling this is also wrong for other reasons; devsw_detach is final
-- you should never have any reason to decide to roll it back.  To be
cleaned up in subsequent commits...)

XXX kernel ABI change to devsw_detach signature requires bump
This commit is contained in:
riastradh 2022-03-28 12:33:20 +00:00
parent 24dda235e4
commit e7bed28911
25 changed files with 85 additions and 127 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dtrace_modevent.c,v 1.6 2018/05/28 21:05:03 chs Exp $ */
/* $NetBSD: dtrace_modevent.c,v 1.7 2022/03/28 12:33:20 riastradh Exp $ */
/*
* CDDL HEADER START
@ -42,9 +42,7 @@ dtrace_modcmd(modcmd_t cmd, void *data)
return error;
case MODULE_CMD_FINI:
error = devsw_detach(NULL, &dtrace_cdevsw);
if (error != 0)
return error;
devsw_detach(NULL, &dtrace_cdevsw);
error = dtrace_unload();
if (error != 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: fbt.c,v 1.27 2019/07/16 07:26:00 hannken Exp $ */
/* $NetBSD: fbt.c,v 1.28 2022/03/28 12:33:20 riastradh Exp $ */
/*
* CDDL HEADER START
@ -1329,7 +1329,8 @@ dtrace_fbt_modcmd(modcmd_t cmd, void *data)
error = fbt_unload();
if (error != 0)
return error;
return devsw_detach(NULL, &fbt_cdevsw);
devsw_detach(NULL, &fbt_cdevsw);
return 0;
case MODULE_CMD_AUTOUNLOAD:
return EBUSY;
default:

View File

@ -39,7 +39,7 @@
* unloaded; in particular, probes may not span multiple kernel modules.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.20 2019/03/09 18:53:52 kamil Exp $");
__KERNEL_RCSID(0, "$NetBSD: sdt.c,v 1.21 2022/03/28 12:33:20 riastradh Exp $");
#include <sys/cdefs.h>
#include <sys/proc.h>
@ -562,7 +562,8 @@ dtrace_sdt_modcmd(modcmd_t cmd, void *data)
error = sdt_unload();
if (error != 0)
return error;
return devsw_detach(NULL, &sdt_cdevsw);
devsw_detach(NULL, &sdt_cdevsw);
return 0;
case MODULE_CMD_AUTOUNLOAD:
return EBUSY;
default:

View File

@ -7231,7 +7231,7 @@ zfs_modcmd(modcmd_t cmd, void *arg)
if (error)
return error;
(void) devsw_detach(&zfs_bdevsw, &zfs_cdevsw);
devsw_detach(&zfs_bdevsw, &zfs_cdevsw);
attacherr:
zfs_sysctl_fini();

View File

@ -1,4 +1,4 @@
.\" $NetBSD: devsw_attach.9,v 1.3 2017/04/30 12:30:00 pgoyette Exp $
.\" $NetBSD: devsw_attach.9,v 1.4 2022/03/28 12:33:20 riastradh Exp $
.\"
.\" Copyright (c) 2015 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd April 30, 2017
.Dd January 11, 2022
.Dt DEVSW 9
.Os
.Sh NAME
@ -49,7 +49,7 @@
.Fa "const struct cdevsw *cdev"
.Fa "devmajor_t *cmajor"
.Fc
.Ft int
.Ft void
.Fo devsw_detach
.Fa "const struct bdevsw *bdev"
.Fa "const struct cdevsw *cdev"
@ -130,6 +130,11 @@ and
structures.
.Fn devsw_detach
should be called before a loaded device driver is unloaded.
The caller must ensure that there are no open instances of the device,
and that the device's
.Fn d_open
function will fail, before calling.
Fn devsw_detach .
.Pp
The
.Fn bdevsw_lookup
@ -155,10 +160,8 @@ or
.Sh RETURN VALUES
Upon successful completion,
.Fn devsw_attach
and
.Fn devsw_detach
return 0.
Otherwise they return an error value.
returns 0.
Otherwise it returns an error value.
.Pp
In case of failure,
.Fn bdevsw_lookup

View File

@ -1,4 +1,4 @@
/* $NetBSD: coda_psdev.c,v 1.60 2021/09/26 01:16:08 thorpej Exp $ */
/* $NetBSD: coda_psdev.c,v 1.61 2022/03/28 12:33:20 riastradh Exp $ */
/*
*
@ -54,7 +54,7 @@
/* These routines are the device entry points for Venus. */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: coda_psdev.c,v 1.60 2021/09/26 01:16:08 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: coda_psdev.c,v 1.61 2022/03/28 12:33:20 riastradh Exp $");
extern int coda_nc_initialized; /* Set if cache has been initialized */
@ -758,7 +758,7 @@ vcoda_modcmd(modcmd_t cmd, void *arg)
if (VC_OPEN(vcp))
return EBUSY;
}
return devsw_detach(NULL, &vcoda_cdevsw);
devsw_detach(NULL, &vcoda_cdevsw);
}
#endif
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ccd.c,v 1.187 2022/03/12 17:27:50 riastradh Exp $ */
/* $NetBSD: ccd.c,v 1.188 2022/03/28 12:33:20 riastradh Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah $Hdr: cd.c 1.6 90/11/28$
* from: Utah $Hdr$
*
* @(#)cd.c 8.2 (Berkeley) 11/16/93
*/
@ -88,7 +88,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.187 2022/03/12 17:27:50 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.188 2022/03/28 12:33:20 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1710,7 +1710,7 @@ ccd_modcmd(modcmd_t cmd, void *arg)
error = EBUSY;
} else {
mutex_exit(&ccd_lock);
error = devsw_detach(&ccd_bdevsw, &ccd_cdevsw);
devsw_detach(&ccd_bdevsw, &ccd_cdevsw);
ccddetach();
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: clockctl.c,v 1.38 2020/02/21 00:26:22 joerg Exp $ */
/* $NetBSD: clockctl.c,v 1.39 2022/03/28 12:33:20 riastradh Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.38 2020/02/21 00:26:22 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.39 2022/03/28 12:33:20 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ntp.h"
@ -182,14 +182,12 @@ clockctl_modcmd(modcmd_t cmd, void *data)
return EBUSY;
}
#ifdef _MODULE
error = devsw_detach(NULL, &clockctl_cdevsw);
devsw_detach(NULL, &clockctl_cdevsw);
#endif
mutex_exit(&clockctl_mtx);
if (error == 0) {
kauth_unlisten_scope(clockctl_listener);
mutex_destroy(&clockctl_mtx);
}
kauth_unlisten_scope(clockctl_listener);
mutex_destroy(&clockctl_mtx);
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: hdaudio.c,v 1.16 2021/08/07 16:19:11 thorpej Exp $ */
/* $NetBSD: hdaudio.c,v 1.17 2022/03/28 12:33:21 riastradh Exp $ */
/*
* Copyright (c) 2009 Precedence Technologies Ltd <support@precedence.co.uk>
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.16 2021/08/07 16:19:11 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.17 2022/03/28 12:33:21 riastradh Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -1636,11 +1636,7 @@ hdaudio_modcmd(modcmd_t cmd, void *opaque)
error = config_cfdriver_detach(&hdaudio_cd);
if (error)
break;
error = devsw_detach(NULL, &hdaudio_cdevsw);
if (error) {
config_cfdriver_attach(&hdaudio_cd);
break;
}
devsw_detach(NULL, &hdaudio_cdevsw);
#endif
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: i2c.c,v 1.84 2022/01/24 09:42:14 andvar Exp $ */
/* $NetBSD: i2c.c,v 1.85 2022/03/28 12:33:21 riastradh Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -53,7 +53,7 @@
#endif /* _KERNEL_OPT */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.84 2022/01/24 09:42:14 andvar Exp $");
__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.85 2022/03/28 12:33:21 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -942,7 +942,7 @@ iic_modcmd(modcmd_t cmd, void *opaque)
if (error) {
aprint_error("%s: unable to init component\n",
iic_cd.cd_name);
(void)devsw_detach(NULL, &iic_cdevsw);
devsw_detach(NULL, &iic_cdevsw);
}
mutex_exit(&iic_mtx);
#endif
@ -960,10 +960,7 @@ iic_modcmd(modcmd_t cmd, void *opaque)
mutex_exit(&iic_mtx);
break;
}
error = devsw_detach(NULL, &iic_cdevsw);
if (error != 0)
config_init_component(cfdriver_ioconf_iic,
cfattach_ioconf_iic, cfdata_ioconf_iic);
devsw_detach(NULL, &iic_cdevsw);
#endif
mutex_exit(&iic_mtx);
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pad.c,v 1.76 2022/03/12 17:07:10 riastradh Exp $ */
/* $NetBSD: pad.c,v 1.77 2022/03/28 12:33:21 riastradh Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.76 2022/03/12 17:07:10 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: pad.c,v 1.77 2022/03/28 12:33:21 riastradh Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -777,9 +777,7 @@ pad_modcmd(modcmd_t cmd, void *arg)
case MODULE_CMD_FINI:
#ifdef _MODULE
error = devsw_detach(NULL, &pad_cdevsw);
if (error)
break;
devsw_detach(NULL, &pad_cdevsw);
error = config_fini_component(cfdriver_ioconf_pad,
pad_cfattach, cfdata_ioconf_pad);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rf_netbsdkintf.c,v 1.403 2022/03/11 01:59:33 mrg Exp $ */
/* $NetBSD: rf_netbsdkintf.c,v 1.404 2022/03/28 12:33:21 riastradh Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: Utah $Hdr: cd.c 1.6 90/11/28$
* from: Utah $Hdr$
*
* @(#)cd.c 8.2 (Berkeley) 11/16/93
*/
@ -101,7 +101,7 @@
***********************************************************/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.403 2022/03/11 01:59:33 mrg Exp $");
__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.404 2022/03/28 12:33:21 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_raid_autoconfig.h"
@ -4082,16 +4082,7 @@ raid_modcmd_fini(void)
return error;
}
#endif
error = devsw_detach(&raid_bdevsw, &raid_cdevsw);
if (error != 0) {
aprint_error("%s: cannot detach devsw\n",__func__);
#ifdef _MODULE
config_cfdriver_attach(&raid_cd);
#endif
config_cfattach_attach(raid_cd.cd_name, &raid_ca);
mutex_exit(&raid_lock);
return error;
}
devsw_detach(&raid_bdevsw, &raid_cdevsw);
rf_BootRaidframe(false);
#if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
rf_destroy_mutex2(rf_sparet_wait_mutex);

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysmon.c,v 1.31 2021/12/31 11:05:41 riastradh Exp $ */
/* $NetBSD: sysmon.c,v 1.32 2022/03/28 12:33:21 riastradh Exp $ */
/*-
* Copyright (c) 2000 Zembu Labs, Inc.
@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.31 2021/12/31 11:05:41 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysmon.c,v 1.32 2022/03/28 12:33:21 riastradh Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -356,7 +356,7 @@ sysmon_fini(void)
if (error == 0) {
mutex_enter(&sysmon_minor_mtx);
sm_is_attached = false;
error = devsw_detach(NULL, &sysmon_cdevsw);
devsw_detach(NULL, &sysmon_cdevsw);
mutex_exit(&sysmon_minor_mtx);
}
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: tprof.c,v 1.16 2021/11/01 17:03:53 skrll Exp $ */
/* $NetBSD: tprof.c,v 1.17 2022/03/28 12:33:21 riastradh Exp $ */
/*-
* Copyright (c)2008,2009,2010 YAMAMOTO Takashi,
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.16 2021/11/01 17:03:53 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: tprof.c,v 1.17 2022/03/28 12:33:21 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -768,13 +768,7 @@ tprof_modcmd(modcmd_t cmd, void *arg)
case MODULE_CMD_FINI:
#if defined(_MODULE)
{
int error;
error = devsw_detach(NULL, &tprof_cdevsw);
if (error) {
return error;
}
}
devsw_detach(NULL, &tprof_cdevsw);
#endif /* defined(_MODULE) */
tprof_driver_fini();
return 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: pf_ioctl.c,v 1.57 2020/02/21 00:26:22 joerg Exp $ */
/* $NetBSD: pf_ioctl.c,v 1.58 2022/03/28 12:33:21 riastradh Exp $ */
/* $OpenBSD: pf_ioctl.c,v 1.182 2007/06/24 11:17:13 mcbride Exp $ */
/*
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v 1.57 2020/02/21 00:26:22 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: pf_ioctl.c,v 1.58 2022/03/28 12:33:21 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -3459,7 +3459,8 @@ pf_modcmd(modcmd_t cmd, void *opaque)
} else {
pfdetach();
pflogdetach();
return devsw_detach(NULL, &pf_cdevsw);
devsw_detach(NULL, &pf_cdevsw);
return 0;
}
default:
return ENOTTY;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ip_fil_netbsd.c,v 1.36 2021/03/08 23:34:58 christos Exp $ */
/* $NetBSD: ip_fil_netbsd.c,v 1.37 2022/03/28 12:33:21 riastradh Exp $ */
/*
* Copyright (C) 2012 by Darren Reed.
@ -8,7 +8,7 @@
#if !defined(lint)
#if defined(__NetBSD__)
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.36 2021/03/08 23:34:58 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.37 2022/03/28 12:33:21 riastradh Exp $");
#else
static const char sccsid[] = "@(#)ip_fil.c 2.41 6/5/96 (C) 1993-2000 Darren Reed";
static const char rcsid[] = "@(#)Id: ip_fil_netbsd.c,v 1.1.1.2 2012/07/22 13:45:17 darrenr Exp";
@ -2256,7 +2256,7 @@ ipl_fini(void *opaque)
{
#ifdef _MODULE
(void)devsw_detach(NULL, &ipl_cdevsw);
devsw_detach(NULL, &ipl_cdevsw);
#endif
/*

View File

@ -33,7 +33,7 @@
*
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.11 2020/04/26 17:00:31 tkusumi Exp $");
__KERNEL_RCSID(0, "$NetBSD: autofs_vfsops.c,v 1.12 2022/03/28 12:33:22 riastradh Exp $");
#include "autofs.h"
@ -496,9 +496,7 @@ autofs_modcmd(modcmd_t cmd, void *arg)
}
mutex_exit(&autofs_softc->sc_lock);
error = devsw_detach(NULL, &autofs_cdevsw);
if (error)
break;
devsw_detach(NULL, &autofs_cdevsw);
#endif
error = vfs_detach(&autofs_vfsops);
if (error)

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_drvctl.c,v 1.50 2022/02/12 03:24:36 riastradh Exp $ */
/* $NetBSD: kern_drvctl.c,v 1.51 2022/03/28 12:33:22 riastradh Exp $ */
/*
* Copyright (c) 2004
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.50 2022/02/12 03:24:36 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_drvctl.c,v 1.51 2022/03/28 12:33:22 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -666,15 +666,10 @@ drvctl_modcmd(modcmd_t cmd, void *arg)
devmon_insert_vec = saved_insert_vec;
saved_insert_vec = NULL;
#ifdef _MODULE
error = devsw_detach(NULL, &drvctl_cdevsw);
if (error != 0) {
saved_insert_vec = devmon_insert_vec;
devmon_insert_vec = devmon_insert;
}
devsw_detach(NULL, &drvctl_cdevsw);
#endif
mutex_exit(&drvctl_lock);
if (error == 0)
drvctl_fini();
drvctl_fini();
break;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: subr_devsw.c,v 1.38 2017/11/07 18:35:57 christos Exp $ */
/* $NetBSD: subr_devsw.c,v 1.39 2022/03/28 12:33:22 riastradh Exp $ */
/*-
* Copyright (c) 2001, 2002, 2007, 2008 The NetBSD Foundation, Inc.
@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.38 2017/11/07 18:35:57 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_devsw.c,v 1.39 2022/03/28 12:33:22 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_dtrace.h"
@ -343,14 +343,13 @@ devsw_detach_locked(const struct bdevsw *bdev, const struct cdevsw *cdev)
}
}
int
void
devsw_detach(const struct bdevsw *bdev, const struct cdevsw *cdev)
{
mutex_enter(&device_lock);
devsw_detach_locked(bdev, cdev);
mutex_exit(&device_lock);
return 0;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: pollpal.c,v 1.3 2020/05/01 21:42:34 christos Exp $ */
/* $NetBSD: pollpal.c,v 1.4 2022/03/28 12:33:22 riastradh Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: pollpal.c,v 1.3 2020/05/01 21:42:34 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: pollpal.c,v 1.4 2022/03/28 12:33:22 riastradh Exp $");
#include <sys/module.h>
#include <sys/param.h>
@ -311,7 +311,8 @@ pollpal_modcmd(modcmd_t cmd, void *arg __unused)
case MODULE_CMD_FINI:
if (pollpal_nopen != 0)
return EBUSY;
return devsw_detach(NULL, &pollpal_cdevsw);
devsw_detach(NULL, &pollpal_cdevsw);
return 0;
default:
return ENOTTY;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tap.c,v 1.124 2021/09/26 15:58:33 thorpej Exp $ */
/* $NetBSD: if_tap.c,v 1.125 2022/03/28 12:33:22 riastradh Exp $ */
/*
* Copyright (c) 2003, 2004, 2008, 2009 The NetBSD Foundation.
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.124 2021/09/26 15:58:33 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.125 2022/03/28 12:33:22 riastradh Exp $");
#if defined(_KERNEL_OPT)
@ -256,9 +256,7 @@ tapdetach(void)
if_clone_detach(&tap_cloners);
#ifdef _MODULE
error = devsw_detach(NULL, &tap_cdevsw);
if (error != 0)
goto out2;
devsw_detach(NULL, &tap_cdevsw);
#endif
if (tap_count != 0) {
@ -277,7 +275,6 @@ tapdetach(void)
out1:
#ifdef _MODULE
devsw_attach("tap", NULL, &tap_bmajor, &tap_cdevsw, &tap_cmajor);
out2:
#endif
if_clone_attach(&tap_cloners);

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_tun.c,v 1.172 2022/03/15 00:05:17 riastradh Exp $ */
/* $NetBSD: if_tun.c,v 1.173 2022/03/28 12:33:22 riastradh Exp $ */
/*
* Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk>
@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.172 2022/03/15 00:05:17 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_tun.c,v 1.173 2022/03/28 12:33:22 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -142,17 +142,10 @@ tuninit(void)
static int
tundetach(void)
{
#ifdef _MODULE
int error;
#endif
if_clone_detach(&tun_cloner);
#ifdef _MODULE
error = devsw_detach(NULL, &tun_cdevsw);
if (error != 0) {
if_clone_attach(&tun_cloner);
return error;
}
devsw_detach(NULL, &tun_cdevsw);
#endif
if (!LIST_EMPTY(&tun_softc_list) || !LIST_EMPTY(&tunz_softc_list)) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: bpf_component.c,v 1.3 2016/07/19 02:47:45 pgoyette Exp $ */
/* $NetBSD: bpf_component.c,v 1.4 2022/03/28 12:33:22 riastradh Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bpf_component.c,v 1.3 2016/07/19 02:47:45 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: bpf_component.c,v 1.4 2022/03/28 12:33:22 riastradh Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -50,6 +50,5 @@ RUMP_COMPONENT(RUMP_COMPONENT_NET)
panic("bpf devsw attach failed: %d", error);
if ((error = rump_vfs_makeonedevnode(S_IFCHR, "/dev/bpf", cmaj, 0)) !=0)
panic("cannot create bpf device nodes: %d", error);
if ((error = devsw_detach(NULL, &bpf_cdevsw)) != 0)
panic("cannot detach bpf devsw: %d", error);
devsw_detach(NULL, &bpf_cdevsw);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: drvctl_component.c,v 1.4 2017/01/15 01:48:05 pgoyette Exp $ */
/* $NetBSD: drvctl_component.c,v 1.5 2022/03/28 12:33:22 riastradh Exp $ */
/*
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drvctl_component.c,v 1.4 2017/01/15 01:48:05 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: drvctl_component.c,v 1.5 2022/03/28 12:33:22 riastradh Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -51,7 +51,5 @@ RUMP_COMPONENT(RUMP_COMPONENT_DEV)
if ( error !=0)
panic("cannot create drvctl device node: %d", error);
error = devsw_detach(NULL, &drvctl_cdevsw);
if (error != 0)
panic("cannot detach drvctl devsw: %d", error);
devsw_detach(NULL, &drvctl_cdevsw);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.h,v 1.154 2019/10/08 12:49:56 uwe Exp $ */
/* $NetBSD: conf.h,v 1.155 2022/03/28 12:33:22 riastradh Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -104,7 +104,7 @@ extern kmutex_t device_lock;
int devsw_attach(const char *, const struct bdevsw *, devmajor_t *,
const struct cdevsw *, devmajor_t *);
int devsw_detach(const struct bdevsw *, const struct cdevsw *);
void devsw_detach(const struct bdevsw *, const struct cdevsw *);
const struct bdevsw *bdevsw_lookup(dev_t);
const struct cdevsw *cdevsw_lookup(dev_t);
devmajor_t bdevsw_lookup_major(const struct bdevsw *);