1 /* SPDX-License-Identifier: GPL-2.0 */ 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 2 /* 3 * ISA bus. 3 * ISA bus. 4 */ 4 */ 5 5 6 #ifndef __LINUX_ISA_H 6 #ifndef __LINUX_ISA_H 7 #define __LINUX_ISA_H 7 #define __LINUX_ISA_H 8 8 9 #include <linux/device.h> 9 #include <linux/device.h> 10 #include <linux/errno.h> 10 #include <linux/errno.h> 11 #include <linux/kernel.h> 11 #include <linux/kernel.h> 12 12 13 struct isa_driver { 13 struct isa_driver { 14 int (*match)(struct device *, unsigned 14 int (*match)(struct device *, unsigned int); 15 int (*probe)(struct device *, unsigned 15 int (*probe)(struct device *, unsigned int); 16 void (*remove)(struct device *, unsign 16 void (*remove)(struct device *, unsigned int); 17 void (*shutdown)(struct device *, unsi 17 void (*shutdown)(struct device *, unsigned int); 18 int (*suspend)(struct device *, unsign 18 int (*suspend)(struct device *, unsigned int, pm_message_t); 19 int (*resume)(struct device *, unsigne 19 int (*resume)(struct device *, unsigned int); 20 20 21 struct device_driver driver; 21 struct device_driver driver; 22 struct device *devices; 22 struct device *devices; 23 }; 23 }; 24 24 25 #define to_isa_driver(x) container_of((x), str 25 #define to_isa_driver(x) container_of((x), struct isa_driver, driver) 26 26 27 #ifdef CONFIG_ISA_BUS_API 27 #ifdef CONFIG_ISA_BUS_API 28 int isa_register_driver(struct isa_driver *, u 28 int isa_register_driver(struct isa_driver *, unsigned int); 29 void isa_unregister_driver(struct isa_driver * 29 void isa_unregister_driver(struct isa_driver *); 30 #else 30 #else 31 static inline int isa_register_driver(struct i 31 static inline int isa_register_driver(struct isa_driver *d, unsigned int i) 32 { 32 { 33 return -ENODEV; 33 return -ENODEV; 34 } 34 } 35 35 36 static inline void isa_unregister_driver(struc 36 static inline void isa_unregister_driver(struct isa_driver *d) 37 { 37 { 38 } 38 } 39 #endif 39 #endif 40 40 41 #define module_isa_driver_init(__isa_driver, _ << 42 static int __init __isa_driver##_init(void) \ << 43 { \ << 44 return isa_register_driver(&(__isa_dri << 45 } \ << 46 module_init(__isa_driver##_init) << 47 << 48 #define module_isa_driver_with_irq_init(__isa_ << 49 static int __init __isa_driver##_init(void) \ << 50 { \ << 51 if (__num_irq != __num_isa_dev) { \ << 52 pr_err("%s: Number of irq (%u) << 53 __isa_driver.driver.nam << 54 return -EINVAL; \ << 55 } \ << 56 return isa_register_driver(&(__isa_dri << 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 << 67 /** 41 /** 68 * module_isa_driver() - Helper macro for regi 42 * module_isa_driver() - Helper macro for registering a ISA driver 69 * @__isa_driver: isa_driver struct 43 * @__isa_driver: isa_driver struct 70 * @__num_isa_dev: number of devices to regist 44 * @__num_isa_dev: number of devices to register 71 * 45 * 72 * Helper macro for ISA drivers which do not d 46 * Helper macro for ISA drivers which do not do anything special in module 73 * init/exit. This eliminates a lot of boilerp 47 * init/exit. This eliminates a lot of boilerplate code. Each module may only 74 * use this macro once, and calling it replace 48 * use this macro once, and calling it replaces module_init and module_exit. 75 */ 49 */ 76 #define module_isa_driver(__isa_driver, __num_ 50 #define module_isa_driver(__isa_driver, __num_isa_dev) \ 77 module_isa_driver_init(__isa_driver, __num_isa !! 51 static int __init __isa_driver##_init(void) \ 78 module_isa_driver_exit(__isa_driver) !! 52 { \ 79 !! 53 return isa_register_driver(&(__isa_driver), __num_isa_dev); \ 80 /** !! 54 } \ 81 * module_isa_driver_with_irq() - Helper macro !! 55 module_init(__isa_driver##_init); \ 82 * @__isa_driver: isa_driver struct !! 56 static void __exit __isa_driver##_exit(void) \ 83 * @__num_isa_dev: number of devices to regist !! 57 { \ 84 * @__num_irq: number of IRQ to register !! 58 isa_unregister_driver(&(__isa_driver)); \ 85 * !! 59 } \ 86 * Helper macro for ISA drivers with irq that !! 60 module_exit(__isa_driver##_exit); 87 * module init/exit. Each module may only use << 88 * replaces module_init and module_exit. << 89 */ << 90 #define module_isa_driver_with_irq(__isa_drive << 91 module_isa_driver_with_irq_init(__isa_driver, << 92 module_isa_driver_exit(__isa_driver) << 93 61 94 /** 62 /** 95 * max_num_isa_dev() - Maximum possible number 63 * max_num_isa_dev() - Maximum possible number registered of an ISA device 96 * @__ida_dev_ext: ISA device address extent 64 * @__ida_dev_ext: ISA device address extent 97 * 65 * 98 * The highest base address possible for an IS 66 * The highest base address possible for an ISA device is 0x3FF; this results in 99 * 1024 possible base addresses. Dividing the 67 * 1024 possible base addresses. Dividing the number of possible base addresses 100 * by the address extent taken by each device 68 * by the address extent taken by each device results in the maximum number of 101 * devices on a system. 69 * devices on a system. 102 */ 70 */ 103 #define max_num_isa_dev(__isa_dev_ext) (1024 / 71 #define max_num_isa_dev(__isa_dev_ext) (1024 / __isa_dev_ext) 104 72 105 #endif /* __LINUX_ISA_H */ 73 #endif /* __LINUX_ISA_H */ 106 74
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.