Module Name: src
Committed By: pgoyette
Date: Sun Jul 17 05:05:11 UTC 2016
Modified Files:
src/sys/dev/raidframe [pgoyette-localcount]: rf_netbsdkintf.c
src/sys/external/bsd/ipf/netinet [pgoyette-localcount]: ip_fil_netbsd.c
src/sys/net [pgoyette-localcount]: bpf.c
src/sys/netsmb [pgoyette-localcount]: smb_dev.c
Log Message:
Adapt some modular drivers to the localcount(9) world. We're still
not actually using the localcount stuff, but we need to differentiate
between built-in vs loaded drivers and allocate a "struct localcount"
only for loaded drivers.
To generate a diff of this commit:
cvs rdiff -u -r1.345.2.1 -r1.345.2.2 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.16 -r1.16.2.1 \
src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
cvs rdiff -u -r1.199 -r1.199.2.1 src/sys/net/bpf.c
cvs rdiff -u -r1.44 -r1.44.2.1 src/sys/netsmb/smb_dev.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/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.1 src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.2
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.345.2.1 Sun Jul 17 02:44:41 2016
+++ src/sys/dev/raidframe/rf_netbsdkintf.c Sun Jul 17 05:05:10 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $ */
+/* $NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
***********************************************************/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.1 2016/07/17 02:44:41 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.345.2.2 2016/07/17 05:05:10 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -127,6 +127,7 @@ __KERNEL_RCSID(0, "$NetBSD: rf_netbsdkin
#include <sys/reboot.h>
#include <sys/kauth.h>
#include <sys/module.h>
+#include <sys/localcount.h>
#include <prop/proplib.h>
@@ -216,6 +217,10 @@ static dev_type_strategy(raidstrategy);
static dev_type_dump(raiddump);
static dev_type_size(raidsize);
+#ifdef _MODULE
+struct localcount raid_localcount_bdev, raid_localcount_cdev;
+#endif
+
const struct bdevsw raid_bdevsw = {
.d_open = raidopen,
.d_close = raidclose,
@@ -224,6 +229,9 @@ const struct bdevsw raid_bdevsw = {
.d_dump = raiddump,
.d_psize = raidsize,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &raid_localcount_bdev,
+#endif
.d_flag = D_DISK
};
@@ -239,6 +247,9 @@ const struct cdevsw raid_cdevsw = {
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &raid_localcount_bdev,
+#endif
.d_flag = D_DISK
};
Index: src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
diff -u src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.16 src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.16.2.1
--- src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c:1.16 Thu Jul 7 09:32:02 2016
+++ src/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Sun Jul 17 05:05:10 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_fil_netbsd.c,v 1.16 2016/07/07 09:32:02 ozaki-r Exp $ */
+/* $NetBSD: ip_fil_netbsd.c,v 1.16.2.1 2016/07/17 05:05:10 pgoyette 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.16 2016/07/07 09:32:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_fil_netbsd.c,v 1.16.2.1 2016/07/17 05:05:10 pgoyette 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";
@@ -57,6 +57,9 @@ static const char rcsid[] = "@(#)Id: ip_
#include <sys/module.h>
#include <sys/mutex.h>
#endif
+#if (__NetBSD_Version__ >= 799003300)
+#include <sys/localcount.h>
+#endif
#include <net/if.h>
#include <net/route.h>
@@ -137,6 +140,10 @@ static int ipfwrite(dev_t, struct u
static int ipfpoll(dev_t, int events, PROC_T *);
static void ipf_timer_func(void *ptr);
+#if defined(_MODULE) && (__NetBSD_Version__ >= 799003300)
+struct localcount ipl_localcount;
+#endif
+
const struct cdevsw ipl_cdevsw = {
.d_open = ipfopen,
.d_close = ipfclose,
@@ -150,6 +157,10 @@ const struct cdevsw ipl_cdevsw = {
#if (__NetBSD_Version__ >= 200000000)
.d_kqfilter = nokqfilter,
#endif
+#ifdef _MODULE
+ .d_localcount = &ipl_localcount,
+#endif
+
.d_discard = nodiscard,
#ifdef D_OTHER
.d_flag = D_OTHER
@@ -2162,7 +2173,9 @@ static int ipl_init(void *);
static int ipl_fini(void *);
static int ipl_modcmd(modcmd_t, void *);
+#ifdef _MODULE
static devmajor_t ipl_cmaj = -1, ipl_bmaj = -1;
+#endif
static int
ipl_modcmd(modcmd_t cmd, void *opaque)
@@ -2198,6 +2211,7 @@ ipl_init(void *opaque)
mutex_init(&ipf_ref_mutex, MUTEX_DEFAULT, IPL_NONE);
ipf_active = 0;
+#ifdef _MODULE
/*
* Insert ourself into the cdevsw list. It's OK if we are
* already there, since this will happen when our module is
@@ -2209,6 +2223,7 @@ ipl_init(void *opaque)
error = devsw_attach("ipl", NULL, &ipl_bmaj, &ipl_cdevsw, &ipl_cmaj);
if (error == EEXIST)
error = 0;
+#endif
if (error)
ipl_fini(opaque);
@@ -2220,7 +2235,9 @@ static int
ipl_fini(void *opaque)
{
+#ifdef _MODULE
(void)devsw_detach(NULL, &ipl_cdevsw);
+#endif
/*
* Grab the mutex, verify that there are no references
@@ -2230,8 +2247,10 @@ ipl_fini(void *opaque)
*/
mutex_enter(&ipf_ref_mutex);
if (ipf_active != 0 || ipfmain.ipf_running > 0) {
+#ifdef _MODULE
(void)devsw_attach("ipl", NULL, &ipl_bmaj,
&ipl_cdevsw, &ipl_cmaj);
+#endif
mutex_exit(&ipf_ref_mutex);
return EBUSY;
}
Index: src/sys/net/bpf.c
diff -u src/sys/net/bpf.c:1.199 src/sys/net/bpf.c:1.199.2.1
--- src/sys/net/bpf.c:1.199 Mon Jun 20 06:46:37 2016
+++ src/sys/net/bpf.c Sun Jul 17 05:05:10 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf.c,v 1.199 2016/06/20 06:46:37 knakahara Exp $ */
+/* $NetBSD: bpf.c,v 1.199.2.1 2016/07/17 05:05:10 pgoyette Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.199 2016/06/20 06:46:37 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.199.2.1 2016/07/17 05:05:10 pgoyette Exp $");
#if defined(_KERNEL_OPT)
#include "opt_bpf.h"
@@ -61,6 +61,7 @@ __KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.19
#include <sys/module.h>
#include <sys/once.h>
#include <sys/atomic.h>
+#include <sys/localcount.h>
#include <sys/file.h>
#include <sys/filedesc.h>
@@ -180,6 +181,10 @@ static const struct fileops bpf_fileops
dev_type_open(bpfopen);
+#ifdef _MODULE
+struct localcount bpf_localcount;
+#endif
+
const struct cdevsw bpf_cdevsw = {
.d_open = bpfopen,
.d_close = noclose,
@@ -192,6 +197,9 @@ const struct cdevsw bpf_cdevsw = {
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &bpf_localcount,
+#endif
.d_flag = D_OTHER
};
@@ -2112,18 +2120,19 @@ MODULE(MODULE_CLASS_DRIVER, bpf, "bpf_fi
static int
bpf_modcmd(modcmd_t cmd, void *arg)
{
+#ifdef _MODULE
devmajor_t bmajor, cmajor;
- int error;
-
- bmajor = cmajor = NODEVMAJOR;
+#endif
+ int error = 0;
switch (cmd) {
case MODULE_CMD_INIT:
bpfilterattach(0);
+#ifdef _MODULE
+ bmajor = cmajor = NODEVMAJOR;
error = devsw_attach("bpf", NULL, &bmajor,
&bpf_cdevsw, &cmajor);
- if (error == EEXIST)
- error = 0; /* maybe built-in ... improve eventually */
+#endif
if (error)
break;
Index: src/sys/netsmb/smb_dev.c
diff -u src/sys/netsmb/smb_dev.c:1.44 src/sys/netsmb/smb_dev.c:1.44.2.1
--- src/sys/netsmb/smb_dev.c:1.44 Thu Aug 20 14:40:19 2015
+++ src/sys/netsmb/smb_dev.c Sun Jul 17 05:05:10 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: smb_dev.c,v 1.44 2015/08/20 14:40:19 christos Exp $ */
+/* $NetBSD: smb_dev.c,v 1.44.2.1 2016/07/17 05:05:10 pgoyette Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.44 2015/08/20 14:40:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v 1.44.2.1 2016/07/17 05:05:10 pgoyette Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: smb_dev.c,v
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <sys/vnode.h>
+#include <sys/localcount.h>
#include <miscfs/specfs/specdev.h> /* XXX */
@@ -86,6 +87,10 @@ dev_type_open(nsmb_dev_open);
dev_type_close(nsmb_dev_close);
dev_type_ioctl(nsmb_dev_ioctl);
+#ifdef _MODULE
+struct localcount nsmb_localcount;
+#endif
+
const struct cdevsw nsmb_cdevsw = {
.d_open = nsmb_dev_open,
.d_close = nsmb_dev_close,
@@ -98,6 +103,9 @@ const struct cdevsw nsmb_cdevsw = {
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &nsmb_localcount,
+#endif
.d_flag = D_OTHER,
};
@@ -372,25 +380,29 @@ MODULE(MODULE_CLASS_DRIVER, nsmb, NULL);
static int
nsmb_modcmd(modcmd_t cmd, void *arg)
{
+#ifdef _MODULE
devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
+#endif
int error = 0;
switch (cmd) {
case MODULE_CMD_INIT:
nsmbattach(1);
+#ifdef _MODULE
error =
devsw_attach("nsmb", NULL, &bmajor, &nsmb_cdevsw, &cmajor);
- if (error == EEXIST) /* builtin */
- error = 0;
+#endif
if (error) {
nsmbdetach();
}
break;
case MODULE_CMD_FINI:
+#ifdef _MODULE
error = devsw_detach(NULL, &nsmb_cdevsw);
if (error)
break;
+#endif
nsmbdetach();
break;
default: