Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Add devsw_{attach, detach} stuff for _MODULE variant....
details: https://anonhg.NetBSD.org/src/rev/201b567ace53
branches: trunk
changeset: 449835:201b567ace53
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Tue Mar 26 00:23:32 2019 +0000
description:
Add devsw_{attach,detach} stuff for _MODULE variant. (Not needed for
built-in variant since the devsw is also built-in.) This will allow
the modular srt devices to be accessed via open(2) and ioctl(2).
XXX Someone(tm) needs to update MAKEDEV to create the /dev/srtN device
nodes (with device-major 179)!
diffstat:
sys/net/if_srt.c | 62 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 42 insertions(+), 20 deletions(-)
diffs (106 lines):
diff -r 5d163be33a42 -r 201b567ace53 sys/net/if_srt.c
--- a/sys/net/if_srt.c Mon Mar 25 23:43:56 2019 +0000
+++ b/sys/net/if_srt.c Tue Mar 26 00:23:32 2019 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: if_srt.c,v 1.27 2017/10/23 09:32:55 msaitoh Exp $ */
+/* $NetBSD: if_srt.c,v 1.28 2019/03/26 00:23:32 pgoyette Exp $ */
/* This file is in the public domain. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.27 2017/10/23 09:32:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_srt.c,v 1.28 2019/03/26 00:23:32 pgoyette Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -64,6 +64,29 @@
static u_int srt_count;
+#ifdef _MODULE
+devmajor_t srt_bmajor = -1, srt_cmajor = -1;
+#endif
+
+static int srt_open(dev_t, int, int, struct lwp *);
+static int srt_close(dev_t, int, int, struct lwp *);
+static int srt_ioctl(dev_t, u_long, void *, int, struct lwp *);
+
+const struct cdevsw srt_cdevsw = {
+ .d_open = srt_open,
+ .d_close = srt_close,
+ .d_read = nullread,
+ .d_write = nullwrite,
+ .d_ioctl = srt_ioctl,
+ .d_stop = nullstop,
+ .d_tty = notty,
+ .d_poll = nullpoll,
+ .d_mmap = nommap,
+ .d_kqfilter = nullkqfilter,
+ .d_discard = nodiscard,
+ .d_flag = D_OTHER
+};
+
/* Internal routines. */
static unsigned int ipv4_masks[33] = {
@@ -332,6 +355,9 @@
softcv[i] = 0;
global_flags = 0;
if_clone_attach(&srt_clone);
+#ifdef _MODULE
+ devsw_attach("srt", NULL, &srt_bmajor, &srt_cdevsw, &srt_cmajor);
+#endif
}
static int
@@ -340,15 +366,26 @@
int error = 0;
int i;
+ if_clone_detach(&srt_clone);
+#ifdef _MODULE
+ devsw_detach(NULL, &srt_cdevsw);
+ if (error != 0) {
+ if_clone_attach(&srt_clone);
+ return error;
+ }
+#endif
+
for (i = SRT_MAXUNIT; i >= 0; i--)
if(softcv[i]) {
error = EBUSY;
+#ifdef _MODULE
+ devsw_attach("srt", NULL, &srt_bmajor,
+ &srt_cdevsw, &srt_cmajor);
+#endif
+ if_clone_attach(&srt_clone);
break;
}
- if (error == 0)
- if_clone_detach(&srt_clone);
-
return error;
}
@@ -533,21 +570,6 @@
return ENOTTY;
}
-const struct cdevsw srt_cdevsw = {
- .d_open = srt_open,
- .d_close = srt_close,
- .d_read = nullread,
- .d_write = nullwrite,
- .d_ioctl = srt_ioctl,
- .d_stop = nullstop,
- .d_tty = notty,
- .d_poll = nullpoll,
- .d_mmap = nommap,
- .d_kqfilter = nullkqfilter,
- .d_discard = nodiscard,
- .d_flag = D_OTHER
-};
-
/*
* Module infrastructure
*/
Home |
Main Index |
Thread Index |
Old Index