blob: f2d0258414cfef9a98384f3c59d691f387ef5862 [file] [log] [blame]
Rene Hermana5117ba72006-06-06 23:54:02 +02001/*
2 * ISA bus.
3 */
4
5#ifndef __LINUX_ISA_H
6#define __LINUX_ISA_H
7
8#include <linux/device.h>
William Breathitt Gray5e25db82016-05-09 09:39:50 -04009#include <linux/errno.h>
Rene Hermana5117ba72006-06-06 23:54:02 +020010#include <linux/kernel.h>
11
12struct isa_driver {
13 int (*match)(struct device *, unsigned int);
14 int (*probe)(struct device *, unsigned int);
15 int (*remove)(struct device *, unsigned int);
16 void (*shutdown)(struct device *, unsigned int);
17 int (*suspend)(struct device *, unsigned int, pm_message_t);
18 int (*resume)(struct device *, unsigned int);
19
20 struct device_driver driver;
21 struct device *devices;
22};
23
24#define to_isa_driver(x) container_of((x), struct isa_driver, driver)
25
William Breathitt Gray3a495512016-05-27 18:08:27 -040026#ifdef CONFIG_ISA_BUS_API
Rene Hermana5117ba72006-06-06 23:54:02 +020027int isa_register_driver(struct isa_driver *, unsigned int);
28void isa_unregister_driver(struct isa_driver *);
Matthew Wilcoxfa890d52007-09-16 17:01:26 -060029#else
30static inline int isa_register_driver(struct isa_driver *d, unsigned int i)
31{
William Breathitt Gray5e25db82016-05-09 09:39:50 -040032 return -ENODEV;
Matthew Wilcoxfa890d52007-09-16 17:01:26 -060033}
34
35static inline void isa_unregister_driver(struct isa_driver *d)
36{
37}
38#endif
Rene Hermana5117ba72006-06-06 23:54:02 +020039
William Breathitt Gray339e6e32016-05-01 18:42:47 -040040/**
41 * module_isa_driver() - Helper macro for registering a ISA driver
42 * @__isa_driver: isa_driver struct
43 * @__num_isa_dev: number of devices to register
44 *
45 * Helper macro for ISA drivers which do not do anything special in module
46 * init/exit. This eliminates a lot of boilerplate code. Each module may only
47 * use this macro once, and calling it replaces module_init and module_exit.
48 */
49#define module_isa_driver(__isa_driver, __num_isa_dev) \
50static int __init __isa_driver##_init(void) \
51{ \
52 return isa_register_driver(&(__isa_driver), __num_isa_dev); \
53} \
54module_init(__isa_driver##_init); \
55static void __exit __isa_driver##_exit(void) \
56{ \
57 isa_unregister_driver(&(__isa_driver)); \
58} \
59module_exit(__isa_driver##_exit);
60
William Breathitt Grayd9a9c612016-05-01 18:43:10 -040061/**
62 * max_num_isa_dev() - Maximum possible number registered of an ISA device
63 * @__ida_dev_ext: ISA device address extent
64 *
65 * The highest base address possible for an ISA device is 0x3FF; this results in
66 * 1024 possible base addresses. Dividing the number of possible base addresses
67 * by the address extent taken by each device results in the maximum number of
68 * devices on a system.
69 */
70#define max_num_isa_dev(__isa_dev_ext) (1024 / __isa_dev_ext)
71
Rene Hermana5117ba72006-06-06 23:54:02 +020072#endif /* __LINUX_ISA_H */