[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1460591998-20598-3-git-send-email-andrew@lunn.ch>
Date: Thu, 14 Apr 2016 01:59:52 +0200
From: Andrew Lunn <andrew@...n.ch>
To: David Miller <davem@...emloft.net>
Cc: Florian Fainelli <f.fainelli@...il.com>,
netdev <netdev@...r.kernel.org>,
Vivien Didelot <vivien.didelot@...oirfairelinux.com>,
Andrew Lunn <andrew@...n.ch>
Subject: [PATCH net-next 2/8] 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 | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx.h
index 5d27decc85cb..afb9ebdfc595 100644
--- a/drivers/net/dsa/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx.h
@@ -561,6 +561,26 @@ extern struct dsa_switch_driver mv88e6171_switch_driver;
return __ret; \
})
-
+/**
+ * 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)
#endif
--
2.7.0
Powered by blists - more mailing lists