Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/gehenna-devsw]: src/sys/net Add the character device switch.
details: https://anonhg.NetBSD.org/src/rev/b6d3da296432
branches: gehenna-devsw
changeset: 527035:b6d3da296432
user: gehenna <gehenna%NetBSD.org@localhost>
date: Thu May 16 03:58:47 2002 +0000
description:
Add the character device switch.
Replace the direct-access to devsw table with calling devsw APIs.
diffstat:
sys/net/bpf.c | 21 +++++++++++++++------
sys/net/ppp_tty.c | 16 +++++++++++-----
2 files changed, 26 insertions(+), 11 deletions(-)
diffs (113 lines):
diff -r 7c1b930243f6 -r b6d3da296432 sys/net/bpf.c
--- a/sys/net/bpf.c Thu May 16 03:54:50 2002 +0000
+++ b/sys/net/bpf.c Thu May 16 03:58:47 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bpf.c,v 1.64 2002/03/23 15:55:21 darrenr Exp $ */
+/* $NetBSD: bpf.c,v 1.64.2.1 2002/05/16 03:58:47 gehenna Exp $ */
/*
* Copyright (c) 1990, 1991, 1993
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.64 2002/03/23 15:55:21 darrenr Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bpf.c,v 1.64.2.1 2002/05/16 03:58:47 gehenna Exp $");
#include "bpfilter.h"
@@ -107,13 +107,24 @@
static void bpf_attachd __P((struct bpf_d *, struct bpf_if *));
static void bpf_detachd __P((struct bpf_d *));
static int bpf_setif __P((struct bpf_d *, struct ifreq *));
-int bpfpoll __P((dev_t, int, struct proc *));
static __inline void
bpf_wakeup __P((struct bpf_d *));
static void catchpacket __P((struct bpf_d *, u_char *, u_int, u_int,
void *(*)(void *, const void *, size_t)));
static void reset_d __P((struct bpf_d *));
+dev_type_open(bpfopen);
+dev_type_close(bpfclose);
+dev_type_read(bpfread);
+dev_type_write(bpfwrite);
+dev_type_ioctl(bpfioctl);
+dev_type_poll(bpfpoll);
+
+const struct cdevsw bpf_cdevsw = {
+ bpfopen, bpfclose, bpfread, bpfwrite, bpfioctl,
+ nostop, notty, bpfpoll, nommap,
+};
+
static int
bpf_movein(uio, linktype, mtu, mp, sockp)
struct uio *uio;
@@ -1263,9 +1274,7 @@
int i, s, cmaj;
/* locate the major number */
- for (cmaj = 0; cmaj <= nchrdev; cmaj++)
- if (cdevsw[cmaj].d_open == bpfopen)
- break;
+ cmaj = cdevsw_lookup_major(&bpf_cdevsw);
/* Nuke the vnodes for any open instances */
for (i = 0; i < NBPFILTER; ++i) {
diff -r 7c1b930243f6 -r b6d3da296432 sys/net/ppp_tty.c
--- a/sys/net/ppp_tty.c Thu May 16 03:54:50 2002 +0000
+++ b/sys/net/ppp_tty.c Thu May 16 03:58:47 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ppp_tty.c,v 1.30 2002/03/17 19:41:11 atatat Exp $ */
+/* $NetBSD: ppp_tty.c,v 1.30.4.1 2002/05/16 03:58:47 gehenna Exp $ */
/* Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp */
/*
@@ -77,7 +77,7 @@
/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.30 2002/03/17 19:41:11 atatat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.30.4.1 2002/05/16 03:58:47 gehenna Exp $");
#include "ppp.h"
@@ -635,6 +635,7 @@
{
struct tty *tp = (struct tty *) sc->sc_devp;
struct mbuf *m, *n;
+ const struct cdevsw *cdev;
int len;
for(m = sc->sc_outm;;) {
@@ -649,8 +650,10 @@
len += n->m_len;
/* call device driver IOCTL to transmit a frame */
- if ((*cdevsw[major(tp->t_dev)].d_ioctl)
- (tp->t_dev, TIOCXMTFRAME, (caddr_t)&m, 0, 0)) {
+ cdev = cdevsw_lookup(tp->t_dev);
+ if (cdev == NULL ||
+ (*cdev->d_ioctl)(tp->t_dev, TIOCXMTFRAME, (caddr_t)&m,
+ 0, 0)) {
/* busy or error, set as current packet */
sc->sc_outm = m;
break;
@@ -968,6 +971,7 @@
{
struct ppp_softc *sc;
struct mbuf *m;
+ const struct cdevsw *cdev;
int ilen, s;
sc = (struct ppp_softc *) tp->t_sc;
@@ -993,7 +997,9 @@
if (c == tp->t_cc[VSTOP] && tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
if ((tp->t_state & TS_TTSTOP) == 0) {
tp->t_state |= TS_TTSTOP;
- (*cdevsw[major(tp->t_dev)].d_stop)(tp, 0);
+ cdev = cdevsw_lookup(tp->t_dev);
+ if (cdev != NULL)
+ (*cdev->d_stop)(tp, 0);
}
return 0;
}
Home |
Main Index |
Thread Index |
Old Index