Commit 7df899c36cf09678bdef1824ce591ef4ac0e9864

Authored by Ben Hutchings
Committed by David S. Miller
1 parent ad293b8a21

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: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 6 changed files with 38 additions and 49 deletions Side-by-side Diff

  1 +# the core
  2 +obj-$(CONFIG_NET_DSA) += dsa_core.o
  3 +dsa_core-y += dsa.o slave.o
  4 +
1 5 # tagging formats
2   -obj-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
3   -obj-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
4   -obj-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
  6 +dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o
  7 +dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o
  8 +dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o
5 9  
6 10 # switch drivers
7 11 obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx.o
8 12 obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o
9 13 obj-$(CONFIG_NET_DSA_MV88E6123_61_65) += mv88e6123_61_65.o
10 14 obj-$(CONFIG_NET_DSA_MV88E6131) += mv88e6131.o
11   -
12   -# the core
13   -obj-$(CONFIG_NET_DSA) += dsa.o slave.o
... ... @@ -398,12 +398,36 @@
398 398  
399 399 static int __init dsa_init_module(void)
400 400 {
401   - return platform_driver_register(&dsa_driver);
  401 + int rc;
  402 +
  403 + rc = platform_driver_register(&dsa_driver);
  404 + if (rc)
  405 + return rc;
  406 +
  407 +#ifdef CONFIG_NET_DSA_TAG_DSA
  408 + dev_add_pack(&dsa_packet_type);
  409 +#endif
  410 +#ifdef CONFIG_NET_DSA_TAG_EDSA
  411 + dev_add_pack(&edsa_packet_type);
  412 +#endif
  413 +#ifdef CONFIG_NET_DSA_TAG_TRAILER
  414 + dev_add_pack(&trailer_packet_type);
  415 +#endif
  416 + return 0;
402 417 }
403 418 module_init(dsa_init_module);
404 419  
405 420 static void __exit dsa_cleanup_module(void)
406 421 {
  422 +#ifdef CONFIG_NET_DSA_TAG_TRAILER
  423 + dev_remove_pack(&trailer_packet_type);
  424 +#endif
  425 +#ifdef CONFIG_NET_DSA_TAG_EDSA
  426 + dev_remove_pack(&edsa_packet_type);
  427 +#endif
  428 +#ifdef CONFIG_NET_DSA_TAG_DSA
  429 + dev_remove_pack(&dsa_packet_type);
  430 +#endif
407 431 platform_driver_unregister(&dsa_driver);
408 432 }
409 433 module_exit(dsa_cleanup_module);
... ... @@ -137,12 +137,15 @@
137 137  
138 138 /* tag_dsa.c */
139 139 netdev_tx_t dsa_xmit(struct sk_buff *skb, struct net_device *dev);
  140 +extern struct packet_type dsa_packet_type;
140 141  
141 142 /* tag_edsa.c */
142 143 netdev_tx_t edsa_xmit(struct sk_buff *skb, struct net_device *dev);
  144 +extern struct packet_type edsa_packet_type;
143 145  
144 146 /* tag_trailer.c */
145 147 netdev_tx_t trailer_xmit(struct sk_buff *skb, struct net_device *dev);
  148 +extern struct packet_type trailer_packet_type;
146 149  
147 150  
148 151 #endif
... ... @@ -186,21 +186,8 @@
186 186 return 0;
187 187 }
188 188  
189   -static struct packet_type dsa_packet_type __read_mostly = {
  189 +struct packet_type dsa_packet_type __read_mostly = {
190 190 .type = cpu_to_be16(ETH_P_DSA),
191 191 .func = dsa_rcv,
192 192 };
193   -
194   -static int __init dsa_init_module(void)
195   -{
196   - dev_add_pack(&dsa_packet_type);
197   - return 0;
198   -}
199   -module_init(dsa_init_module);
200   -
201   -static void __exit dsa_cleanup_module(void)
202   -{
203   - dev_remove_pack(&dsa_packet_type);
204   -}
205   -module_exit(dsa_cleanup_module);
... ... @@ -205,21 +205,8 @@
205 205 return 0;
206 206 }
207 207  
208   -static struct packet_type edsa_packet_type __read_mostly = {
  208 +struct packet_type edsa_packet_type __read_mostly = {
209 209 .type = cpu_to_be16(ETH_P_EDSA),
210 210 .func = edsa_rcv,
211 211 };
212   -
213   -static int __init edsa_init_module(void)
214   -{
215   - dev_add_pack(&edsa_packet_type);
216   - return 0;
217   -}
218   -module_init(edsa_init_module);
219   -
220   -static void __exit edsa_cleanup_module(void)
221   -{
222   - dev_remove_pack(&edsa_packet_type);
223   -}
224   -module_exit(edsa_cleanup_module);
net/dsa/tag_trailer.c
... ... @@ -114,21 +114,8 @@
114 114 return 0;
115 115 }
116 116  
117   -static struct packet_type trailer_packet_type __read_mostly = {
  117 +struct packet_type trailer_packet_type __read_mostly = {
118 118 .type = cpu_to_be16(ETH_P_TRAILER),
119 119 .func = trailer_rcv,
120 120 };
121   -
122   -static int __init trailer_init_module(void)
123   -{
124   - dev_add_pack(&trailer_packet_type);
125   - return 0;
126   -}
127   -module_init(trailer_init_module);
128   -
129   -static void __exit trailer_cleanup_module(void)
130   -{
131   - dev_remove_pack(&trailer_packet_type);
132   -}
133   -module_exit(trailer_cleanup_module);