aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
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
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')
-rw-r--r--drivers/pnp/base.h2
-rw-r--r--drivers/pnp/interface.c14
-rw-r--r--drivers/pnp/isapnp/core.c9
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c42
-rw-r--r--drivers/pnp/pnpbios/rsparser.c26
-rw-r--r--drivers/pnp/resource.c26
6 files changed, 47 insertions, 72 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index 3dd5d849c30f..b6719b384347 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -43,3 +43,5 @@ struct pnp_resource_table {
43 43
44struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq, 44struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
45 int flags); 45 int flags);
46struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
47 int flags);
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c
index e8134c286207..00c8a970a97e 100644
--- a/drivers/pnp/interface.c
+++ b/drivers/pnp/interface.c
@@ -440,16 +440,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
440 buf += 3; 440 buf += 3;
441 while (isspace(*buf)) 441 while (isspace(*buf))
442 ++buf; 442 ++buf;
443 pnp_res = pnp_get_pnp_resource(dev, 443 start = simple_strtoul(buf, &buf, 0);
444 IORESOURCE_DMA, ndma); 444 pnp_res = pnp_add_dma_resource(dev, start, 0);
445 if (!pnp_res) 445 if (pnp_res)
446 break; 446 pnp_res->index = ndma++;
447 pnp_res->index = ndma;
448 res = &pnp_res->res;
449 res->start = res->end =
450 simple_strtoul(buf, &buf, 0);
451 res->flags = IORESOURCE_DMA;
452 ndma++;
453 continue; 447 continue;
454 } 448 }
455 break; 449 break;
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 2cf750f077a4..2e5e58c777dd 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -973,12 +973,9 @@ static int isapnp_read_resources(struct pnp_dev *dev)
973 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp); 973 ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
974 if (ret == 4) 974 if (ret == 4)
975 continue; 975 continue;
976 pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, 976 pnp_res = pnp_add_dma_resource(dev, ret, 0);
977 tmp); 977 if (pnp_res)
978 pnp_res->index = tmp; 978 pnp_res->index = tmp;
979 res = &pnp_res->res;
980 res->start = res->end = ret;
981 res->flags = IORESOURCE_DMA;
982 } 979 }
983 } 980 }
984 return 0; 981 return 0;
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:
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 845730c57edc..7f8d65728599 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -54,27 +54,6 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
54 * Allocated Resources 54 * Allocated Resources
55 */ 55 */
56 56
57static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
58{
59 struct resource *res;
60 int i;
61
62 for (i = 0; i < PNP_MAX_DMA; i++) {
63 res = pnp_get_resource(dev, IORESOURCE_DMA, i);
64 if (!pnp_resource_valid(res))
65 break;
66 }
67
68 if (i < PNP_MAX_DMA) {
69 res->flags = IORESOURCE_DMA; // Also clears _UNSET flag
70 if (dma == -1) {
71 res->flags |= IORESOURCE_DISABLED;
72 return;
73 }
74 res->start = res->end = (unsigned long)dma;
75 }
76}
77
78static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, 57static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
79 int io, int len) 58 int io, int len)
80{ 59{
@@ -199,12 +178,15 @@ static unsigned char *pnpbios_parse_allocated_resource_data(struct pnp_dev *dev,
199 case SMALL_TAG_DMA: 178 case SMALL_TAG_DMA:
200 if (len != 2) 179 if (len != 2)
201 goto len_err; 180 goto len_err;
181 flags = 0;
202 io = -1; 182 io = -1;
203 mask = p[1]; 183 mask = p[1];
204 for (i = 0; i < 8; i++, mask = mask >> 1) 184 for (i = 0; i < 8; i++, mask = mask >> 1)
205 if (mask & 0x01) 185 if (mask & 0x01)
206 io = i; 186 io = i;
207 pnpbios_parse_allocated_dmaresource(dev, io); 187 if (io == -1)
188 flags = IORESOURCE_DISABLED;
189 pnp_add_dma_resource(dev, io, flags);
208 break; 190 break;
209 191
210 case SMALL_TAG_PORT: 192 case SMALL_TAG_PORT:
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 082a556b9dcc..2a8612e31ab7 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -602,6 +602,32 @@ struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq,
602 return pnp_res; 602 return pnp_res;
603} 603}
604 604
605struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma,
606 int flags)
607{
608 struct pnp_resource *pnp_res;
609 struct resource *res;
610 static unsigned char warned;
611
612 pnp_res = pnp_new_resource(dev, IORESOURCE_DMA);
613 if (!pnp_res) {
614 if (!warned) {
615 dev_err(&dev->dev, "can't add resource for DMA %d\n",
616 dma);
617 warned = 1;
618 }
619 return NULL;
620 }
621
622 res = &pnp_res->res;
623 res->flags = IORESOURCE_DMA | flags;
624 res->start = dma;
625 res->end = dma;
626
627 dev_dbg(&dev->dev, " add dma %d flags %#x\n", dma, flags);
628 return pnp_res;
629}
630
605/* format is: pnp_reserve_irq=irq1[,irq2] .... */ 631/* format is: pnp_reserve_irq=irq1[,irq2] .... */
606static int __init pnp_setup_reserve_irq(char *str) 632static int __init pnp_setup_reserve_irq(char *str)
607{ 633{