1 /* SPDX-License-Identifier: GPL-2.0 */
9 #include <linux/device.h>
10 #include <linux/errno.h>
11 #include <linux/kernel.h>
14 int (*match)(struct device *, unsigned int);
15 int (*probe)(struct device *, unsigned int);
16 void (*remove)(struct device *, unsigned int);
17 void (*shutdown)(struct device *, unsigned int);
18 int (*suspend)(struct device *, unsigned int, pm_message_t);
19 int (*resume)(struct device *, unsigned int);
21 struct device_driver driver;
22 struct device *devices;
25 #define to_isa_driver(x) container_of((x), struct isa_driver, driver)
27 #ifdef CONFIG_ISA_BUS_API
28 int isa_register_driver(struct isa_driver *, unsigned int);
29 void isa_unregister_driver(struct isa_driver *);
31 static inline int isa_register_driver(struct isa_driver *d, unsigned int i)
36 static inline void isa_unregister_driver(struct isa_driver *d)
41 #define module_isa_driver_init(__isa_driver, __num_isa_dev) \
42 static int __init __isa_driver##_init(void) \
44 return isa_register_driver(&(__isa_driver), __num_isa_dev); \
46 module_init(__isa_driver##_init)
48 #define module_isa_driver_with_irq_init(__isa_driver, __num_isa_dev, __num_irq) \
49 static int __init __isa_driver##_init(void) \
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); \
56 return isa_register_driver(&(__isa_driver), __num_isa_dev); \
58 module_init(__isa_driver##_init)
60 #define module_isa_driver_exit(__isa_driver) \
61 static void __exit __isa_driver##_exit(void) \
63 isa_unregister_driver(&(__isa_driver)); \
65 module_exit(__isa_driver##_exit)
68 * module_isa_driver() - Helper macro for registering a ISA driver
69 * @__isa_driver: isa_driver struct
70 * @__num_isa_dev: number of devices to register
72 * Helper macro for ISA drivers which do not do anything special in module
73 * init/exit. This eliminates a lot of boilerplate code. Each module may only
74 * use this macro once, and calling it replaces module_init and module_exit.
76 #define module_isa_driver(__isa_driver, __num_isa_dev) \
77 module_isa_driver_init(__isa_driver, __num_isa_dev); \
78 module_isa_driver_exit(__isa_driver)
81 * module_isa_driver_with_irq() - Helper macro for registering an ISA driver with irq
82 * @__isa_driver: isa_driver struct
83 * @__num_isa_dev: number of devices to register
84 * @__num_irq: number of IRQ to register
86 * Helper macro for ISA drivers with irq that do not do anything special in
87 * module init/exit. Each module may only use this macro once, and calling it
88 * replaces module_init and module_exit.
90 #define module_isa_driver_with_irq(__isa_driver, __num_isa_dev, __num_irq) \
91 module_isa_driver_with_irq_init(__isa_driver, __num_isa_dev, __num_irq); \
92 module_isa_driver_exit(__isa_driver)
95 * max_num_isa_dev() - Maximum possible number registered of an ISA device
96 * @__ida_dev_ext: ISA device address extent
98 * The highest base address possible for an ISA device is 0x3FF; this results in
99 * 1024 possible base addresses. Dividing the number of possible base addresses
100 * by the address extent taken by each device results in the maximum number of
101 * devices on a system.
103 #define max_num_isa_dev(__isa_dev_ext) (1024 / __isa_dev_ext)
105 #endif /* __LINUX_ISA_H */