From: Ben Hutchings <ben@decadent.org.uk>
To: David Miller <davem@davemloft.net>
Cc: Lennert Buytenhek <buytenh@wantstofly.org>, netdev@vger.kernel.org
Subject: [PATCH net-next 4/8] mv88e6xxx: Combine mv88e6131 and mv88e612_61_65 drivers
Date: Sat, 26 Nov 2011 00:36:19 +0000	[thread overview]
Message-ID: <1322267779.2839.385.camel@deadeye> (raw)
In-Reply-To: <1322267572.2839.381.camel@deadeye>
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>
---
 net/dsa/Makefile          |    7 ++++---
 net/dsa/mv88e6123_61_65.c |   15 +--------------
 net/dsa/mv88e6131.c       |   15 +--------------
 net/dsa/mv88e6xxx.c       |   23 +++++++++++++++++++++++
 net/dsa/mv88e6xxx.h       |    3 +++
 5 files changed, 32 insertions(+), 31 deletions(-)
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index 5431b4a..5c48ac5 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -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
diff --git a/net/dsa/mv88e6123_61_65.c b/net/dsa/mv88e6123_61_65.c
index 52faaa2..7951a6c 100644
--- a/net/dsa/mv88e6123_61_65.c
+++ b/net/dsa/mv88e6123_61_65.c
@@ -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);
diff --git a/net/dsa/mv88e6131.c b/net/dsa/mv88e6131.c
index 9bd1061..45f4123 100644
--- a/net/dsa/mv88e6131.c
+++ b/net/dsa/mv88e6131.c
@@ -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);
diff --git a/net/dsa/mv88e6xxx.c b/net/dsa/mv88e6xxx.c
index efe661a..50fd860 100644
--- a/net/dsa/mv88e6xxx.c
+++ b/net/dsa/mv88e6xxx.c
@@ -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);
diff --git a/net/dsa/mv88e6xxx.h b/net/dsa/mv88e6xxx.h
index 61156ca2..fc2cd7b 100644
--- a/net/dsa/mv88e6xxx.h
+++ b/net/dsa/mv88e6xxx.h
@@ -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;						\
-- 
1.7.7.3
next prev parent reply	other threads:[~2011-11-26  0:36 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-26  0:32 [PATCH net-next 1/8] dsa: Change dsa_uses_{dsa,trailer}_tags() into inline functions Ben Hutchings
2011-11-26  0:34 ` [PATCH net-next 2/8] dsa: Export functions from core to modules Ben Hutchings
2011-11-27 19:15   ` Lennert Buytenhek
2011-11-27 22:38     ` Ben Hutchings
2011-11-26  0:35 ` [PATCH net-next 3/8] dsa: Combine core and tagging code Ben Hutchings
2011-11-27 19:16   ` Lennert Buytenhek
2011-11-26  0:36 ` Ben Hutchings [this message]
2011-11-27 19:18   ` [PATCH net-next 4/8] mv88e6xxx: Combine mv88e6131 and mv88e612_61_65 drivers Lennert Buytenhek
2011-11-26  0:37 ` [PATCH net-next 5/8] dsa: Define module author, description, license and aliases for drivers Ben Hutchings
2011-11-27 19:17   ` Lennert Buytenhek
2011-11-26  0:38 ` [PATCH net-next 6/8] dsa: Allow core and drivers to be built as modules Ben Hutchings
2011-11-27 19:19   ` Lennert Buytenhek
2011-11-27 22:39     ` Ben Hutchings
2011-11-26  0:40 ` [PATCH net-next 7/8] net: Revert ARCNET and PHYLIB to tristate options Ben Hutchings
2011-11-26 19:42   ` David Miller
2011-11-26  0:40 ` [PATCH net-next 8/8] net: Use IS_ENABLED() in netdevice.h as appropriate Ben Hutchings
2011-11-27 19:12 ` [PATCH net-next 1/8] dsa: Change dsa_uses_{dsa,trailer}_tags() into inline functions Lennert Buytenhek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=1322267779.2839.385.camel@deadeye \
    --to=ben@decadent.org.uk \
    --cc=buytenh@wantstofly.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).