Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * manager.c - Resource Management, Conflict Resolution, Activation and Disabling of Devices |
| 3 | * |
Jaroslav Kysela | c1017a4 | 2007-10-15 09:50:19 +0200 | [diff] [blame] | 4 | * based on isapnp.c resource management (c) Jaroslav Kysela <perex@perex.cz> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * Copyright 2003 Adam Belay <ambx1@neo.rr.com> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | #include <linux/errno.h> |
| 9 | #include <linux/module.h> |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/pnp.h> |
Tim Schmielau | 4e57b68 | 2005-10-30 15:03:48 -0800 | [diff] [blame] | 13 | #include <linux/slab.h> |
| 14 | #include <linux/bitmap.h> |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 15 | #include <linux/mutex.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include "base.h" |
| 17 | |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 18 | DEFINE_MUTEX(pnp_res_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) |
| 21 | { |
Greg Kroah-Hartman | b60ba83 | 2006-06-12 17:07:07 -0700 | [diff] [blame] | 22 | resource_size_t *start, *end; |
| 23 | unsigned long *flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | if (idx >= PNP_MAX_PORT) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 26 | dev_err(&dev->dev, "too many I/O port resources\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | /* pretend we were successful so at least the manager won't try again */ |
| 28 | return 1; |
| 29 | } |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | start = &dev->res.port_resource[idx].start; |
| 32 | end = &dev->res.port_resource[idx].end; |
| 33 | flags = &dev->res.port_resource[idx].flags; |
| 34 | |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 35 | /* check if this resource has been manually set, if so skip */ |
| 36 | if (!(dev->res.port_resource[idx].flags & IORESOURCE_AUTO)) { |
| 37 | dev_dbg(&dev->dev, " io %d already set to %#llx-%#llx " |
| 38 | "flags %#lx\n", idx, (unsigned long long) *start, |
| 39 | (unsigned long long) *end, *flags); |
| 40 | return 1; |
| 41 | } |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | /* set the initial values */ |
| 44 | *flags |= rule->flags | IORESOURCE_IO; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 45 | *flags &= ~IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | if (!rule->size) { |
| 48 | *flags |= IORESOURCE_DISABLED; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 49 | dev_dbg(&dev->dev, " io %d disabled\n", idx); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 50 | return 1; /* skip disabled resource requests */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | *start = rule->min; |
| 54 | *end = *start + rule->size - 1; |
| 55 | |
| 56 | /* run through until pnp_check_port is happy */ |
| 57 | while (!pnp_check_port(dev, idx)) { |
| 58 | *start += rule->align; |
| 59 | *end = *start + rule->size - 1; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 60 | if (*start > rule->max || !rule->align) { |
| 61 | dev_dbg(&dev->dev, " couldn't assign io %d\n", idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | return 0; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 63 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | } |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 65 | dev_dbg(&dev->dev, " assign io %d %#llx-%#llx\n", idx, |
| 66 | (unsigned long long) *start, (unsigned long long) *end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | return 1; |
| 68 | } |
| 69 | |
| 70 | static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx) |
| 71 | { |
Greg Kroah-Hartman | b60ba83 | 2006-06-12 17:07:07 -0700 | [diff] [blame] | 72 | resource_size_t *start, *end; |
| 73 | unsigned long *flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | if (idx >= PNP_MAX_MEM) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 76 | dev_err(&dev->dev, "too many memory resources\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | /* pretend we were successful so at least the manager won't try again */ |
| 78 | return 1; |
| 79 | } |
| 80 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | start = &dev->res.mem_resource[idx].start; |
| 82 | end = &dev->res.mem_resource[idx].end; |
| 83 | flags = &dev->res.mem_resource[idx].flags; |
| 84 | |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 85 | /* check if this resource has been manually set, if so skip */ |
| 86 | if (!(dev->res.mem_resource[idx].flags & IORESOURCE_AUTO)) { |
| 87 | dev_dbg(&dev->dev, " mem %d already set to %#llx-%#llx " |
| 88 | "flags %#lx\n", idx, (unsigned long long) *start, |
| 89 | (unsigned long long) *end, *flags); |
| 90 | return 1; |
| 91 | } |
| 92 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | /* set the initial values */ |
| 94 | *flags |= rule->flags | IORESOURCE_MEM; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 95 | *flags &= ~IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* convert pnp flags to standard Linux flags */ |
| 98 | if (!(rule->flags & IORESOURCE_MEM_WRITEABLE)) |
| 99 | *flags |= IORESOURCE_READONLY; |
| 100 | if (rule->flags & IORESOURCE_MEM_CACHEABLE) |
| 101 | *flags |= IORESOURCE_CACHEABLE; |
| 102 | if (rule->flags & IORESOURCE_MEM_RANGELENGTH) |
| 103 | *flags |= IORESOURCE_RANGELENGTH; |
| 104 | if (rule->flags & IORESOURCE_MEM_SHADOWABLE) |
| 105 | *flags |= IORESOURCE_SHADOWABLE; |
| 106 | |
| 107 | if (!rule->size) { |
| 108 | *flags |= IORESOURCE_DISABLED; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 109 | dev_dbg(&dev->dev, " mem %d disabled\n", idx); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 110 | return 1; /* skip disabled resource requests */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | *start = rule->min; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 114 | *end = *start + rule->size - 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | /* run through until pnp_check_mem is happy */ |
| 117 | while (!pnp_check_mem(dev, idx)) { |
| 118 | *start += rule->align; |
| 119 | *end = *start + rule->size - 1; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 120 | if (*start > rule->max || !rule->align) { |
| 121 | dev_dbg(&dev->dev, " couldn't assign mem %d\n", idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | return 0; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 123 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | } |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 125 | dev_dbg(&dev->dev, " assign mem %d %#llx-%#llx\n", idx, |
| 126 | (unsigned long long) *start, (unsigned long long) *end); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | return 1; |
| 128 | } |
| 129 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 130 | static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
Greg Kroah-Hartman | b60ba83 | 2006-06-12 17:07:07 -0700 | [diff] [blame] | 132 | resource_size_t *start, *end; |
| 133 | unsigned long *flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | int i; |
| 135 | |
| 136 | /* IRQ priority: this table is good for i386 */ |
| 137 | static unsigned short xtab[16] = { |
| 138 | 5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2 |
| 139 | }; |
| 140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | if (idx >= PNP_MAX_IRQ) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 142 | dev_err(&dev->dev, "too many IRQ resources\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | /* pretend we were successful so at least the manager won't try again */ |
| 144 | return 1; |
| 145 | } |
| 146 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | start = &dev->res.irq_resource[idx].start; |
| 148 | end = &dev->res.irq_resource[idx].end; |
| 149 | flags = &dev->res.irq_resource[idx].flags; |
| 150 | |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 151 | /* check if this resource has been manually set, if so skip */ |
| 152 | if (!(dev->res.irq_resource[idx].flags & IORESOURCE_AUTO)) { |
| 153 | dev_dbg(&dev->dev, " irq %d already set to %d flags %#lx\n", |
| 154 | idx, (int) *start, *flags); |
| 155 | return 1; |
| 156 | } |
| 157 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | /* set the initial values */ |
| 159 | *flags |= rule->flags | IORESOURCE_IRQ; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 160 | *flags &= ~IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | |
| 162 | if (bitmap_empty(rule->map, PNP_IRQ_NR)) { |
| 163 | *flags |= IORESOURCE_DISABLED; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 164 | dev_dbg(&dev->dev, " irq %d disabled\n", idx); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 165 | return 1; /* skip disabled resource requests */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /* TBD: need check for >16 IRQ */ |
| 169 | *start = find_next_bit(rule->map, PNP_IRQ_NR, 16); |
| 170 | if (*start < PNP_IRQ_NR) { |
| 171 | *end = *start; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 172 | dev_dbg(&dev->dev, " assign irq %d %d\n", idx, (int) *start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | return 1; |
| 174 | } |
| 175 | for (i = 0; i < 16; i++) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 176 | if (test_bit(xtab[i], rule->map)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | *start = *end = xtab[i]; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 178 | if (pnp_check_irq(dev, idx)) { |
| 179 | dev_dbg(&dev->dev, " assign irq %d %d\n", idx, |
| 180 | (int) *start); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | return 1; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 182 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | } |
| 184 | } |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 185 | dev_dbg(&dev->dev, " couldn't assign irq %d\n", idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | return 0; |
| 187 | } |
| 188 | |
Jan Beulich | 7ef3639 | 2007-10-16 23:31:07 -0700 | [diff] [blame] | 189 | static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | { |
Greg Kroah-Hartman | b60ba83 | 2006-06-12 17:07:07 -0700 | [diff] [blame] | 191 | resource_size_t *start, *end; |
| 192 | unsigned long *flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | int i; |
| 194 | |
| 195 | /* DMA priority: this table is good for i386 */ |
| 196 | static unsigned short xtab[8] = { |
| 197 | 1, 3, 5, 6, 7, 0, 2, 4 |
| 198 | }; |
| 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | if (idx >= PNP_MAX_DMA) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 201 | dev_err(&dev->dev, "too many DMA resources\n"); |
Jan Beulich | 7ef3639 | 2007-10-16 23:31:07 -0700 | [diff] [blame] | 202 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | start = &dev->res.dma_resource[idx].start; |
| 206 | end = &dev->res.dma_resource[idx].end; |
| 207 | flags = &dev->res.dma_resource[idx].flags; |
| 208 | |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 209 | /* check if this resource has been manually set, if so skip */ |
| 210 | if (!(dev->res.dma_resource[idx].flags & IORESOURCE_AUTO)) { |
| 211 | dev_dbg(&dev->dev, " dma %d already set to %d flags %#lx\n", |
| 212 | idx, (int) *start, *flags); |
| 213 | return; |
| 214 | } |
| 215 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | /* set the initial values */ |
| 217 | *flags |= rule->flags | IORESOURCE_DMA; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 218 | *flags &= ~IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 219 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | for (i = 0; i < 8; i++) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 221 | if (rule->map & (1 << xtab[i])) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | *start = *end = xtab[i]; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 223 | if (pnp_check_dma(dev, idx)) { |
| 224 | dev_dbg(&dev->dev, " assign dma %d %d\n", idx, |
| 225 | (int) *start); |
Jan Beulich | 7ef3639 | 2007-10-16 23:31:07 -0700 | [diff] [blame] | 226 | return; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 227 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | } |
| 229 | } |
Jan Beulich | 7ef3639 | 2007-10-16 23:31:07 -0700 | [diff] [blame] | 230 | #ifdef MAX_DMA_CHANNELS |
| 231 | *start = *end = MAX_DMA_CHANNELS; |
| 232 | #endif |
| 233 | *flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 234 | dev_dbg(&dev->dev, " disable dma %d\n", idx); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | /** |
| 238 | * pnp_init_resources - Resets a resource table to default values. |
| 239 | * @table: pointer to the desired resource table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | */ |
| 241 | void pnp_init_resource_table(struct pnp_resource_table *table) |
| 242 | { |
| 243 | int idx; |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 244 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | for (idx = 0; idx < PNP_MAX_IRQ; idx++) { |
| 246 | table->irq_resource[idx].name = NULL; |
| 247 | table->irq_resource[idx].start = -1; |
| 248 | table->irq_resource[idx].end = -1; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 249 | table->irq_resource[idx].flags = |
| 250 | IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | } |
| 252 | for (idx = 0; idx < PNP_MAX_DMA; idx++) { |
| 253 | table->dma_resource[idx].name = NULL; |
| 254 | table->dma_resource[idx].start = -1; |
| 255 | table->dma_resource[idx].end = -1; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 256 | table->dma_resource[idx].flags = |
| 257 | IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | } |
| 259 | for (idx = 0; idx < PNP_MAX_PORT; idx++) { |
| 260 | table->port_resource[idx].name = NULL; |
| 261 | table->port_resource[idx].start = 0; |
| 262 | table->port_resource[idx].end = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 263 | table->port_resource[idx].flags = |
| 264 | IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | } |
| 266 | for (idx = 0; idx < PNP_MAX_MEM; idx++) { |
| 267 | table->mem_resource[idx].name = NULL; |
| 268 | table->mem_resource[idx].start = 0; |
| 269 | table->mem_resource[idx].end = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 270 | table->mem_resource[idx].flags = |
| 271 | IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | } |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * pnp_clean_resources - clears resources that were not manually set |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 277 | * @res: the resources to clean |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | */ |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 279 | static void pnp_clean_resource_table(struct pnp_resource_table *res) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | { |
| 281 | int idx; |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 282 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | for (idx = 0; idx < PNP_MAX_IRQ; idx++) { |
| 284 | if (!(res->irq_resource[idx].flags & IORESOURCE_AUTO)) |
| 285 | continue; |
| 286 | res->irq_resource[idx].start = -1; |
| 287 | res->irq_resource[idx].end = -1; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 288 | res->irq_resource[idx].flags = |
| 289 | IORESOURCE_IRQ | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | for (idx = 0; idx < PNP_MAX_DMA; idx++) { |
| 292 | if (!(res->dma_resource[idx].flags & IORESOURCE_AUTO)) |
| 293 | continue; |
| 294 | res->dma_resource[idx].start = -1; |
| 295 | res->dma_resource[idx].end = -1; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 296 | res->dma_resource[idx].flags = |
| 297 | IORESOURCE_DMA | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | for (idx = 0; idx < PNP_MAX_PORT; idx++) { |
| 300 | if (!(res->port_resource[idx].flags & IORESOURCE_AUTO)) |
| 301 | continue; |
| 302 | res->port_resource[idx].start = 0; |
| 303 | res->port_resource[idx].end = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 304 | res->port_resource[idx].flags = |
| 305 | IORESOURCE_IO | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | for (idx = 0; idx < PNP_MAX_MEM; idx++) { |
| 308 | if (!(res->mem_resource[idx].flags & IORESOURCE_AUTO)) |
| 309 | continue; |
| 310 | res->mem_resource[idx].start = 0; |
| 311 | res->mem_resource[idx].end = 0; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 312 | res->mem_resource[idx].flags = |
| 313 | IORESOURCE_MEM | IORESOURCE_AUTO | IORESOURCE_UNSET; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } |
| 315 | } |
| 316 | |
| 317 | /** |
| 318 | * pnp_assign_resources - assigns resources to the device based on the specified dependent number |
| 319 | * @dev: pointer to the desired device |
| 320 | * @depnum: the dependent function number |
| 321 | * |
| 322 | * Only set depnum to 0 if the device does not have dependent options. |
| 323 | */ |
| 324 | static int pnp_assign_resources(struct pnp_dev *dev, int depnum) |
| 325 | { |
| 326 | struct pnp_port *port; |
| 327 | struct pnp_mem *mem; |
| 328 | struct pnp_irq *irq; |
| 329 | struct pnp_dma *dma; |
| 330 | int nport = 0, nmem = 0, nirq = 0, ndma = 0; |
| 331 | |
| 332 | if (!pnp_can_configure(dev)) |
| 333 | return -ENODEV; |
| 334 | |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 335 | dbg_pnp_show_resources(dev, "before pnp_assign_resources"); |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 336 | mutex_lock(&pnp_res_mutex); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 337 | pnp_clean_resource_table(&dev->res); /* start with a fresh slate */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | if (dev->independent) { |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 339 | dev_dbg(&dev->dev, "assigning independent options\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | port = dev->independent->port; |
| 341 | mem = dev->independent->mem; |
| 342 | irq = dev->independent->irq; |
| 343 | dma = dev->independent->dma; |
| 344 | while (port) { |
| 345 | if (!pnp_assign_port(dev, port, nport)) |
| 346 | goto fail; |
| 347 | nport++; |
| 348 | port = port->next; |
| 349 | } |
| 350 | while (mem) { |
| 351 | if (!pnp_assign_mem(dev, mem, nmem)) |
| 352 | goto fail; |
| 353 | nmem++; |
| 354 | mem = mem->next; |
| 355 | } |
| 356 | while (irq) { |
| 357 | if (!pnp_assign_irq(dev, irq, nirq)) |
| 358 | goto fail; |
| 359 | nirq++; |
| 360 | irq = irq->next; |
| 361 | } |
| 362 | while (dma) { |
Jan Beulich | 7ef3639 | 2007-10-16 23:31:07 -0700 | [diff] [blame] | 363 | pnp_assign_dma(dev, dma, ndma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | ndma++; |
| 365 | dma = dma->next; |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | if (depnum) { |
| 370 | struct pnp_option *dep; |
| 371 | int i; |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 372 | |
| 373 | dev_dbg(&dev->dev, "assigning dependent option %d\n", depnum); |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 374 | for (i = 1, dep = dev->dependent; i < depnum; |
| 375 | i++, dep = dep->next) |
| 376 | if (!dep) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | goto fail; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 378 | port = dep->port; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 379 | mem = dep->mem; |
| 380 | irq = dep->irq; |
| 381 | dma = dep->dma; |
| 382 | while (port) { |
| 383 | if (!pnp_assign_port(dev, port, nport)) |
| 384 | goto fail; |
| 385 | nport++; |
| 386 | port = port->next; |
| 387 | } |
| 388 | while (mem) { |
| 389 | if (!pnp_assign_mem(dev, mem, nmem)) |
| 390 | goto fail; |
| 391 | nmem++; |
| 392 | mem = mem->next; |
| 393 | } |
| 394 | while (irq) { |
| 395 | if (!pnp_assign_irq(dev, irq, nirq)) |
| 396 | goto fail; |
| 397 | nirq++; |
| 398 | irq = irq->next; |
| 399 | } |
| 400 | while (dma) { |
Jan Beulich | 7ef3639 | 2007-10-16 23:31:07 -0700 | [diff] [blame] | 401 | pnp_assign_dma(dev, dma, ndma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | ndma++; |
| 403 | dma = dma->next; |
| 404 | } |
| 405 | } else if (dev->dependent) |
| 406 | goto fail; |
| 407 | |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 408 | mutex_unlock(&pnp_res_mutex); |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 409 | dbg_pnp_show_resources(dev, "after pnp_assign_resources"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | return 1; |
| 411 | |
Bjorn Helgaas | 1e0aa9a | 2007-08-15 10:32:08 -0600 | [diff] [blame] | 412 | fail: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | pnp_clean_resource_table(&dev->res); |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 414 | mutex_unlock(&pnp_res_mutex); |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 415 | dbg_pnp_show_resources(dev, "after pnp_assign_resources (failed)"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | return 0; |
| 417 | } |
| 418 | |
| 419 | /** |
| 420 | * pnp_manual_config_dev - Disables Auto Config and Manually sets the resource table |
| 421 | * @dev: pointer to the desired device |
| 422 | * @res: pointer to the new resource config |
Martin Waitz | 3d41088 | 2005-06-23 22:05:21 -0700 | [diff] [blame] | 423 | * @mode: 0 or PNP_CONFIG_FORCE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | * |
| 425 | * This function can be used by drivers that want to manually set thier resources. |
| 426 | */ |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 427 | int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res, |
| 428 | int mode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | { |
| 430 | int i; |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 431 | struct pnp_resource_table *bak; |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 432 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 433 | if (!pnp_can_configure(dev)) |
| 434 | return -ENODEV; |
| 435 | bak = pnp_alloc(sizeof(struct pnp_resource_table)); |
| 436 | if (!bak) |
| 437 | return -ENOMEM; |
| 438 | *bak = dev->res; |
| 439 | |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 440 | mutex_lock(&pnp_res_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | dev->res = *res; |
| 442 | if (!(mode & PNP_CONFIG_FORCE)) { |
| 443 | for (i = 0; i < PNP_MAX_PORT; i++) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 444 | if (!pnp_check_port(dev, i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | goto fail; |
| 446 | } |
| 447 | for (i = 0; i < PNP_MAX_MEM; i++) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 448 | if (!pnp_check_mem(dev, i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | goto fail; |
| 450 | } |
| 451 | for (i = 0; i < PNP_MAX_IRQ; i++) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 452 | if (!pnp_check_irq(dev, i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | goto fail; |
| 454 | } |
| 455 | for (i = 0; i < PNP_MAX_DMA; i++) { |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 456 | if (!pnp_check_dma(dev, i)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | goto fail; |
| 458 | } |
| 459 | } |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 460 | mutex_unlock(&pnp_res_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | |
| 462 | kfree(bak); |
| 463 | return 0; |
| 464 | |
Bjorn Helgaas | 1e0aa9a | 2007-08-15 10:32:08 -0600 | [diff] [blame] | 465 | fail: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | dev->res = *bak; |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 467 | mutex_unlock(&pnp_res_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | kfree(bak); |
| 469 | return -EINVAL; |
| 470 | } |
| 471 | |
| 472 | /** |
| 473 | * pnp_auto_config_dev - automatically assigns resources to a device |
| 474 | * @dev: pointer to the desired device |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | */ |
| 476 | int pnp_auto_config_dev(struct pnp_dev *dev) |
| 477 | { |
| 478 | struct pnp_option *dep; |
| 479 | int i = 1; |
| 480 | |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 481 | if (!pnp_can_configure(dev)) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 482 | dev_dbg(&dev->dev, "configuration not supported\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | return -ENODEV; |
| 484 | } |
| 485 | |
| 486 | if (!dev->dependent) { |
| 487 | if (pnp_assign_resources(dev, 0)) |
| 488 | return 0; |
| 489 | } else { |
| 490 | dep = dev->dependent; |
| 491 | do { |
| 492 | if (pnp_assign_resources(dev, i)) |
| 493 | return 0; |
| 494 | dep = dep->next; |
| 495 | i++; |
| 496 | } while (dep); |
| 497 | } |
| 498 | |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 499 | dev_err(&dev->dev, "unable to assign resources\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | return -EBUSY; |
| 501 | } |
| 502 | |
| 503 | /** |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 504 | * pnp_start_dev - low-level start of the PnP device |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | * @dev: pointer to the desired device |
| 506 | * |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 507 | * assumes that resources have already been allocated |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 508 | */ |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 509 | int pnp_start_dev(struct pnp_dev *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 510 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 511 | if (!pnp_can_write(dev)) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 512 | dev_dbg(&dev->dev, "activation not supported\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | return -EINVAL; |
| 514 | } |
| 515 | |
Bjorn Helgaas | 81b5c75 | 2008-04-28 16:34:08 -0600 | [diff] [blame^] | 516 | dbg_pnp_show_resources(dev, "pnp_start_dev"); |
Bjorn Helgaas | 59284cb | 2008-04-28 16:34:05 -0600 | [diff] [blame] | 517 | if (dev->protocol->set(dev) < 0) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 518 | dev_err(&dev->dev, "activation failed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 519 | return -EIO; |
| 520 | } |
| 521 | |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 522 | dev_info(&dev->dev, "activated\n"); |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 523 | return 0; |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * pnp_stop_dev - low-level disable of the PnP device |
| 528 | * @dev: pointer to the desired device |
| 529 | * |
| 530 | * does not free resources |
| 531 | */ |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 532 | int pnp_stop_dev(struct pnp_dev *dev) |
| 533 | { |
| 534 | if (!pnp_can_disable(dev)) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 535 | dev_dbg(&dev->dev, "disabling not supported\n"); |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 536 | return -EINVAL; |
| 537 | } |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 538 | if (dev->protocol->disable(dev) < 0) { |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 539 | dev_err(&dev->dev, "disable failed\n"); |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 540 | return -EIO; |
| 541 | } |
| 542 | |
Bjorn Helgaas | a05d078 | 2007-10-16 23:31:10 -0700 | [diff] [blame] | 543 | dev_info(&dev->dev, "disabled\n"); |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 544 | return 0; |
| 545 | } |
| 546 | |
| 547 | /** |
| 548 | * pnp_activate_dev - activates a PnP device for use |
| 549 | * @dev: pointer to the desired device |
| 550 | * |
| 551 | * does not validate or set resources so be careful. |
| 552 | */ |
| 553 | int pnp_activate_dev(struct pnp_dev *dev) |
| 554 | { |
| 555 | int error; |
| 556 | |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 557 | if (dev->active) |
Bjorn Helgaas | cc8259a | 2008-02-06 01:40:02 -0800 | [diff] [blame] | 558 | return 0; |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 559 | |
| 560 | /* ensure resources are allocated */ |
| 561 | if (pnp_auto_config_dev(dev)) |
| 562 | return -EBUSY; |
| 563 | |
| 564 | error = pnp_start_dev(dev); |
| 565 | if (error) |
| 566 | return error; |
| 567 | |
| 568 | dev->active = 1; |
Bjorn Helgaas | cc8259a | 2008-02-06 01:40:02 -0800 | [diff] [blame] | 569 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /** |
| 573 | * pnp_disable_dev - disables device |
| 574 | * @dev: pointer to the desired device |
| 575 | * |
| 576 | * inform the correct pnp protocol so that resources can be used by other devices |
| 577 | */ |
| 578 | int pnp_disable_dev(struct pnp_dev *dev) |
| 579 | { |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 580 | int error; |
| 581 | |
Bjorn Helgaas | 07d4e9a | 2007-07-26 10:41:21 -0700 | [diff] [blame] | 582 | if (!dev->active) |
Bjorn Helgaas | cc8259a | 2008-02-06 01:40:02 -0800 | [diff] [blame] | 583 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 584 | |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 585 | error = pnp_stop_dev(dev); |
| 586 | if (error) |
| 587 | return error; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 588 | |
| 589 | dev->active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | |
| 591 | /* release the resources so that other devices can use them */ |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 592 | mutex_lock(&pnp_res_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | pnp_clean_resource_table(&dev->res); |
Daniel Walker | b3bd86e | 2008-02-06 01:40:04 -0800 | [diff] [blame] | 594 | mutex_unlock(&pnp_res_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 595 | |
Bjorn Helgaas | cc8259a | 2008-02-06 01:40:02 -0800 | [diff] [blame] | 596 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | } |
| 598 | |
| 599 | /** |
| 600 | * pnp_resource_change - change one resource |
| 601 | * @resource: pointer to resource to be changed |
| 602 | * @start: start of region |
| 603 | * @size: size of region |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | */ |
Greg Kroah-Hartman | b60ba83 | 2006-06-12 17:07:07 -0700 | [diff] [blame] | 605 | void pnp_resource_change(struct resource *resource, resource_size_t start, |
Bjorn Helgaas | 9dd7846 | 2007-07-26 10:41:20 -0700 | [diff] [blame] | 606 | resource_size_t size) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 607 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | resource->flags &= ~(IORESOURCE_AUTO | IORESOURCE_UNSET); |
| 609 | resource->start = start; |
| 610 | resource->end = start + size - 1; |
| 611 | } |
| 612 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | EXPORT_SYMBOL(pnp_manual_config_dev); |
Pierre Ossman | 68094e3 | 2005-11-29 09:09:32 +0100 | [diff] [blame] | 614 | EXPORT_SYMBOL(pnp_start_dev); |
| 615 | EXPORT_SYMBOL(pnp_stop_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | EXPORT_SYMBOL(pnp_activate_dev); |
| 617 | EXPORT_SYMBOL(pnp_disable_dev); |
| 618 | EXPORT_SYMBOL(pnp_resource_change); |
| 619 | EXPORT_SYMBOL(pnp_init_resource_table); |