diff options
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2011-07-25 20:13:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 23:57:14 -0400 |
commit | a0e44d4a7a3935afe425ec8dd1a5b63895e1f9c3 (patch) | |
tree | ef31b7fe165d9777e93beacb191adbef280c21b6 | |
parent | ae891a1b93bf62e9aaa116a7a71312375047fc9f (diff) |
include/linux/ioport.h: new helper to define common struct resource constructs
Resource definitions that just define start, end and flags =
IORESOURCE_MEM or IORESOURCE_IRQ (with start=end) are quite common. So
introduce a shortcut for them. For completeness add macros for
IORESOURCE_DMA and IORESOURCE_IO, too and also make available a set of
macros to specify named resources of all types which are less common.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/ioport.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/include/linux/ioport.h b/include/linux/ioport.h index e9bb22cba764..c2ebfe66177c 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h | |||
@@ -109,6 +109,36 @@ struct resource_list { | |||
109 | /* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */ | 109 | /* PCI control bits. Shares IORESOURCE_BITS with above PCI ROM. */ |
110 | #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */ | 110 | #define IORESOURCE_PCI_FIXED (1<<4) /* Do not move resource */ |
111 | 111 | ||
112 | |||
113 | /* helpers to define resources */ | ||
114 | #define DEFINE_RES_NAMED(_start, _size, _name, _flags) \ | ||
115 | { \ | ||
116 | .start = (_start), \ | ||
117 | .end = (_start) + (_size) - 1, \ | ||
118 | .name = (_name), \ | ||
119 | .flags = (_flags), \ | ||
120 | } | ||
121 | |||
122 | #define DEFINE_RES_IO_NAMED(_start, _size, _name) \ | ||
123 | DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_IO) | ||
124 | #define DEFINE_RES_IO(_start, _size) \ | ||
125 | DEFINE_RES_IO_NAMED((_start), (_size), NULL) | ||
126 | |||
127 | #define DEFINE_RES_MEM_NAMED(_start, _size, _name) \ | ||
128 | DEFINE_RES_NAMED((_start), (_size), (_name), IORESOURCE_MEM) | ||
129 | #define DEFINE_RES_MEM(_start, _size) \ | ||
130 | DEFINE_RES_MEM_NAMED((_start), (_size), NULL) | ||
131 | |||
132 | #define DEFINE_RES_IRQ_NAMED(_irq, _name) \ | ||
133 | DEFINE_RES_NAMED((_irq), 1, (_name), IORESOURCE_IRQ) | ||
134 | #define DEFINE_RES_IRQ(_irq) \ | ||
135 | DEFINE_RES_IRQ_NAMED((_irq), NULL) | ||
136 | |||
137 | #define DEFINE_RES_DMA_NAMED(_dma, _name) \ | ||
138 | DEFINE_RES_NAMED((_dma), 1, (_name), IORESOURCE_DMA) | ||
139 | #define DEFINE_RES_DMA(_dma) \ | ||
140 | DEFINE_RES_DMA_NAMED((_dma), NULL) | ||
141 | |||
112 | /* PC/ISA/whatever - the normal PC address spaces: IO and memory */ | 142 | /* PC/ISA/whatever - the normal PC address spaces: IO and memory */ |
113 | extern struct resource ioport_resource; | 143 | extern struct resource ioport_resource; |
114 | extern struct resource iomem_resource; | 144 | extern struct resource iomem_resource; |