diff options
author | Johan Hovold <johan@kernel.org> | 2014-11-11 21:45:57 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-12 21:52:52 +0300 |
commit | c31accd159a6477b91de61ae237dce38e3f3ee4d (patch) | |
tree | 37a681381ffda08039093d41585516bdbd265aea /include/linux/phy.h | |
parent | c647cc3fd5ee3c3aba34a00326e684684d491de0 (diff) | |
download | linux-c31accd159a6477b91de61ae237dce38e3f3ee4d.tar.xz |
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>
Diffstat (limited to 'include/linux/phy.h')
-rw-r--r-- | include/linux/phy.h | 24 |
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); void mdio_bus_exit(void); extern struct bus_type mdio_bus_type; + +/** + * module_phy_driver() - Helper macro for registering PHY drivers + * @__phy_drivers: array of PHY drivers to register + * + * Helper macro for PHY 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 phy_module_driver(__phy_drivers, __count) \ +static int __init phy_module_init(void) \ +{ \ + return phy_drivers_register(__phy_drivers, __count); \ +} \ +module_init(phy_module_init); \ +static void __exit phy_module_exit(void) \ +{ \ + phy_drivers_unregister(__phy_drivers, __count); \ +} \ +module_exit(phy_module_exit) + +#define module_phy_driver(__phy_drivers) \ + phy_module_driver(__phy_drivers, ARRAY_SIZE(__phy_drivers)) + #endif /* __PHY_H */ |