Commit 7df899c3 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller

dsa: Combine core and tagging code

These files have circular dependencies, so if we make DSA modular then
they must be built into the same module.  Therefore, link them
together and merge their respective module init and exit functions.
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ad293b8a
# the core
obj-$(CONFIG_NET_DSA) += dsa_core.o
dsa_core-y += dsa.o slave.o
# tagging formats # tagging formats
obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
# switch drivers # switch drivers
obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
obj-$(CONFIG_NET_DSA_MV88E6123_61_65) += mv88e6123_61_65.o obj-$(CONFIG_NET_DSA_MV88E6123_61_65) += mv88e6123_61_65.o
obj-$(CONFIG_NET_DSA_MV88E6131) += mv88e6131.o obj-$(CONFIG_NET_DSA_MV88E6131) += mv88e6131.o
# the core
obj-$(CONFIG_NET_DSA) += dsa.o slave.o
...@@ -398,12 +398,36 @@ static struct platform_driver dsa_driver = { ...@@ -398,12 +398,36 @@ static struct platform_driver dsa_driver = {
static int __init dsa_init_module(void) 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); module_init(dsa_init_module);
static void __exit dsa_cleanup_module(void) 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); platform_driver_unregister(&dsa_driver);
} }
module_exit(dsa_cleanup_module); module_exit(dsa_cleanup_module);
......
...@@ -137,12 +137,15 @@ struct net_device *dsa_slave_create(struct dsa_switch *ds, ...@@ -137,12 +137,15 @@ struct net_device *dsa_slave_create(struct dsa_switch *ds,
/* tag_dsa.c */ /* tag_dsa.c */
netdev_tx_t dsa_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t dsa_xmit(struct sk_buff *skb, struct net_device *dev);
extern struct packet_type dsa_packet_type;
/* tag_edsa.c */ /* tag_edsa.c */
netdev_tx_t edsa_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t edsa_xmit(struct sk_buff *skb, struct net_device *dev);
extern struct packet_type edsa_packet_type;
/* tag_trailer.c */ /* tag_trailer.c */
netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev); netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev);
extern struct packet_type trailer_packet_type;
#endif #endif
...@@ -186,20 +186,7 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -186,20 +186,7 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev,
return 0; 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), .type = cpu_to_be16(ETH_P_DSA),
.func = dsa_rcv, .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);
...@@ -205,20 +205,7 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -205,20 +205,7 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev,
return 0; 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), .type = cpu_to_be16(ETH_P_EDSA),
.func = edsa_rcv, .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);
...@@ -114,20 +114,7 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -114,20 +114,7 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev,
return 0; 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), .type = cpu_to_be16(ETH_P_TRAILER),
.func = trailer_rcv, .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);
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