diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-04-28 18:34:36 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-04-29 03:22:29 -0400 |
commit | cc8c2e308194f0997c718c7c735550ff06754d20 (patch) | |
tree | 1464d278291fd285653ff026f62c5f4f6d75286c /drivers/pnp | |
parent | dc16f5f2ede8cc2acf8ac22857a7fecf3a4296c2 (diff) |
PNP: make generic pnp_add_io_resource()
Add a pnp_add_io_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.h | 3 | ||||
-rw-r--r-- | drivers/pnp/interface.c | 20 | ||||
-rw-r--r-- | drivers/pnp/isapnp/core.c | 8 | ||||
-rw-r--r-- | drivers/pnp/pnpacpi/rsparser.c | 35 | ||||
-rw-r--r-- | drivers/pnp/pnpbios/rsparser.c | 23 | ||||
-rw-r--r-- | drivers/pnp/resource.c | 29 |
6 files changed, 59 insertions, 59 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h index b6719b384347..bfb08abc311b 100644 --- a/drivers/pnp/base.h +++ b/drivers/pnp/base.h | |||
@@ -45,3 +45,6 @@ struct pnp_resource *pnp_add_irq_resource(struct pnp_dev *dev, int irq, | |||
45 | int flags); | 45 | int flags); |
46 | struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, | 46 | struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, |
47 | int flags); | 47 | int flags); |
48 | struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, | ||
49 | resource_size_t start, | ||
50 | resource_size_t end, int flags); | ||
diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 00c8a970a97e..77d8bf01b485 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c | |||
@@ -324,7 +324,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
324 | struct resource *res; | 324 | struct resource *res; |
325 | char *buf = (void *)ubuf; | 325 | char *buf = (void *)ubuf; |
326 | int retval = 0; | 326 | int retval = 0; |
327 | resource_size_t start; | 327 | resource_size_t start, end; |
328 | 328 | ||
329 | if (dev->status & PNP_ATTACHED) { | 329 | if (dev->status & PNP_ATTACHED) { |
330 | retval = -EBUSY; | 330 | retval = -EBUSY; |
@@ -382,24 +382,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, | |||
382 | buf += 2; | 382 | buf += 2; |
383 | while (isspace(*buf)) | 383 | while (isspace(*buf)) |
384 | ++buf; | 384 | ++buf; |
385 | pnp_res = pnp_get_pnp_resource(dev, | 385 | start = simple_strtoul(buf, &buf, 0); |
386 | IORESOURCE_IO, nport); | ||
387 | if (!pnp_res) | ||
388 | break; | ||
389 | pnp_res->index = nport; | ||
390 | res = &pnp_res->res; | ||
391 | res->start = simple_strtoul(buf, &buf, 0); | ||
392 | while (isspace(*buf)) | 386 | while (isspace(*buf)) |
393 | ++buf; | 387 | ++buf; |
394 | if (*buf == '-') { | 388 | if (*buf == '-') { |
395 | buf += 1; | 389 | buf += 1; |
396 | while (isspace(*buf)) | 390 | while (isspace(*buf)) |
397 | ++buf; | 391 | ++buf; |
398 | res->end = simple_strtoul(buf, &buf, 0); | 392 | end = simple_strtoul(buf, &buf, 0); |
399 | } else | 393 | } else |
400 | res->end = res->start; | 394 | end = start; |
401 | res->flags = IORESOURCE_IO; | 395 | pnp_res = pnp_add_io_resource(dev, start, end, |
402 | nport++; | 396 | 0); |
397 | if (pnp_res) | ||
398 | pnp_res->index = nport++; | ||
403 | continue; | 399 | continue; |
404 | } | 400 | } |
405 | if (!strnicmp(buf, "mem", 3)) { | 401 | if (!strnicmp(buf, "mem", 3)) { |
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c index 2e5e58c777dd..bdd8508090da 100644 --- a/drivers/pnp/isapnp/core.c +++ b/drivers/pnp/isapnp/core.c | |||
@@ -941,11 +941,9 @@ static int isapnp_read_resources(struct pnp_dev *dev) | |||
941 | ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); | 941 | ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1)); |
942 | if (!ret) | 942 | if (!ret) |
943 | continue; | 943 | continue; |
944 | pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp); | 944 | pnp_res = pnp_add_io_resource(dev, ret, ret, 0); |
945 | pnp_res->index = tmp; | 945 | if (pnp_res) |
946 | res = &pnp_res->res; | 946 | pnp_res->index = tmp; |
947 | res->start = ret; | ||
948 | res->flags = IORESOURCE_IO; | ||
949 | } | 947 | } |
950 | for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { | 948 | for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) { |
951 | ret = | 949 | ret = |
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c index fc7cf73b7a7e..d3ca8e035c19 100644 --- a/drivers/pnp/pnpacpi/rsparser.c +++ b/drivers/pnp/pnpacpi/rsparser.c | |||
@@ -158,33 +158,18 @@ static int dma_flags(int type, int bus_master, int transfer) | |||
158 | return flags; | 158 | return flags; |
159 | } | 159 | } |
160 | 160 | ||
161 | static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, | 161 | static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, u64 start, |
162 | u64 io, u64 len, int io_decode) | 162 | u64 len, int io_decode) |
163 | { | 163 | { |
164 | struct resource *res; | 164 | int flags = 0; |
165 | int i; | 165 | u64 end = start + len - 1; |
166 | static unsigned char warned; | ||
167 | 166 | ||
168 | for (i = 0; i < PNP_MAX_PORT; i++) { | 167 | if (io_decode == ACPI_DECODE_16) |
169 | res = pnp_get_resource(dev, IORESOURCE_IO, i); | 168 | flags |= PNP_PORT_FLAG_16BITADDR; |
170 | if (!pnp_resource_valid(res)) | 169 | if (len == 0 || end >= 0x10003) |
171 | break; | 170 | flags |= IORESOURCE_DISABLED; |
172 | } | 171 | |
173 | if (i < PNP_MAX_PORT) { | 172 | pnp_add_io_resource(dev, start, end, flags); |
174 | res->flags = IORESOURCE_IO; // Also clears _UNSET flag | ||
175 | if (io_decode == ACPI_DECODE_16) | ||
176 | res->flags |= PNP_PORT_FLAG_16BITADDR; | ||
177 | if (len <= 0 || (io + len - 1) >= 0x10003) { | ||
178 | res->flags |= IORESOURCE_DISABLED; | ||
179 | return; | ||
180 | } | ||
181 | res->start = io; | ||
182 | res->end = io + len - 1; | ||
183 | } else if (!warned) { | ||
184 | printk(KERN_WARNING "pnpacpi: exceeded the max number of IO " | ||
185 | "resources: %d \n", PNP_MAX_PORT); | ||
186 | warned = 1; | ||
187 | } | ||
188 | } | 173 | } |
189 | 174 | ||
190 | static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, | 175 | static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev, |
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c index 7f8d65728599..8c83bc16a9be 100644 --- a/drivers/pnp/pnpbios/rsparser.c +++ b/drivers/pnp/pnpbios/rsparser.c | |||
@@ -55,26 +55,15 @@ inline void pcibios_penalize_isa_irq(int irq, int active) | |||
55 | */ | 55 | */ |
56 | 56 | ||
57 | static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, | 57 | static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, |
58 | int io, int len) | 58 | int start, int len) |
59 | { | 59 | { |
60 | struct resource *res; | 60 | int flags = 0; |
61 | int i; | 61 | int end = start + len - 1; |
62 | 62 | ||
63 | for (i = 0; i < PNP_MAX_PORT; i++) { | 63 | if (len <= 0 || end >= 0x10003) |
64 | res = pnp_get_resource(dev, IORESOURCE_IO, i); | 64 | flags |= IORESOURCE_DISABLED; |
65 | if (!pnp_resource_valid(res)) | ||
66 | break; | ||
67 | } | ||
68 | 65 | ||
69 | if (i < PNP_MAX_PORT) { | 66 | pnp_add_io_resource(dev, start, end, flags); |
70 | res->flags = IORESOURCE_IO; // Also clears _UNSET flag | ||
71 | if (len <= 0 || (io + len - 1) >= 0x10003) { | ||
72 | res->flags |= IORESOURCE_DISABLED; | ||
73 | return; | ||
74 | } | ||
75 | res->start = (unsigned long)io; | ||
76 | res->end = (unsigned long)(io + len - 1); | ||
77 | } | ||
78 | } | 67 | } |
79 | 68 | ||
80 | static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, | 69 | static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, |
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index 2a8612e31ab7..64387b70026a 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c | |||
@@ -628,6 +628,35 @@ struct pnp_resource *pnp_add_dma_resource(struct pnp_dev *dev, int dma, | |||
628 | return pnp_res; | 628 | return pnp_res; |
629 | } | 629 | } |
630 | 630 | ||
631 | struct pnp_resource *pnp_add_io_resource(struct pnp_dev *dev, | ||
632 | resource_size_t start, | ||
633 | resource_size_t end, int flags) | ||
634 | { | ||
635 | struct pnp_resource *pnp_res; | ||
636 | struct resource *res; | ||
637 | static unsigned char warned; | ||
638 | |||
639 | pnp_res = pnp_new_resource(dev, IORESOURCE_IO); | ||
640 | if (!pnp_res) { | ||
641 | if (!warned) { | ||
642 | dev_err(&dev->dev, "can't add resource for IO " | ||
643 | "%#llx-%#llx\n",(unsigned long long) start, | ||
644 | (unsigned long long) end); | ||
645 | warned = 1; | ||
646 | } | ||
647 | return NULL; | ||
648 | } | ||
649 | |||
650 | res = &pnp_res->res; | ||
651 | res->flags = IORESOURCE_IO | flags; | ||
652 | res->start = start; | ||
653 | res->end = end; | ||
654 | |||
655 | dev_dbg(&dev->dev, " add io %#llx-%#llx flags %#x\n", | ||
656 | (unsigned long long) start, (unsigned long long) end, flags); | ||
657 | return pnp_res; | ||
658 | } | ||
659 | |||
631 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ | 660 | /* format is: pnp_reserve_irq=irq1[,irq2] .... */ |
632 | static int __init pnp_setup_reserve_irq(char *str) | 661 | static int __init pnp_setup_reserve_irq(char *str) |
633 | { | 662 | { |