aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpacpi/rsparser.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-04-28 18:34:35 -0400
committerLen Brown <len.brown@intel.com>2008-04-29 03:22:28 -0400
commitdc16f5f2ede8cc2acf8ac22857a7fecf3a4296c2 (patch)
treeb4ba965b7c5e1e6011697160aa5346b63afbbbf9 /drivers/pnp/pnpacpi/rsparser.c
parentdbddd0383c59d588f8db5e773b062756e39117ec (diff)
PNP: make generic pnp_add_dma_resource()
Add a pnp_add_dma_resource() that can be used by all the PNP backends. This consolidates a little more pnp_resource_table knowledge into one place. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/pnp/pnpacpi/rsparser.c')
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c42
1 files changed, 8 insertions, 34 deletions
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 0b67dff1e7c3..fc7cf73b7a7e 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -158,34 +158,6 @@ static int dma_flags(int type, int bus_master, int transfer)
158 return flags; 158 return flags;
159} 159}
160 160
161static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
162 u32 dma, int flags)
163{
164 struct resource *res;
165 int i;
166 static unsigned char warned;
167
168 for (i = 0; i < PNP_MAX_DMA; i++) {
169 res = pnp_get_resource(dev, IORESOURCE_DMA, i);
170 if (!pnp_resource_valid(res))
171 break;
172 }
173 if (i < PNP_MAX_DMA) {
174 res->flags = IORESOURCE_DMA; // Also clears _UNSET flag
175 res->flags |= flags;
176 if (dma == -1) {
177 res->flags |= IORESOURCE_DISABLED;
178 return;
179 }
180 res->start = dma;
181 res->end = dma;
182 } else if (!warned) {
183 printk(KERN_WARNING "pnpacpi: exceeded the max number of DMA "
184 "resources: %d \n", PNP_MAX_DMA);
185 warned = 1;
186 }
187}
188
189static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, 161static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
190 u64 io, u64 len, int io_decode) 162 u64 io, u64 len, int io_decode)
191{ 163{
@@ -285,7 +257,7 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
285 struct acpi_resource_memory32 *memory32; 257 struct acpi_resource_memory32 *memory32;
286 struct acpi_resource_fixed_memory32 *fixed_memory32; 258 struct acpi_resource_fixed_memory32 *fixed_memory32;
287 struct acpi_resource_extended_irq *extended_irq; 259 struct acpi_resource_extended_irq *extended_irq;
288 int i; 260 int i, flags;
289 261
290 switch (res->type) { 262 switch (res->type) {
291 case ACPI_RESOURCE_TYPE_IRQ: 263 case ACPI_RESOURCE_TYPE_IRQ:
@@ -305,11 +277,13 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
305 277
306 case ACPI_RESOURCE_TYPE_DMA: 278 case ACPI_RESOURCE_TYPE_DMA:
307 dma = &res->data.dma; 279 dma = &res->data.dma;
308 if (dma->channel_count > 0) 280 if (dma->channel_count > 0) {
309 pnpacpi_parse_allocated_dmaresource(dev, 281 flags = dma_flags(dma->type, dma->bus_master,
310 dma->channels[0], 282 dma->transfer);
311 dma_flags(dma->type, dma->bus_master, 283 if (dma->channels[0] == (u8) -1)
312 dma->transfer)); 284 flags |= IORESOURCE_DISABLED;
285 pnp_add_dma_resource(dev, dma->channels[0], flags);
286 }
313 break; 287 break;
314 288
315 case ACPI_RESOURCE_TYPE_IO: 289 case ACPI_RESOURCE_TYPE_IO: