Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-localcount]: src/sys Adapt some modular drivers to the localcou...
details: https://anonhg.NetBSD.org/src/rev/ff8c47150d29
branches: pgoyette-localcount
changeset: 852802:ff8c47150d29
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Jul 17 05:05:10 2016 +0000
description:
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.
diffstat:
sys/dev/raidframe/rf_netbsdkintf.c | 15 +++++++++++++--
sys/external/bsd/ipf/netinet/ip_fil_netbsd.c | 23 +++++++++++++++++++++--
sys/net/bpf.c | 23 ++++++++++++++++-------
sys/netsmb/smb_dev.c | 20 ++++++++++++++++----
4 files changed, 66 insertions(+), 15 deletions(-)
diffs (truncated from 305 to 300 lines):
diff -r b7044e1a5d0c -r ff8c47150d29 sys/dev/raidframe/rf_netbsdkintf.c
--- a/sys/dev/raidframe/rf_netbsdkintf.c Sun Jul 17 05:02:19 2016 +0000
+++ b/sys/dev/raidframe/rf_netbsdkintf.c Sun Jul 17 05:05:10 2016 +0000
@@ -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 @@
#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_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 @@
.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 @@
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &raid_localcount_bdev,
+#endif
.d_flag = D_DISK
};
diff -r b7044e1a5d0c -r ff8c47150d29 sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
--- a/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Sun Jul 17 05:02:19 2016 +0000
+++ b/sys/external/bsd/ipf/netinet/ip_fil_netbsd.c Sun Jul 17 05:05:10 2016 +0000
@@ -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 @@
#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 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 @@
#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_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 @@
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 @@
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 @@
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 @@
*/
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;
}
diff -r b7044e1a5d0c -r ff8c47150d29 sys/net/bpf.c
--- a/sys/net/bpf.c Sun Jul 17 05:02:19 2016 +0000
+++ b/sys/net/bpf.c Sun Jul 17 05:05:10 2016 +0000
@@ -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 @@
#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 @@
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 @@
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &bpf_localcount,
+#endif
.d_flag = D_OTHER
};
@@ -2112,18 +2120,19 @@
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;
diff -r b7044e1a5d0c -r ff8c47150d29 sys/netsmb/smb_dev.c
--- a/sys/netsmb/smb_dev.c Sun Jul 17 05:02:19 2016 +0000
+++ b/sys/netsmb/smb_dev.c Sun Jul 17 05:05:10 2016 +0000
@@ -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 @@
#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_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 @@
.d_mmap = nommap,
.d_kqfilter = nokqfilter,
.d_discard = nodiscard,
+#ifdef _MODULE
+ .d_localcount = &nsmb_localcount,
+#endif
.d_flag = D_OTHER,
};
@@ -372,25 +380,29 @@
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)
Home |
Main Index |
Thread Index |
Old Index