Commit a4c84476 authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[PKT_SCHED]: Convert to {subsys,module}_initcall(), fix init failure bugs in sch_teql.c

pktsched_init() and tc_filter_init() converted to subsys_initcall().
initialization of individual qdisc and tcf_proto switched to
module_init().  Some of them used to be registered twice if built-in, BTW.
init failure handling in sch_teql.c fixed - it used to leave objects
(both qdisc and netdev) registered if insmod failed.
parent 144abfc2
...@@ -440,9 +440,6 @@ int qdisc_new_estimator(struct tc_stats *stats, struct rtattr *opt); ...@@ -440,9 +440,6 @@ int qdisc_new_estimator(struct tc_stats *stats, struct rtattr *opt);
void qdisc_kill_estimator(struct tc_stats *stats); void qdisc_kill_estimator(struct tc_stats *stats);
struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *tab); struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *tab);
void qdisc_put_rtab(struct qdisc_rate_table *tab); void qdisc_put_rtab(struct qdisc_rate_table *tab);
int teql_init(void);
int tc_filter_init(void);
int pktsched_init(void);
extern int qdisc_restart(struct net_device *dev); extern int qdisc_restart(struct net_device *dev);
......
...@@ -3217,10 +3217,6 @@ static int __init net_dev_init(void) ...@@ -3217,10 +3217,6 @@ static int __init net_dev_init(void)
dst_init(); dst_init();
dev_mcast_init(); dev_mcast_init();
#ifdef CONFIG_NET_SCHED
pktsched_init();
#endif
rc = 0; rc = 0;
out: out:
return rc; return rc;
......
...@@ -8,23 +8,23 @@ obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o ...@@ -8,23 +8,23 @@ obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o
obj-$(CONFIG_NET_ESTIMATOR) += estimator.o obj-$(CONFIG_NET_ESTIMATOR) += estimator.o
obj-$(CONFIG_NET_CLS) += cls_api.o obj-$(CONFIG_NET_CLS) += cls_api.o
obj-$(CONFIG_NET_CLS_POLICE) += police.o obj-$(CONFIG_NET_CLS_POLICE) += police.o
obj-$(CONFIG_NET_SCH_INGRESS) += sch_ingress.o
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
obj-$(CONFIG_NET_SCH_CSZ) += sch_csz.o obj-$(CONFIG_NET_SCH_CSZ) += sch_csz.o
obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o
obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
obj-$(CONFIG_NET_SCH_RED) += sch_red.o obj-$(CONFIG_NET_SCH_RED) += sch_red.o
obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
obj-$(CONFIG_NET_SCH_GRED) += sch_gred.o obj-$(CONFIG_NET_SCH_GRED) += sch_gred.o
obj-$(CONFIG_NET_SCH_INGRESS) += sch_ingress.o
obj-$(CONFIG_NET_SCH_DSMARK) += sch_dsmark.o obj-$(CONFIG_NET_SCH_DSMARK) += sch_dsmark.o
obj-$(CONFIG_NET_CLS_TCINDEX) += cls_tcindex.o obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o
obj-$(CONFIG_NET_CLS_U32) += cls_u32.o obj-$(CONFIG_NET_CLS_U32) += cls_u32.o
obj-$(CONFIG_NET_CLS_RSVP) += cls_rsvp.o
obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o
obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o
obj-$(CONFIG_NET_CLS_FW) += cls_fw.o obj-$(CONFIG_NET_CLS_FW) += cls_fw.o
obj-$(CONFIG_NET_CLS_RSVP) += cls_rsvp.o
obj-$(CONFIG_NET_CLS_TCINDEX) += cls_tcindex.o
obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o
...@@ -425,7 +425,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -425,7 +425,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
} }
int __init tc_filter_init(void) static int __init tc_filter_init(void)
{ {
struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC]; struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC];
...@@ -439,31 +439,10 @@ int __init tc_filter_init(void) ...@@ -439,31 +439,10 @@ int __init tc_filter_init(void)
link_p[RTM_GETTFILTER-RTM_BASE].doit = tc_ctl_tfilter; link_p[RTM_GETTFILTER-RTM_BASE].doit = tc_ctl_tfilter;
link_p[RTM_GETTFILTER-RTM_BASE].dumpit = tc_dump_tfilter; link_p[RTM_GETTFILTER-RTM_BASE].dumpit = tc_dump_tfilter;
} }
#define INIT_TC_FILTER(name) { \
extern struct tcf_proto_ops cls_##name##_ops; \
register_tcf_proto_ops(&cls_##name##_ops); \
}
#ifdef CONFIG_NET_CLS_U32
INIT_TC_FILTER(u32);
#endif
#ifdef CONFIG_NET_CLS_ROUTE4
INIT_TC_FILTER(route4);
#endif
#ifdef CONFIG_NET_CLS_FW
INIT_TC_FILTER(fw);
#endif
#ifdef CONFIG_NET_CLS_RSVP
INIT_TC_FILTER(rsvp);
#endif
#ifdef CONFIG_NET_CLS_TCINDEX
INIT_TC_FILTER(tcindex);
#endif
#ifdef CONFIG_NET_CLS_RSVP6
INIT_TC_FILTER(rsvp6);
#endif
return 0; return 0;
} }
subsys_initcall(tc_filter_init);
EXPORT_SYMBOL(register_tcf_proto_ops); EXPORT_SYMBOL(register_tcf_proto_ops);
EXPORT_SYMBOL(unregister_tcf_proto_ops); EXPORT_SYMBOL(unregister_tcf_proto_ops);
...@@ -347,7 +347,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -347,7 +347,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
return -1; return -1;
} }
struct tcf_proto_ops cls_fw_ops = { static struct tcf_proto_ops cls_fw_ops = {
.next = NULL, .next = NULL,
.kind = "fw", .kind = "fw",
.classify = fw_classify, .classify = fw_classify,
...@@ -362,15 +362,16 @@ struct tcf_proto_ops cls_fw_ops = { ...@@ -362,15 +362,16 @@ struct tcf_proto_ops cls_fw_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init init_fw(void)
int init_module(void)
{ {
return register_tcf_proto_ops(&cls_fw_ops); return register_tcf_proto_ops(&cls_fw_ops);
} }
void cleanup_module(void) static void __exit exit_fw(void)
{ {
unregister_tcf_proto_ops(&cls_fw_ops); unregister_tcf_proto_ops(&cls_fw_ops);
} }
#endif
module_init(init_fw)
module_exit(exit_fw)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -602,7 +602,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -602,7 +602,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
return -1; return -1;
} }
struct tcf_proto_ops cls_route4_ops = { static struct tcf_proto_ops cls_route4_ops = {
.next = NULL, .next = NULL,
.kind = "route", .kind = "route",
.classify = route4_classify, .classify = route4_classify,
...@@ -617,15 +617,16 @@ struct tcf_proto_ops cls_route4_ops = { ...@@ -617,15 +617,16 @@ struct tcf_proto_ops cls_route4_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init init_route4(void)
int init_module(void)
{ {
return register_tcf_proto_ops(&cls_route4_ops); return register_tcf_proto_ops(&cls_route4_ops);
} }
void cleanup_module(void) static void __exit exit_route4(void)
{ {
unregister_tcf_proto_ops(&cls_route4_ops); unregister_tcf_proto_ops(&cls_route4_ops);
} }
#endif
module_init(init_route4)
module_exit(exit_route4)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -667,7 +667,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -667,7 +667,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh,
return -1; return -1;
} }
struct tcf_proto_ops RSVP_OPS = { static struct tcf_proto_ops RSVP_OPS = {
.next = NULL, .next = NULL,
.kind = RSVP_ID, .kind = RSVP_ID,
.classify = rsvp_classify, .classify = rsvp_classify,
...@@ -682,14 +682,15 @@ struct tcf_proto_ops RSVP_OPS = { ...@@ -682,14 +682,15 @@ struct tcf_proto_ops RSVP_OPS = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init init_rsvp(void)
int init_module(void)
{ {
return register_tcf_proto_ops(&RSVP_OPS); return register_tcf_proto_ops(&RSVP_OPS);
} }
void cleanup_module(void) static void __exit exit_rsvp(void)
{ {
unregister_tcf_proto_ops(&RSVP_OPS); unregister_tcf_proto_ops(&RSVP_OPS);
} }
#endif
module_init(init_rsvp)
module_exit(exit_rsvp)
...@@ -476,7 +476,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -476,7 +476,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
return -1; return -1;
} }
struct tcf_proto_ops cls_tcindex_ops = { static struct tcf_proto_ops cls_tcindex_ops = {
.next = NULL, .next = NULL,
.kind = "tcindex", .kind = "tcindex",
.classify = tcindex_classify, .classify = tcindex_classify,
...@@ -491,16 +491,16 @@ struct tcf_proto_ops cls_tcindex_ops = { ...@@ -491,16 +491,16 @@ struct tcf_proto_ops cls_tcindex_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init init_tcindex(void)
#ifdef MODULE
int init_module(void)
{ {
return register_tcf_proto_ops(&cls_tcindex_ops); return register_tcf_proto_ops(&cls_tcindex_ops);
} }
void cleanup_module(void) static void __exit exit_tcindex(void)
{ {
unregister_tcf_proto_ops(&cls_tcindex_ops); unregister_tcf_proto_ops(&cls_tcindex_ops);
} }
#endif
module_init(init_tcindex)
module_exit(exit_tcindex)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -684,7 +684,7 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -684,7 +684,7 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
return -1; return -1;
} }
struct tcf_proto_ops cls_u32_ops = { static struct tcf_proto_ops cls_u32_ops = {
.next = NULL, .next = NULL,
.kind = "u32", .kind = "u32",
.classify = u32_classify, .classify = u32_classify,
...@@ -699,15 +699,16 @@ struct tcf_proto_ops cls_u32_ops = { ...@@ -699,15 +699,16 @@ struct tcf_proto_ops cls_u32_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init init_u32(void)
int init_module(void)
{ {
return register_tcf_proto_ops(&cls_u32_ops); return register_tcf_proto_ops(&cls_u32_ops);
} }
void cleanup_module(void) static void __exit exit_u32(void)
{ {
unregister_tcf_proto_ops(&cls_u32_ops); unregister_tcf_proto_ops(&cls_u32_ops);
} }
#endif
module_init(init_u32)
module_exit(exit_u32)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -1165,7 +1165,7 @@ int __init psched_calibrate_clock(void) ...@@ -1165,7 +1165,7 @@ int __init psched_calibrate_clock(void)
} }
#endif #endif
int __init pktsched_init(void) static int __init pktsched_init(void)
{ {
struct rtnetlink_link *link_p; struct rtnetlink_link *link_p;
...@@ -1197,65 +1197,15 @@ int __init pktsched_init(void) ...@@ -1197,65 +1197,15 @@ int __init pktsched_init(void)
link_p[RTM_GETTCLASS-RTM_BASE].dumpit = tc_dump_tclass; link_p[RTM_GETTCLASS-RTM_BASE].dumpit = tc_dump_tclass;
} }
#define INIT_QDISC(name) { \ register_qdisc(&pfifo_qdisc_ops);
extern struct Qdisc_ops name##_qdisc_ops; \ register_qdisc(&bfifo_qdisc_ops);
register_qdisc(& name##_qdisc_ops); \
}
INIT_QDISC(pfifo);
INIT_QDISC(bfifo);
#ifdef CONFIG_NET_SCH_CBQ
INIT_QDISC(cbq);
#endif
#ifdef CONFIG_NET_SCH_HTB
INIT_QDISC(htb);
#endif
#ifdef CONFIG_NET_SCH_CSZ
INIT_QDISC(csz);
#endif
#ifdef CONFIG_NET_SCH_HPFQ
INIT_QDISC(hpfq);
#endif
#ifdef CONFIG_NET_SCH_HFSC
INIT_QDISC(hfsc);
#endif
#ifdef CONFIG_NET_SCH_RED
INIT_QDISC(red);
#endif
#ifdef CONFIG_NET_SCH_GRED
INIT_QDISC(gred);
#endif
#ifdef CONFIG_NET_SCH_INGRESS
INIT_QDISC(ingress);
#endif
#ifdef CONFIG_NET_SCH_DSMARK
INIT_QDISC(dsmark);
#endif
#ifdef CONFIG_NET_SCH_SFQ
INIT_QDISC(sfq);
#endif
#ifdef CONFIG_NET_SCH_TBF
INIT_QDISC(tbf);
#endif
#ifdef CONFIG_NET_SCH_TEQL
teql_init();
#endif
#ifdef CONFIG_NET_SCH_PRIO
INIT_QDISC(prio);
#endif
#ifdef CONFIG_NET_SCH_ATM
INIT_QDISC(atm);
#endif
#ifdef CONFIG_NET_CLS
tc_filter_init();
#endif
proc_net_fops_create("psched", 0, &psched_fops); proc_net_fops_create("psched", 0, &psched_fops);
return 0; return 0;
} }
subsys_initcall(pktsched_init);
EXPORT_SYMBOL(qdisc_copy_stats); EXPORT_SYMBOL(qdisc_copy_stats);
EXPORT_SYMBOL(qdisc_get_rtab); EXPORT_SYMBOL(qdisc_get_rtab);
EXPORT_SYMBOL(qdisc_put_rtab); EXPORT_SYMBOL(qdisc_put_rtab);
......
...@@ -682,7 +682,7 @@ static struct Qdisc_class_ops atm_class_ops = { ...@@ -682,7 +682,7 @@ static struct Qdisc_class_ops atm_class_ops = {
.dump = atm_tc_dump_class, .dump = atm_tc_dump_class,
}; };
struct Qdisc_ops atm_qdisc_ops = { static struct Qdisc_ops atm_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &atm_class_ops, .cl_ops = &atm_class_ops,
.id = "atm", .id = "atm",
...@@ -700,15 +700,15 @@ struct Qdisc_ops atm_qdisc_ops = { ...@@ -700,15 +700,15 @@ struct Qdisc_ops atm_qdisc_ops = {
}; };
#ifdef MODULE static int __init atm_init(void)
int init_module(void)
{ {
return register_qdisc(&atm_qdisc_ops); return register_qdisc(&atm_qdisc_ops);
} }
static void __exit atm_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&atm_qdisc_ops); unregister_qdisc(&atm_qdisc_ops);
} }
#endif
module_init(atm_init)
module_exit(atm_exit)
...@@ -2074,7 +2074,7 @@ static struct Qdisc_class_ops cbq_class_ops = { ...@@ -2074,7 +2074,7 @@ static struct Qdisc_class_ops cbq_class_ops = {
.dump = cbq_dump_class, .dump = cbq_dump_class,
}; };
struct Qdisc_ops cbq_qdisc_ops = { static struct Qdisc_ops cbq_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &cbq_class_ops, .cl_ops = &cbq_class_ops,
.id = "cbq", .id = "cbq",
...@@ -2091,15 +2091,14 @@ struct Qdisc_ops cbq_qdisc_ops = { ...@@ -2091,15 +2091,14 @@ struct Qdisc_ops cbq_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init cbq_module_init(void)
int init_module(void)
{ {
return register_qdisc(&cbq_qdisc_ops); return register_qdisc(&cbq_qdisc_ops);
} }
static void __exit cbq_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&cbq_qdisc_ops); unregister_qdisc(&cbq_qdisc_ops);
} }
#endif module_init(cbq_module_init)
module_exit(cbq_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -1027,7 +1027,7 @@ struct Qdisc_class_ops csz_class_ops = { ...@@ -1027,7 +1027,7 @@ struct Qdisc_class_ops csz_class_ops = {
.dump = csz_dump_class, .dump = csz_dump_class,
}; };
struct Qdisc_ops csz_qdisc_ops = { static struct Qdisc_ops csz_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &csz_class_ops, .cl_ops = &csz_class_ops,
.id = "csz", .id = "csz",
...@@ -1044,16 +1044,14 @@ struct Qdisc_ops csz_qdisc_ops = { ...@@ -1044,16 +1044,14 @@ struct Qdisc_ops csz_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init csz_module_init(void)
#ifdef MODULE
int init_module(void)
{ {
return register_qdisc(&csz_qdisc_ops); return register_qdisc(&csz_qdisc_ops);
} }
static void __exit csz_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&csz_qdisc_ops); unregister_qdisc(&csz_qdisc_ops);
} }
#endif module_init(csz_module_init)
module_exit(csz_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -447,7 +447,7 @@ static struct Qdisc_class_ops dsmark_class_ops = { ...@@ -447,7 +447,7 @@ static struct Qdisc_class_ops dsmark_class_ops = {
.dump = dsmark_dump_class, .dump = dsmark_dump_class,
}; };
struct Qdisc_ops dsmark_qdisc_ops = { static struct Qdisc_ops dsmark_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &dsmark_class_ops, .cl_ops = &dsmark_class_ops,
.id = "dsmark", .id = "dsmark",
...@@ -464,16 +464,14 @@ struct Qdisc_ops dsmark_qdisc_ops = { ...@@ -464,16 +464,14 @@ struct Qdisc_ops dsmark_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init dsmark_module_init(void)
int init_module(void)
{ {
return register_qdisc(&dsmark_qdisc_ops); return register_qdisc(&dsmark_qdisc_ops);
} }
static void __exit dsmark_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&dsmark_qdisc_ops); unregister_qdisc(&dsmark_qdisc_ops);
} }
#endif module_init(dsmark_module_init)
module_exit(dsmark_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -602,7 +602,7 @@ static void gred_destroy(struct Qdisc *sch) ...@@ -602,7 +602,7 @@ static void gred_destroy(struct Qdisc *sch)
} }
} }
struct Qdisc_ops gred_qdisc_ops = { static struct Qdisc_ops gred_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = NULL, .cl_ops = NULL,
.id = "gred", .id = "gred",
...@@ -619,16 +619,14 @@ struct Qdisc_ops gred_qdisc_ops = { ...@@ -619,16 +619,14 @@ struct Qdisc_ops gred_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init gred_module_init(void)
#ifdef MODULE
int init_module(void)
{ {
return register_qdisc(&gred_qdisc_ops); return register_qdisc(&gred_qdisc_ops);
} }
static void __exit gred_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&gred_qdisc_ops); unregister_qdisc(&gred_qdisc_ops);
} }
#endif module_init(gred_module_init)
module_exit(gred_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -1831,7 +1831,7 @@ static struct Qdisc_class_ops hfsc_class_ops = { ...@@ -1831,7 +1831,7 @@ static struct Qdisc_class_ops hfsc_class_ops = {
.walk = hfsc_walk .walk = hfsc_walk
}; };
struct Qdisc_ops hfsc_qdisc_ops = { static struct Qdisc_ops hfsc_qdisc_ops = {
.id = "hfsc", .id = "hfsc",
.init = hfsc_init_qdisc, .init = hfsc_init_qdisc,
.change = hfsc_change_qdisc, .change = hfsc_change_qdisc,
......
...@@ -1646,7 +1646,7 @@ static struct Qdisc_class_ops htb_class_ops = { ...@@ -1646,7 +1646,7 @@ static struct Qdisc_class_ops htb_class_ops = {
.dump = htb_dump_class, .dump = htb_dump_class,
}; };
struct Qdisc_ops htb_qdisc_ops = { static struct Qdisc_ops htb_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &htb_class_ops, .cl_ops = &htb_class_ops,
.id = "htb", .id = "htb",
...@@ -1663,15 +1663,14 @@ struct Qdisc_ops htb_qdisc_ops = { ...@@ -1663,15 +1663,14 @@ struct Qdisc_ops htb_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init htb_module_init(void)
int init_module(void)
{ {
return register_qdisc(&htb_qdisc_ops); return register_qdisc(&htb_qdisc_ops);
} }
static void __exit htb_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&htb_qdisc_ops); unregister_qdisc(&htb_qdisc_ops);
} }
module_init(htb_module_init)
module_exit(htb_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
#endif
...@@ -333,7 +333,7 @@ static struct Qdisc_class_ops ingress_class_ops = { ...@@ -333,7 +333,7 @@ static struct Qdisc_class_ops ingress_class_ops = {
.dump = NULL, .dump = NULL,
}; };
struct Qdisc_ops ingress_qdisc_ops = { static struct Qdisc_ops ingress_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &ingress_class_ops, .cl_ops = &ingress_class_ops,
.id = "ingress", .id = "ingress",
...@@ -350,9 +350,7 @@ struct Qdisc_ops ingress_qdisc_ops = { ...@@ -350,9 +350,7 @@ struct Qdisc_ops ingress_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init ingress_module_init(void)
#ifdef MODULE
int init_module(void)
{ {
int ret = 0; int ret = 0;
...@@ -363,13 +361,12 @@ int init_module(void) ...@@ -363,13 +361,12 @@ int init_module(void)
return ret; return ret;
} }
static void __exit ingress_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&ingress_qdisc_ops); unregister_qdisc(&ingress_qdisc_ops);
if (nf_registered) if (nf_registered)
nf_unregister_hook(&ing_ops); nf_unregister_hook(&ing_ops);
} }
#endif module_init(ingress_module_init)
module_exit(ingress_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -382,7 +382,7 @@ static struct Qdisc_class_ops prio_class_ops = { ...@@ -382,7 +382,7 @@ static struct Qdisc_class_ops prio_class_ops = {
.dump = prio_dump_class, .dump = prio_dump_class,
}; };
struct Qdisc_ops prio_qdisc_ops = { static struct Qdisc_ops prio_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &prio_class_ops, .cl_ops = &prio_class_ops,
.id = "prio", .id = "prio",
...@@ -399,17 +399,17 @@ struct Qdisc_ops prio_qdisc_ops = { ...@@ -399,17 +399,17 @@ struct Qdisc_ops prio_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init prio_module_init(void)
int init_module(void)
{ {
return register_qdisc(&prio_qdisc_ops); return register_qdisc(&prio_qdisc_ops);
} }
void cleanup_module(void) static void __exit prio_module_exit(void)
{ {
unregister_qdisc(&prio_qdisc_ops); unregister_qdisc(&prio_qdisc_ops);
} }
#endif module_init(prio_module_init)
module_exit(prio_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -453,7 +453,7 @@ static void red_destroy(struct Qdisc *sch) ...@@ -453,7 +453,7 @@ static void red_destroy(struct Qdisc *sch)
{ {
} }
struct Qdisc_ops red_qdisc_ops = { static struct Qdisc_ops red_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = NULL, .cl_ops = NULL,
.id = "red", .id = "red",
...@@ -470,16 +470,14 @@ struct Qdisc_ops red_qdisc_ops = { ...@@ -470,16 +470,14 @@ struct Qdisc_ops red_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init red_module_init(void)
#ifdef MODULE
int init_module(void)
{ {
return register_qdisc(&red_qdisc_ops); return register_qdisc(&red_qdisc_ops);
} }
static void __exit red_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&red_qdisc_ops); unregister_qdisc(&red_qdisc_ops);
} }
#endif module_init(red_module_init)
module_exit(red_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -466,7 +466,7 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb) ...@@ -466,7 +466,7 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
return -1; return -1;
} }
struct Qdisc_ops sfq_qdisc_ops = { static struct Qdisc_ops sfq_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = NULL, .cl_ops = NULL,
.id = "sfq", .id = "sfq",
...@@ -483,15 +483,14 @@ struct Qdisc_ops sfq_qdisc_ops = { ...@@ -483,15 +483,14 @@ struct Qdisc_ops sfq_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#ifdef MODULE static int __init sfq_module_init(void)
int init_module(void)
{ {
return register_qdisc(&sfq_qdisc_ops); return register_qdisc(&sfq_qdisc_ops);
} }
static void __exit sfq_module_exit(void)
void cleanup_module(void)
{ {
unregister_qdisc(&sfq_qdisc_ops); unregister_qdisc(&sfq_qdisc_ops);
} }
#endif module_init(sfq_module_init)
module_exit(sfq_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -510,7 +510,7 @@ static struct Qdisc_class_ops tbf_class_ops = ...@@ -510,7 +510,7 @@ static struct Qdisc_class_ops tbf_class_ops =
.dump = tbf_dump_class, .dump = tbf_dump_class,
}; };
struct Qdisc_ops tbf_qdisc_ops = { static struct Qdisc_ops tbf_qdisc_ops = {
.next = NULL, .next = NULL,
.cl_ops = &tbf_class_ops, .cl_ops = &tbf_class_ops,
.id = "tbf", .id = "tbf",
...@@ -527,16 +527,15 @@ struct Qdisc_ops tbf_qdisc_ops = { ...@@ -527,16 +527,15 @@ struct Qdisc_ops tbf_qdisc_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int __init tbf_module_init(void)
#ifdef MODULE
int init_module(void)
{ {
return register_qdisc(&tbf_qdisc_ops); return register_qdisc(&tbf_qdisc_ops);
} }
void cleanup_module(void) static void __exit tbf_module_exit(void)
{ {
unregister_qdisc(&tbf_qdisc_ops); unregister_qdisc(&tbf_qdisc_ops);
} }
#endif module_init(tbf_module_init)
module_exit(tbf_module_exit)
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -418,14 +418,12 @@ static int teql_master_mtu(struct net_device *dev, int new_mtu) ...@@ -418,14 +418,12 @@ static int teql_master_mtu(struct net_device *dev, int new_mtu)
return 0; return 0;
} }
static __init int teql_master_init(struct net_device *dev) static __init void teql_master_setup(struct net_device *dev)
{ {
struct teql_master *master = dev->priv; struct teql_master *master = dev->priv;
struct Qdisc_ops *ops = &master->qops; struct Qdisc_ops *ops = &master->qops;
master->dev = dev; master->dev = dev;
strlcpy(ops->id, dev->name, IFNAMSIZ);
ops->priv_size = sizeof(struct teql_sched_data); ops->priv_size = sizeof(struct teql_sched_data);
ops->enqueue = teql_enqueue; ops->enqueue = teql_enqueue;
...@@ -436,12 +434,6 @@ static __init int teql_master_init(struct net_device *dev) ...@@ -436,12 +434,6 @@ static __init int teql_master_init(struct net_device *dev)
ops->destroy = teql_destroy; ops->destroy = teql_destroy;
ops->owner = THIS_MODULE; ops->owner = THIS_MODULE;
return register_qdisc(ops);
}
static __init void teql_master_setup(struct net_device *dev)
{
dev->init = teql_master_init;
dev->open = teql_master_open; dev->open = teql_master_open;
dev->hard_start_xmit = teql_master_xmit; dev->hard_start_xmit = teql_master_xmit;
dev->stop = teql_master_close; dev->stop = teql_master_close;
...@@ -460,10 +452,10 @@ static int max_equalizers = 1; ...@@ -460,10 +452,10 @@ static int max_equalizers = 1;
MODULE_PARM(max_equalizers, "i"); MODULE_PARM(max_equalizers, "i");
MODULE_PARM_DESC(max_equalizers, "Max number of link equalizers"); MODULE_PARM_DESC(max_equalizers, "Max number of link equalizers");
int __init teql_init(void) static int __init teql_init(void)
{ {
int i; int i;
int err = 0; int err = -ENODEV;
for (i = 0; i < max_equalizers; i++) { for (i = 0; i < max_equalizers; i++) {
struct net_device *dev; struct net_device *dev;
...@@ -471,19 +463,30 @@ int __init teql_init(void) ...@@ -471,19 +463,30 @@ int __init teql_init(void)
dev = alloc_netdev(sizeof(struct teql_master), dev = alloc_netdev(sizeof(struct teql_master),
"teql%d", teql_master_setup); "teql%d", teql_master_setup);
if (!dev) if (!dev) {
return -ENOMEM; err = -ENOMEM;
break;
}
if ((err = register_netdev(dev))) { if ((err = register_netdev(dev))) {
free_netdev(dev); free_netdev(dev);
goto out; break;
} }
master = dev->priv; master = dev->priv;
strlcpy(master->qops.id, dev->name, IFNAMSIZ);
err = register_qdisc(&master->qops);
if (err) {
unregister_netdev(dev);
free_netdev(dev);
break;
}
list_add_tail(&master->master_list, &master_dev_list); list_add_tail(&master->master_list, &master_dev_list);
} }
out: return i ? 0 : err;
return err;
} }
static void __exit teql_exit(void) static void __exit teql_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment