summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Breathitt Gray <vilhelm.gray@gmail.com>2016-05-01 18:42:47 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-05-02 09:32:04 -0700
commit339e6e31d2bfb40354cbfe672b357b88a88223f2 (patch)
treee15090dc5916ea254e73097adc7f04c3a157b2b3
parent0619f39474b991244d0a2cbd323915c0e6167b5a (diff)
downloadop-kernel-dev-339e6e31d2bfb40354cbfe672b357b88a88223f2.zip
op-kernel-dev-339e6e31d2bfb40354cbfe672b357b88a88223f2.tar.gz
isa: Implement the module_isa_driver macro
The module_isa_driver macro is a helper macro for ISA drivers which do not do anything special in module init/exit. This eliminates a lot of boilerplate code. Each module may only use this macro once, and calling it replaces module_init and module_exit. Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/linux/isa.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/isa.h b/include/linux/isa.h
index b0270e3..e394917 100644
--- a/include/linux/isa.h
+++ b/include/linux/isa.h
@@ -36,4 +36,25 @@ static inline void isa_unregister_driver(struct isa_driver *d)
}
#endif
+/**
+ * module_isa_driver() - Helper macro for registering a ISA driver
+ * @__isa_driver: isa_driver struct
+ * @__num_isa_dev: number of devices to register
+ *
+ * Helper macro for ISA drivers which do not do anything special in module
+ * init/exit. This eliminates a lot of boilerplate code. Each module may only
+ * use this macro once, and calling it replaces module_init and module_exit.
+ */
+#define module_isa_driver(__isa_driver, __num_isa_dev) \
+static int __init __isa_driver##_init(void) \
+{ \
+ return isa_register_driver(&(__isa_driver), __num_isa_dev); \
+} \
+module_init(__isa_driver##_init); \
+static void __exit __isa_driver##_exit(void) \
+{ \
+ isa_unregister_driver(&(__isa_driver)); \
+} \
+module_exit(__isa_driver##_exit);
+
#endif /* __LINUX_ISA_H */
OpenPOWER on IntegriCloud