From 912bb3e6d9ef2fe15cb23712e9d113d99e8a8c95 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Fri, 25 Nov 2011 14:35:02 +0000 Subject: [PATCH] --- yaml --- r: 277951 b: refs/heads/master c: 7df899c36cf09678bdef1824ce591ef4ac0e9864 h: refs/heads/master i: 277949: c47ad5da7c101054ccdd972ef41bb169a2722f67 277947: 056e1ce960fc3e6e677423cd905cfab3d10684af 277943: 6cc522b04d5120496f4c4f9567458292c389fd1b 277935: 754f62a20b01149c475bbe136a881445eeaec9d0 277919: d4559c2f5f79264d6e3086e4c06c95c4c43f2e7e 277887: 64ff422a7588ef375fb089be2de1c07a48ede103 v: v3 --- [refs] | 2 +- trunk/net/dsa/Makefile | 13 +++++++------ trunk/net/dsa/dsa.c | 26 +++++++++++++++++++++++++- trunk/net/dsa/dsa_priv.h | 3 +++ trunk/net/dsa/tag_dsa.c | 15 +-------------- trunk/net/dsa/tag_edsa.c | 15 +-------------- trunk/net/dsa/tag_trailer.c | 15 +-------------- 7 files changed, 39 insertions(+), 50 deletions(-) diff --git a/[refs] b/[refs] index 526c1f32b408..241e3003b6bb 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ad293b8a218ca13a9ee3e3c98137fa301987577c +refs/heads/master: 7df899c36cf09678bdef1824ce591ef4ac0e9864 diff --git a/trunk/net/dsa/Makefile b/trunk/net/dsa/Makefile index 2374faff4dea..5431b4a43c13 100644 --- a/trunk/net/dsa/Makefile +++ b/trunk/net/dsa/Makefile @@ -1,13 +1,14 @@ +# the core +obj-$(CONFIG_NET_DSA) += dsa_core.o +dsa_core-y += dsa.o slave.o + # tagging formats -obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o -obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o -obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o +dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o +dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o +dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o # switch drivers obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o obj-$(CONFIG_NET_DSA_MV88E6123_61_65) += mv88e6123_61_65.o obj-$(CONFIG_NET_DSA_MV88E6131) += mv88e6131.o - -# the core -obj-$(CONFIG_NET_DSA) += dsa.o slave.o diff --git a/trunk/net/dsa/dsa.c b/trunk/net/dsa/dsa.c index fc93088cdc90..88e7c2f3fa0d 100644 --- a/trunk/net/dsa/dsa.c +++ b/trunk/net/dsa/dsa.c @@ -398,12 +398,36 @@ static struct platform_driver dsa_driver = { static int __init dsa_init_module(void) { - return platform_driver_register(&dsa_driver); + int rc; + + rc = platform_driver_register(&dsa_driver); + if (rc) + return rc; + +#ifdef CONFIG_NET_DSA_TAG_DSA + dev_add_pack(&dsa_packet_type); +#endif +#ifdef CONFIG_NET_DSA_TAG_EDSA + dev_add_pack(&edsa_packet_type); +#endif +#ifdef CONFIG_NET_DSA_TAG_TRAILER + dev_add_pack(&trailer_packet_type); +#endif + return 0; } module_init(dsa_init_module); static void __exit dsa_cleanup_module(void) { +#ifdef CONFIG_NET_DSA_TAG_TRAILER + dev_remove_pack(&trailer_packet_type); +#endif +#ifdef CONFIG_NET_DSA_TAG_EDSA + dev_remove_pack(&edsa_packet_type); +#endif +#ifdef CONFIG_NET_DSA_TAG_DSA + dev_remove_pack(&dsa_packet_type); +#endif platform_driver_unregister(&dsa_driver); } module_exit(dsa_cleanup_module); diff --git a/trunk/net/dsa/dsa_priv.h b/trunk/net/dsa/dsa_priv.h index a45186cb6daf..89a2eb48232a 100644 --- a/trunk/net/dsa/dsa_priv.h +++ b/trunk/net/dsa/dsa_priv.h @@ -137,12 +137,15 @@ struct net_device *dsa_slave_create(struct dsa_switch *ds, /* tag_dsa.c */ netdev_tx_t dsa_xmit(struct sk_buff *skb, struct net_device *dev); +extern struct packet_type dsa_packet_type; /* tag_edsa.c */ netdev_tx_t edsa_xmit(struct sk_buff *skb, struct net_device *dev); +extern struct packet_type edsa_packet_type; /* tag_trailer.c */ netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev); +extern struct packet_type trailer_packet_type; #endif diff --git a/trunk/net/dsa/tag_dsa.c b/trunk/net/dsa/tag_dsa.c index 98dfe80b4538..cacce1e22f9c 100644 --- a/trunk/net/dsa/tag_dsa.c +++ b/trunk/net/dsa/tag_dsa.c @@ -186,20 +186,7 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev, return 0; } -static struct packet_type dsa_packet_type __read_mostly = { +struct packet_type dsa_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_DSA), .func = dsa_rcv, }; - -static int __init dsa_init_module(void) -{ - dev_add_pack(&dsa_packet_type); - return 0; -} -module_init(dsa_init_module); - -static void __exit dsa_cleanup_module(void) -{ - dev_remove_pack(&dsa_packet_type); -} -module_exit(dsa_cleanup_module); diff --git a/trunk/net/dsa/tag_edsa.c b/trunk/net/dsa/tag_edsa.c index 6f383322ad25..e70c43c25e64 100644 --- a/trunk/net/dsa/tag_edsa.c +++ b/trunk/net/dsa/tag_edsa.c @@ -205,20 +205,7 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev, return 0; } -static struct packet_type edsa_packet_type __read_mostly = { +struct packet_type edsa_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_EDSA), .func = edsa_rcv, }; - -static int __init edsa_init_module(void) -{ - dev_add_pack(&edsa_packet_type); - return 0; -} -module_init(edsa_init_module); - -static void __exit edsa_cleanup_module(void) -{ - dev_remove_pack(&edsa_packet_type); -} -module_exit(edsa_cleanup_module); diff --git a/trunk/net/dsa/tag_trailer.c b/trunk/net/dsa/tag_trailer.c index d6d7d0add3cb..94bc260d015d 100644 --- a/trunk/net/dsa/tag_trailer.c +++ b/trunk/net/dsa/tag_trailer.c @@ -114,20 +114,7 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev, return 0; } -static struct packet_type trailer_packet_type __read_mostly = { +struct packet_type trailer_packet_type __read_mostly = { .type = cpu_to_be16(ETH_P_TRAILER), .func = trailer_rcv, }; - -static int __init trailer_init_module(void) -{ - dev_add_pack(&trailer_packet_type); - return 0; -} -module_init(trailer_init_module); - -static void __exit trailer_cleanup_module(void) -{ - dev_remove_pack(&trailer_packet_type); -} -module_exit(trailer_cleanup_module);