From: Andrew Lunn <andrew@lunn.ch>
To: David Miller <davem@davemloft.net>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
netdev <netdev@vger.kernel.org>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>,
Andrew Lunn <andrew@lunn.ch>
Subject: [PATCH net-next 2/8] dsa: mv88e6xxx: Add macro for registering the drivers
Date: Thu, 14 Apr 2016 01:59:52 +0200 [thread overview]
Message-ID: <1460591998-20598-3-git-send-email-andrew@lunn.ch> (raw)
In-Reply-To: <1460591998-20598-1-git-send-email-andrew@lunn.ch>
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@lunn.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
next prev parent reply other threads:[~2016-04-14 0:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-13 23:59 [PATCH net-next 0/8] DSA refactoring: set 2 Andrew Lunn
2016-04-13 23:59 ` [PATCH net-next 1/8] dsa: mv88e6xxx: Prepare for turning this into a library module Andrew Lunn
2016-04-14 20:22 ` Vivien Didelot
2016-04-14 21:26 ` Florian Fainelli
2016-04-14 21:37 ` Andrew Lunn
2016-04-14 21:49 ` David Miller
2016-04-14 21:32 ` Andrew Lunn
2016-04-13 23:59 ` Andrew Lunn [this message]
2016-04-13 23:59 ` [PATCH net-next 3/8] dsa: Add mdio device support to Marvell switches Andrew Lunn
2016-04-13 23:59 ` [PATCH net-next 4/8] dsa: Move gpio reset into switch driver Andrew Lunn
2016-04-14 2:03 ` David Miller
2016-04-13 23:59 ` [PATCH net-next 5/8] dsa: mv88e6xxx: Kill the REG_READ and REG_WRITE macros Andrew Lunn
2016-04-14 14:54 ` Vivien Didelot
2016-04-13 23:59 ` [PATCH net-next 6/8] dsa: mv88e6xxx: Replace ds with ps where possible Andrew Lunn
2016-04-13 23:59 ` [PATCH net-next 7/8] dsa: mv88e6xxx: Use the name table to determine number of ports Andrew Lunn
2016-04-13 23:59 ` [PATCH net-next 8/8] dsa: mv88e6131: Don't special case a single device Andrew Lunn
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=1460591998-20598-3-git-send-email-andrew@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.com \
/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).