summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2001-01-31 07:58:58 +0000
committerpeter <peter@FreeBSD.org>2001-01-31 07:58:58 +0000
commit6be84866ea66a3d9041f0400dda21d05913d219d (patch)
tree126edfdf3ed82891788fa9edc2df5bada88d2592
parent2c2377c37d343b47ad9d996ea324576e1977647d (diff)
downloadFreeBSD-src-6be84866ea66a3d9041f0400dda21d05913d219d.zip
FreeBSD-src-6be84866ea66a3d9041f0400dda21d05913d219d.tar.gz
Exterminate the use of PSEUDO_SET() with extreme prejudice.
-rw-r--r--sys/dev/fb/fb.c32
-rw-r--r--sys/net/if_disc.c29
-rw-r--r--sys/net/if_loop.c40
-rw-r--r--sys/net/if_ppp.c31
-rw-r--r--sys/net/if_sl.c45
-rw-r--r--sys/net/if_tun.c34
-rw-r--r--sys/net/if_vlan.c29
7 files changed, 176 insertions, 64 deletions
diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c
index 0c354c1..c729e0f 100644
--- a/sys/dev/fb/fb.c
+++ b/sys/dev/fb/fb.c
@@ -36,6 +36,7 @@
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/uio.h>
#include <sys/fbio.h>
@@ -374,18 +375,29 @@ static struct cdevsw fb_cdevsw = {
/* bmaj */ -1
};
-static void
-vfbattach(void *arg)
-{
- static int fb_devsw_installed = FALSE;
- if (!fb_devsw_installed) {
- cdevsw_add(&fb_cdevsw);
- fb_devsw_installed = TRUE;
- }
-}
+static int
+fb_modevent(module_t mod, int type, void *data)
+{
-PSEUDO_SET(vfbattach, fb);
+ switch (type) {
+ case MOD_LOAD:
+ cdevsw_add(&fb_cdevsw);
+ break;
+ case MOD_UNLOAD:
+ printf("fb module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t fb_mod = {
+ "fb",
+ fb_modevent,
+ NULL
+};
+
+DECLARE_MODULE(fb, fb_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
int
fb_attach(dev_t dev, video_adapter_t *adp, struct cdevsw *cdevsw)
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 66bd5f8..7573112 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -42,6 +42,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/module.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/sockio.h>
@@ -60,8 +61,7 @@
#define DSMTU 65532
#endif
-static void discattach __P((void *dummy));
-PSEUDO_SET(discattach, if_disc);
+static void discattach __P((void));
static struct ifnet discif;
static int discoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
@@ -71,8 +71,7 @@ static int discioctl(struct ifnet *, u_long, caddr_t);
/* ARGSUSED */
static void
-discattach(dummy)
- void *dummy;
+discattach()
{
register struct ifnet *ifp = &discif;
@@ -90,6 +89,28 @@ discattach(dummy)
}
static int
+disc_modevent(module_t mod, int type, void *data)
+{
+ switch (type) {
+ case MOD_LOAD:
+ discattach();
+ break;
+ case MOD_UNLOAD:
+ printf("if_disc module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t disc_mod = {
+ "if_disc",
+ disc_modevent,
+ NULL
+};
+
+DECLARE_MODULE(if_disc, disc_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+
+static int
discoutput(ifp, m, dst, rt)
struct ifnet *ifp;
register struct mbuf *m;
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 105b8dd..3c75a34 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -48,6 +48,7 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
+#include <sys/module.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <sys/sysctl.h>
@@ -89,9 +90,6 @@
int loioctl __P((struct ifnet *, u_long, caddr_t));
static void lortrequest __P((int, struct rtentry *, struct sockaddr *));
-static void loopattach __P((void *));
-PSEUDO_SET(loopattach, if_loop);
-
int looutput __P((struct ifnet *ifp,
struct mbuf *m, struct sockaddr *dst, struct rtentry *rt));
@@ -174,19 +172,33 @@ sysctl_net_nloop(SYSCTL_HANDLER_ARGS)
SYSCTL_PROC(_net, OID_AUTO, nloop, CTLTYPE_INT | CTLFLAG_RW,
0, 0, sysctl_net_nloop, "I", "");
-/* ARGSUSED */
-static void
-loopattach(dummy)
- void *dummy;
-{
+static int
+loop_modevent(module_t mod, int type, void *data)
+{
int i;
- TUNABLE_INT_FETCH("net.nloop", 1, nloop);
- if (nloop < 1) /* sanity check */
- nloop = 1;
- for (i = 0; i < nloop; i++)
- locreate(i);
-}
+ switch (type) {
+ case MOD_LOAD:
+ TUNABLE_INT_FETCH("net.nloop", 1, nloop);
+ if (nloop < 1) /* sanity check */
+ nloop = 1;
+ for (i = 0; i < nloop; i++)
+ locreate(i);
+ break;
+ case MOD_UNLOAD:
+ printf("loop module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t loop_mod = {
+ "loop",
+ loop_modevent,
+ 0
+};
+
+DECLARE_MODULE(loop, loop_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
int
looutput(ifp, m, dst, rt)
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index c5eb10c..0f7ba81 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -94,6 +94,7 @@
#include <sys/kernel.h>
#include <sys/time.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -134,9 +135,6 @@ struct ppp_softc ppp_softc[NPPP];
/* XXX layering violation */
extern void pppasyncattach __P((void *));
-static void pppattach __P((void *));
-PSEUDO_SET(pppattach, if_ppp);
-
static int pppsioctl __P((struct ifnet *ifp, u_long cmd, caddr_t data));
static void pppintr __P((void));
@@ -192,8 +190,7 @@ static struct compressor *ppp_compressors[8] = {
* Called from boot code to establish ppp interfaces.
*/
static void
-pppattach(dummy)
- void *dummy;
+pppattach(void)
{
register struct ppp_softc *sc;
register int i = 0;
@@ -222,9 +219,31 @@ pppattach(dummy)
* XXX layering violation - if_ppp can work over any lower level
* transport that cares to attach to it.
*/
- pppasyncattach(dummy);
+ pppasyncattach(NULL);
}
+static int
+ppp_modevent(module_t mod, int type, void *data)
+{
+ switch (type) {
+ case MOD_LOAD:
+ pppattach();
+ break;
+ case MOD_UNLOAD:
+ printf("if_ppp module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t ppp_mod = {
+ "if_ppp",
+ ppp_modevent,
+ 0
+};
+
+DECLARE_MODULE(if_ppp, ppp_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+
/*
* Allocate a ppp interface unit and initialize it.
*/
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index d3f8085..8871bfd 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -81,6 +81,7 @@
#include <sys/clist.h>
#include <sys/kernel.h>
#include <sys/conf.h>
+#include <sys/module.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -103,9 +104,6 @@
static MALLOC_DEFINE(M_SL, "sl", "SLIP Interface");
-static void slattach __P((void *));
-PSEUDO_SET(slattach, if_sl);
-
/*
* SLRMAX is a hard limit on input packet size. To simplify the code
* and improve performance, we require that packets fit in an mbuf
@@ -198,20 +196,34 @@ static struct linesw slipdisc = {
/*
* Called from boot code to establish sl interfaces.
*/
-static void
-slattach(dummy)
- void *dummy;
-{
- linesw[SLIPDISC] = slipdisc;
-
- LIST_INIT(&sl_list);
-}
+static int
+sl_modevent(module_t mod, int type, void *data)
+{
+ switch (type) {
+ case MOD_LOAD:
+ linesw[SLIPDISC] = slipdisc;
+ LIST_INIT(&sl_list);
+ break;
+ case MOD_UNLOAD:
+ printf("if_sl module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t sl_mod = {
+ "if_sl",
+ sl_modevent,
+ 0
+};
+
+DECLARE_MODULE(if_sl, sl_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
static int *st_unit_list;
static size_t st_unit_max = 0;
-static
-int slisstatic(unit)
+static int
+slisstatic(unit)
int unit;
{
size_t i;
@@ -222,8 +234,8 @@ int slisstatic(unit)
return 0;
}
-static
-void slmarkstatic(unit)
+static void
+slmarkstatic(unit)
int unit;
{
int *t;
@@ -367,7 +379,8 @@ slopen(dev, tp)
}
void
-sldestroy(struct sl_softc *sc) {
+sldestroy(struct sl_softc *sc)
+{
bpfdetach(&sc->sc_if);
if_detach(&sc->sc_if);
LIST_REMOVE(sc, sl_next);
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index c7047a7..feef9c9 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -22,6 +22,7 @@
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
+#include <sys/module.h>
#include <sys/socket.h>
#include <sys/filio.h>
#include <sys/sockio.h>
@@ -52,9 +53,6 @@
static MALLOC_DEFINE(M_TUN, "tun", "Tunnel Interface");
-static void tunattach __P((void *));
-PSEUDO_SET(tunattach, if_tun);
-
static void tuncreate __P((dev_t dev));
#define TUNDEBUG if (tundebug) printf
@@ -113,14 +111,28 @@ tun_clone(arg, name, namelen, dev)
}
-static void
-tunattach(dummy)
- void *dummy;
-{
-
- EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000);
- cdevsw_add(&tun_cdevsw);
-}
+static int
+tun_modevent(module_t mod, int type, void *data)
+{
+ switch (type) {
+ case MOD_LOAD:
+ EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000);
+ cdevsw_add(&tun_cdevsw);
+ break;
+ case MOD_UNLOAD:
+ printf("if_tun module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t tun_mod = {
+ "if_tun",
+ tun_modevent,
+ 0
+};
+
+DECLARE_MODULE(if_tun, tun_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
static void
tunstart(ifp)
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index d20dbcc..5a2d88f 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -61,6 +61,7 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
+#include <sys/module.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/sockio.h>
@@ -105,7 +106,8 @@ static int vlan_config(struct ifvlan *ifv, struct ifnet *p);
* later by the upper protocol layers. Unfortunately, there's no way
* to avoid this: there really is only one physical interface.
*/
-static int vlan_setmulti(struct ifnet *ifp)
+static int
+vlan_setmulti(struct ifnet *ifp)
{
struct ifnet *ifp_p;
struct ifmultiaddr *ifma, *rifma = NULL;
@@ -150,7 +152,7 @@ static int vlan_setmulti(struct ifnet *ifp)
}
static void
-vlaninit(void *dummy)
+vlaninit(void)
{
int i;
@@ -177,7 +179,28 @@ vlaninit(void *dummy)
ifp->if_resolvemulti = 0;
}
}
-PSEUDO_SET(vlaninit, if_vlan);
+
+static int
+vlan_modevent(module_t mod, int type, void *data)
+{
+ switch (type) {
+ case MOD_LOAD:
+ vlaninit();
+ break;
+ case MOD_UNLOAD:
+ printf("if_vlan module unload - not possible for this module type\n");
+ return EINVAL;
+ }
+ return 0;
+}
+
+static moduledata_t vlan_mod = {
+ "if_vlan",
+ vlan_modevent,
+ 0
+};
+
+DECLARE_MODULE(if_vlan, vlan_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
static void
vlan_ifinit(void *foo)
OpenPOWER on IntegriCloud