aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2014-11-11 13:45:57 -0500
committerDavid S. Miller <davem@davemloft.net>2014-11-12 13:52:52 -0500
commitc31accd159a6477b91de61ae237dce38e3f3ee4d (patch)
tree37a681381ffda08039093d41585516bdbd265aea
parentc647cc3fd5ee3c3aba34a00326e684684d491de0 (diff)
net: phy: add module_phy_driver macro
Add helper macro for PHY drivers which do not do anything special in module init/exit. This will allow us to eliminate a lot of boilerplate code. Signed-off-by: Johan Hovold <johan@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/phy.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/phy.h b/include/linux/phy.h
index d090cfcaa167..07794e720139 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -772,4 +772,28 @@ int __init mdio_bus_init(void);
772void mdio_bus_exit(void); 772void mdio_bus_exit(void);
773 773
774extern struct bus_type mdio_bus_type; 774extern struct bus_type mdio_bus_type;
775
776/**
777 * module_phy_driver() - Helper macro for registering PHY drivers
778 * @__phy_drivers: array of PHY drivers to register
779 *
780 * Helper macro for PHY drivers which do not do anything special in module
781 * init/exit. Each module may only use this macro once, and calling it
782 * replaces module_init() and module_exit().
783 */
784#define phy_module_driver(__phy_drivers, __count) \
785static int __init phy_module_init(void) \
786{ \
787 return phy_drivers_register(__phy_drivers, __count); \
788} \
789module_init(phy_module_init); \
790static void __exit phy_module_exit(void) \
791{ \
792 phy_drivers_unregister(__phy_drivers, __count); \
793} \
794module_exit(phy_module_exit)
795
796#define module_phy_driver(__phy_drivers) \
797 phy_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers))
798
775#endif /* __PHY_H */ 799#endif /* __PHY_H */