Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Rene Herman | a5117ba7 | 2006-06-06 23:54:02 +0200 | [diff] [blame] | 2 | /* |
| 3 | * ISA bus. |
| 4 | */ |
| 5 | |
| 6 | #ifndef __LINUX_ISA_H |
| 7 | #define __LINUX_ISA_H |
| 8 | |
| 9 | #include <linux/device.h> |
William Breathitt Gray | 5e25db8 | 2016-05-09 09:39:50 -0400 | [diff] [blame] | 10 | #include <linux/errno.h> |
Rene Herman | a5117ba7 | 2006-06-06 23:54:02 +0200 | [diff] [blame] | 11 | #include <linux/kernel.h> |
| 12 | |
| 13 | struct isa_driver { |
| 14 | int (*match)(struct device *, unsigned int); |
| 15 | int (*probe)(struct device *, unsigned int); |
| 16 | int (*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); |
| 20 | |
| 21 | struct device_driver driver; |
| 22 | struct device *devices; |
| 23 | }; |
| 24 | |
| 25 | #define to_isa_driver(x) container_of((x), struct isa_driver, driver) |
| 26 | |
William Breathitt Gray | 3a49551 | 2016-05-27 18:08:27 -0400 | [diff] [blame] | 27 | #ifdef CONFIG_ISA_BUS_API |
Rene Herman | a5117ba7 | 2006-06-06 23:54:02 +0200 | [diff] [blame] | 28 | int isa_register_driver(struct isa_driver *, unsigned int); |
| 29 | void isa_unregister_driver(struct isa_driver *); |
Matthew Wilcox | fa890d5 | 2007-09-16 17:01:26 -0600 | [diff] [blame] | 30 | #else |
| 31 | static inline int isa_register_driver(struct isa_driver *d, unsigned int i) |
| 32 | { |
William Breathitt Gray | 5e25db8 | 2016-05-09 09:39:50 -0400 | [diff] [blame] | 33 | return -ENODEV; |
Matthew Wilcox | fa890d5 | 2007-09-16 17:01:26 -0600 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | static inline void isa_unregister_driver(struct isa_driver *d) |
| 37 | { |
| 38 | } |
| 39 | #endif |
Rene Herman | a5117ba7 | 2006-06-06 23:54:02 +0200 | [diff] [blame] | 40 | |
William Breathitt Gray | 339e6e3 | 2016-05-01 18:42:47 -0400 | [diff] [blame] | 41 | /** |
| 42 | * module_isa_driver() - Helper macro for registering a ISA driver |
| 43 | * @__isa_driver: isa_driver struct |
| 44 | * @__num_isa_dev: number of devices to register |
| 45 | * |
| 46 | * Helper macro for ISA drivers which do not do anything special in module |
| 47 | * init/exit. This eliminates a lot of boilerplate code. Each module may only |
| 48 | * use this macro once, and calling it replaces module_init and module_exit. |
| 49 | */ |
| 50 | #define module_isa_driver(__isa_driver, __num_isa_dev) \ |
| 51 | static int __init __isa_driver##_init(void) \ |
| 52 | { \ |
| 53 | return isa_register_driver(&(__isa_driver), __num_isa_dev); \ |
| 54 | } \ |
| 55 | module_init(__isa_driver##_init); \ |
| 56 | static void __exit __isa_driver##_exit(void) \ |
| 57 | { \ |
| 58 | isa_unregister_driver(&(__isa_driver)); \ |
| 59 | } \ |
| 60 | module_exit(__isa_driver##_exit); |
| 61 | |
William Breathitt Gray | d9a9c61 | 2016-05-01 18:43:10 -0400 | [diff] [blame] | 62 | /** |
| 63 | * max_num_isa_dev() - Maximum possible number registered of an ISA device |
| 64 | * @__ida_dev_ext: ISA device address extent |
| 65 | * |
| 66 | * The highest base address possible for an ISA device is 0x3FF; this results in |
| 67 | * 1024 possible base addresses. Dividing the number of possible base addresses |
| 68 | * by the address extent taken by each device results in the maximum number of |
| 69 | * devices on a system. |
| 70 | */ |
| 71 | #define max_num_isa_dev(__isa_dev_ext) (1024 / __isa_dev_ext) |
| 72 | |
Rene Herman | a5117ba7 | 2006-06-06 23:54:02 +0200 | [diff] [blame] | 73 | #endif /* __LINUX_ISA_H */ |