Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

isa: Introduce the module_isa_driver_with_irq helper macro

Several ISA drivers feature IRQ support that can configured via an "irq"
array module parameter. This array typically matches directly with the
respective "base" array module parameter. To reduce code repetition, a
module_isa_driver_with_irq helper macro is introduced to provide a check
ensuring that the number of "irq" passed to the module matches with the
respective number of "base".

Signed-off-by: William Breathitt Gray <william.gray@linaro.org>
Acked-by: William Breathitt Gray <william.gray@linaro.org>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>

authored by

William Breathitt Gray and committed by
Bartosz Golaszewski
85ebe0af 13c5d4ce

+42 -10
+42 -10
include/linux/isa.h
··· 38 38 } 39 39 #endif 40 40 41 + #define module_isa_driver_init(__isa_driver, __num_isa_dev) \ 42 + static int __init __isa_driver##_init(void) \ 43 + { \ 44 + return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 45 + } \ 46 + module_init(__isa_driver##_init) 47 + 48 + #define module_isa_driver_with_irq_init(__isa_driver, __num_isa_dev, __num_irq) \ 49 + static int __init __isa_driver##_init(void) \ 50 + { \ 51 + if (__num_irq != __num_isa_dev) { \ 52 + pr_err("%s: Number of irq (%u) does not match number of base (%u)\n", \ 53 + __isa_driver.driver.name, __num_irq, __num_isa_dev); \ 54 + return -EINVAL; \ 55 + } \ 56 + return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 57 + } \ 58 + module_init(__isa_driver##_init) 59 + 60 + #define module_isa_driver_exit(__isa_driver) \ 61 + static void __exit __isa_driver##_exit(void) \ 62 + { \ 63 + isa_unregister_driver(&(__isa_driver)); \ 64 + } \ 65 + module_exit(__isa_driver##_exit) 66 + 41 67 /** 42 68 * module_isa_driver() - Helper macro for registering a ISA driver 43 69 * @__isa_driver: isa_driver struct ··· 74 48 * use this macro once, and calling it replaces module_init and module_exit. 75 49 */ 76 50 #define module_isa_driver(__isa_driver, __num_isa_dev) \ 77 - static int __init __isa_driver##_init(void) \ 78 - { \ 79 - return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 80 - } \ 81 - module_init(__isa_driver##_init); \ 82 - static void __exit __isa_driver##_exit(void) \ 83 - { \ 84 - isa_unregister_driver(&(__isa_driver)); \ 85 - } \ 86 - module_exit(__isa_driver##_exit); 51 + module_isa_driver_init(__isa_driver, __num_isa_dev); \ 52 + module_isa_driver_exit(__isa_driver) 53 + 54 + /** 55 + * module_isa_driver_with_irq() - Helper macro for registering an ISA driver with irq 56 + * @__isa_driver: isa_driver struct 57 + * @__num_isa_dev: number of devices to register 58 + * @__num_irq: number of IRQ to register 59 + * 60 + * Helper macro for ISA drivers with irq that do not do anything special in 61 + * module init/exit. Each module may only use this macro once, and calling it 62 + * replaces module_init and module_exit. 63 + */ 64 + #define module_isa_driver_with_irq(__isa_driver, __num_isa_dev, __num_irq) \ 65 + module_isa_driver_with_irq_init(__isa_driver, __num_isa_dev, __num_irq); \ 66 + module_isa_driver_exit(__isa_driver) 87 67 88 68 /** 89 69 * max_num_isa_dev() - Maximum possible number registered of an ISA device