[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1456677700-23027-20-git-send-email-andrew@lunn.ch>
Date: Sun, 28 Feb 2016 17:41:27 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Florian Fainelli <f.fainelli@...il.com>,
Vivien Didelot <vivien.didelot@...oirfairelinux.com>,
netdev <netdev@...r.kernel.org>
Cc: Andrew Lunn <andrew@...n.ch>
Subject: [PATCH RFC v2 19/32] dsa: mv88e6xxx: Add macro for registering the drivers
The macro cuts down on boilerplate. The switch driver needs to both
register itself as an MDIO driver and register itself as a switch
driver. This second registration is needed to retain backwards
compatibility with the old binding.
Signed-off-by: Andrew Lunn <andrew@...n.ch>
---
drivers/net/dsa/mv88e6xxx.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index a4ae99b7cfd0..ce05964da85f 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -546,3 +546,26 @@ extern struct dsa_switch_driver mv88e6171_switch_driver;
#endif
+
+/**
+ * mv88e6xxx_module_driver() - Helper macro for registering mv88e6xxx drivers
+ *
+ * Helper macro for mv88e6xxx drivers which do not do anything special
+ * in module init/exit. Each module may only use this macro once, and
+ * calling it replaces module_init() and module_exit().
+ */
+#define mv88e6xxx_module_driver(_mdio_driver, _switch_driver) \
+static int __init mv88e6xxx_module_init(void) \
+{ \
+ register_switch_driver(&_switch_driver); \
+ return mdio_driver_register(&_mdio_driver); \
+} \
+module_init(mv88e6xxx_module_init); \
+ \
+static void __exit mv88e6xxx_module_exit(void) \
+{ \
+ mdio_driver_unregister(&_mdio_driver); \
+ unregister_switch_driver(&_switch_driver); \
+} \
+module_exit(mv88e6xxx_module_exit)
+
--
2.7.0
Powered by blists - more mailing lists