mv88e6xxx: Combine mv88e6131 and mv88e612_61_65 drivers
authorBen Hutchings <ben@decadent.org.uk>
Fri, 25 Nov 2011 14:36:19 +0000 (14:36 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 26 Nov 2011 19:48:15 +0000 (14:48 -0500)
These drivers share a lot of code, so if we make them modular they
should 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>
net/dsa/Makefile
net/dsa/mv88e6123_61_65.c
net/dsa/mv88e6131.c
net/dsa/mv88e6xxx.c
net/dsa/mv88e6xxx.h

index 5431b4a43c130a9ab9df75d9abdb1dfc94954a1f..5c48ac5569978a5be444777fd01997bc7c8a8a18 100644 (file)
@@ -8,7 +8,8 @@ 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
+obj-$(CONFIG_NET_DSA_MV88E6XXX) += mv88e6xxx_drv.o
+mv88e6xxx_drv-y += mv88e6xxx.o
+mv88e6xxx_drv-$(CONFIG_NET_DSA_MV88E6123_61_65) += mv88e6123_61_65.o
+mv88e6xxx_drv-$(CONFIG_NET_DSA_MV88E6131) += mv88e6131.o
index 52faaa21a4d927e1a943840b01e2c85bb20464b9..7951a6cc9bdc7f5d037fbb51b520d1da7f6926d0 100644 (file)
@@ -419,7 +419,7 @@ static int mv88e6123_61_65_get_sset_count(struct dsa_switch *ds)
        return ARRAY_SIZE(mv88e6123_61_65_hw_stats);
 }
 
-static struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
+struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
        .tag_protocol           = cpu_to_be16(ETH_P_EDSA),
        .priv_size              = sizeof(struct mv88e6xxx_priv_state),
        .probe                  = mv88e6123_61_65_probe,
@@ -432,16 +432,3 @@ static struct dsa_switch_driver mv88e6123_61_65_switch_driver = {
        .get_ethtool_stats      = mv88e6123_61_65_get_ethtool_stats,
        .get_sset_count         = mv88e6123_61_65_get_sset_count,
 };
-
-static int __init mv88e6123_61_65_init(void)
-{
-       register_switch_driver(&mv88e6123_61_65_switch_driver);
-       return 0;
-}
-module_init(mv88e6123_61_65_init);
-
-static void __exit mv88e6123_61_65_cleanup(void)
-{
-       unregister_switch_driver(&mv88e6123_61_65_switch_driver);
-}
-module_exit(mv88e6123_61_65_cleanup);
index 9bd1061fa4ee5f6ef0b88b838c458d47603d541a..45f41239381c4b2db8240639cfe98aac2ea140af 100644 (file)
@@ -415,7 +415,7 @@ static int mv88e6131_get_sset_count(struct dsa_switch *ds)
        return ARRAY_SIZE(mv88e6131_hw_stats);
 }
 
-static struct dsa_switch_driver mv88e6131_switch_driver = {
+struct dsa_switch_driver mv88e6131_switch_driver = {
        .tag_protocol           = cpu_to_be16(ETH_P_DSA),
        .priv_size              = sizeof(struct mv88e6xxx_priv_state),
        .probe                  = mv88e6131_probe,
@@ -428,16 +428,3 @@ static struct dsa_switch_driver mv88e6131_switch_driver = {
        .get_ethtool_stats      = mv88e6131_get_ethtool_stats,
        .get_sset_count         = mv88e6131_get_sset_count,
 };
-
-static int __init mv88e6131_init(void)
-{
-       register_switch_driver(&mv88e6131_switch_driver);
-       return 0;
-}
-module_init(mv88e6131_init);
-
-static void __exit mv88e6131_cleanup(void)
-{
-       unregister_switch_driver(&mv88e6131_switch_driver);
-}
-module_exit(mv88e6131_cleanup);
index efe661a9def4db3644d0e8402e2b00295a3cd0c6..50fd860279695a6975347ff304cbcfd5f8bd762d 100644 (file)
@@ -520,3 +520,26 @@ void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
 
        mutex_unlock(&ps->stats_mutex);
 }
+
+static int __init mv88e6xxx_init(void)
+{
+#if IS_ENABLED(CONFIG_NET_DSA_MV88E6131)
+       register_switch_driver(&mv88e6131_switch_driver);
+#endif
+#if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65)
+       register_switch_driver(&mv88e6123_61_65_switch_driver);
+#endif
+       return 0;
+}
+module_init(mv88e6xxx_init);
+
+static void __exit mv88e6xxx_cleanup(void)
+{
+#if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65)
+       unregister_switch_driver(&mv88e6123_61_65_switch_driver);
+#endif
+#if IS_ENABLED(CONFIG_NET_DSA_MV88E6131)
+       unregister_switch_driver(&mv88e6131_switch_driver);
+#endif
+}
+module_exit(mv88e6xxx_cleanup);
index 61156ca26a0da3d17e7be6bc70bc7c11de4c6489..fc2cd7b90e8d257f9144933bb93f29c77b51ad83 100644 (file)
@@ -71,6 +71,9 @@ void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds,
                                 int nr_stats, struct mv88e6xxx_hw_stat *stats,
                                 int port, uint64_t *data);
 
+extern struct dsa_switch_driver mv88e6131_switch_driver;
+extern struct dsa_switch_driver mv88e6123_61_65_switch_driver;
+
 #define REG_READ(addr, reg)                                            \
        ({                                                              \
                int __ret;                                              \