Exterminate the use of PSEUDO_SET() with extreme prejudice.

This commit is contained in:
Peter Wemm 2001-01-31 07:58:58 +00:00
parent 0adb9b96bd
commit 2b12097485
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=71862
7 changed files with 173 additions and 61 deletions

View File

@ -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) {
static int
fb_modevent(module_t mod, int type, void *data)
{
switch (type) {
case MOD_LOAD:
cdevsw_add(&fb_cdevsw);
fb_devsw_installed = TRUE;
}
}
break;
case MOD_UNLOAD:
printf("fb module unload - not possible for this module type\n");
return EINVAL;
}
return 0;
}
PSEUDO_SET(vfbattach, fb);
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)

View File

@ -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;
@ -89,6 +88,28 @@ discattach(dummy)
bpfattach(ifp, DLT_NULL, sizeof(u_int));
}
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;

View File

@ -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)

View File

@ -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.
*/

View File

@ -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;
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;
}
LIST_INIT(&sl_list);
}
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);

View File

@ -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;
{
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;
}
EVENTHANDLER_REGISTER(dev_clone, tun_clone, 0, 1000);
cdevsw_add(&tun_cdevsw);
}
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)

View File

@ -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)