From 59284cb4099411bc6f4915a5a4cb76414440c447 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:05 -0600 Subject: PNP: remove pnp_resource_table from internal get/set interfaces When we call protocol->get() and protocol->set() methods, we currently supply pointers to both the pnp_dev and the pnp_resource_table even though the pnp_resource_table should always be the one associated with the pnp_dev. This removes the pnp_resource_table arguments to make it clear that these methods only operate on the specified pnp_dev. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 982658477a5..e882896bdbd 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -364,7 +364,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, if (!strnicmp(buf, "get", 3)) { mutex_lock(&pnp_res_mutex); if (pnp_can_read(dev)) - dev->protocol->get(dev, &dev->res); + dev->protocol->get(dev); mutex_unlock(&pnp_res_mutex); goto done; } -- cgit v1.2.3 From f44900020926b2cb06b87f0f52643d6285514fc3 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:09 -0600 Subject: PNP: add pnp_init_resources(struct pnp_dev *) interface Add pnp_init_resources(struct pnp_dev *) to replace pnp_init_resource_table(), which takes a pointer to the pnp_resource_table itself. Passing only the pnp_dev * reduces the possibility for error in the caller and removes the pnp_resource_table implementation detail from the interface. Even though pnp_init_resource_table() is exported, I did not export pnp_init_resources() because it is used only by the PNP core. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/interface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index e882896bdbd..cdc3ecfde6e 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -351,14 +351,14 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, if (!strnicmp(buf, "auto", 4)) { if (dev->active) goto done; - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); retval = pnp_auto_config_dev(dev); goto done; } if (!strnicmp(buf, "clear", 5)) { if (dev->active) goto done; - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); goto done; } if (!strnicmp(buf, "get", 3)) { @@ -373,7 +373,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, if (dev->active) goto done; buf += 3; - pnp_init_resource_table(&dev->res); + pnp_init_resources(dev); mutex_lock(&pnp_res_mutex); while (1) { while (isspace(*buf)) -- cgit v1.2.3 From 470feb113a23de365b6051efde0d69de86d9d2f8 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:20 -0600 Subject: PNP: reduce redundancy in pnp_set_current_resources() Use a temporary "res" pointer to replace repeated lookups in the pnp resource tables. Signed-off-by: Bjorn Helgaas Acked-By: Rene Herman Signed-off-by: Len Brown --- drivers/pnp/interface.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index cdc3ecfde6e..1801df3db1e 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -323,6 +323,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, const char *ubuf, size_t count) { struct pnp_dev *dev = to_pnp_dev(dmdev); + struct resource *res; char *buf = (void *)ubuf; int retval = 0; @@ -382,21 +383,18 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 2; while (isspace(*buf)) ++buf; - dev->res.port_resource[nport].start = - simple_strtoul(buf, &buf, 0); + res = &dev->res.port_resource[nport]; + res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; if (*buf == '-') { buf += 1; while (isspace(*buf)) ++buf; - dev->res.port_resource[nport].end = - simple_strtoul(buf, &buf, 0); + res->end = simple_strtoul(buf, &buf, 0); } else - dev->res.port_resource[nport].end = - dev->res.port_resource[nport].start; - dev->res.port_resource[nport].flags = - IORESOURCE_IO; + res->end = res->start; + res->flags = IORESOURCE_IO; nport++; if (nport >= PNP_MAX_PORT) break; @@ -406,21 +404,18 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - dev->res.mem_resource[nmem].start = - simple_strtoul(buf, &buf, 0); + res = &dev->res.mem_resource[nmem]; + res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; if (*buf == '-') { buf += 1; while (isspace(*buf)) ++buf; - dev->res.mem_resource[nmem].end = - simple_strtoul(buf, &buf, 0); + res->end = simple_strtoul(buf, &buf, 0); } else - dev->res.mem_resource[nmem].end = - dev->res.mem_resource[nmem].start; - dev->res.mem_resource[nmem].flags = - IORESOURCE_MEM; + res->end = res->start; + res->flags = IORESOURCE_MEM; nmem++; if (nmem >= PNP_MAX_MEM) break; @@ -430,11 +425,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - dev->res.irq_resource[nirq].start = - dev->res.irq_resource[nirq].end = + res = &dev->res.irq_resource[nirq]; + res->start = res->end = simple_strtoul(buf, &buf, 0); - dev->res.irq_resource[nirq].flags = - IORESOURCE_IRQ; + res->flags = IORESOURCE_IRQ; nirq++; if (nirq >= PNP_MAX_IRQ) break; @@ -444,11 +438,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - dev->res.dma_resource[ndma].start = - dev->res.dma_resource[ndma].end = + res = &dev->res.dma_resource[ndma]; + res->start = res->end = simple_strtoul(buf, &buf, 0); - dev->res.dma_resource[ndma].flags = - IORESOURCE_DMA; + res->flags = IORESOURCE_DMA; ndma++; if (ndma >= PNP_MAX_DMA) break; -- cgit v1.2.3 From f6505fef18644557f732468c1f22f84560d8a819 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:25 -0600 Subject: PNP: convert assign, interface to use pnp_get_resource(), not pnp_resource_table This removes more direct references to pnp_resource_table from the pnp_assign_resources() path and the /sys user interface path. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/interface.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 1801df3db1e..a608054a3e5 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -383,7 +383,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 2; while (isspace(*buf)) ++buf; - res = &dev->res.port_resource[nport]; + res = pnp_get_resource(dev, IORESOURCE_IO, + nport); + if (!res) + break; res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; @@ -396,15 +399,16 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, res->end = res->start; res->flags = IORESOURCE_IO; nport++; - if (nport >= PNP_MAX_PORT) - break; continue; } if (!strnicmp(buf, "mem", 3)) { buf += 3; while (isspace(*buf)) ++buf; - res = &dev->res.mem_resource[nmem]; + res = pnp_get_resource(dev, IORESOURCE_MEM, + nmem); + if (!res) + break; res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; @@ -417,34 +421,34 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, res->end = res->start; res->flags = IORESOURCE_MEM; nmem++; - if (nmem >= PNP_MAX_MEM) - break; continue; } if (!strnicmp(buf, "irq", 3)) { buf += 3; while (isspace(*buf)) ++buf; - res = &dev->res.irq_resource[nirq]; + res = pnp_get_resource(dev, IORESOURCE_IRQ, + nirq); + if (!res) + break; res->start = res->end = simple_strtoul(buf, &buf, 0); res->flags = IORESOURCE_IRQ; nirq++; - if (nirq >= PNP_MAX_IRQ) - break; continue; } if (!strnicmp(buf, "dma", 3)) { buf += 3; while (isspace(*buf)) ++buf; - res = &dev->res.dma_resource[ndma]; + res = pnp_get_resource(dev, IORESOURCE_DMA, + ndma); + if (!res) + break; res->start = res->end = simple_strtoul(buf, &buf, 0); res->flags = IORESOURCE_DMA; ndma++; - if (ndma >= PNP_MAX_DMA) - break; continue; } break; -- cgit v1.2.3 From 95ab3669f7830682c7762e9c305a0c1dd44454cc Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:26 -0600 Subject: PNP: remove PNP_MAX_* uses Remove some PNP_MAX_* uses. The pnp_resource_table isn't dynamic yet, but with pnp_get_resource(), we can start moving away from the table size constants. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/interface.c | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index a608054a3e5..e9e66ed4fa3 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -248,6 +248,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, char *buf) { struct pnp_dev *dev = to_pnp_dev(dmdev); + struct resource *res; int i, ret; pnp_info_buffer_t *buffer; @@ -267,50 +268,46 @@ static ssize_t pnp_show_current_resources(struct device *dmdev, else pnp_printf(buffer, "disabled\n"); - for (i = 0; i < PNP_MAX_PORT; i++) { - if (pnp_port_valid(dev, i)) { + for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) { + if (pnp_resource_valid(res)) { pnp_printf(buffer, "io"); - if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED) + if (res->flags & IORESOURCE_DISABLED) pnp_printf(buffer, " disabled\n"); else pnp_printf(buffer, " 0x%llx-0x%llx\n", - (unsigned long long) - pnp_port_start(dev, i), - (unsigned long long)pnp_port_end(dev, - i)); + (unsigned long long) res->start, + (unsigned long long) res->end); } } - for (i = 0; i < PNP_MAX_MEM; i++) { - if (pnp_mem_valid(dev, i)) { + for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) { + if (pnp_resource_valid(res)) { pnp_printf(buffer, "mem"); - if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED) + if (res->flags & IORESOURCE_DISABLED) pnp_printf(buffer, " disabled\n"); else pnp_printf(buffer, " 0x%llx-0x%llx\n", - (unsigned long long) - pnp_mem_start(dev, i), - (unsigned long long)pnp_mem_end(dev, - i)); + (unsigned long long) res->start, + (unsigned long long) res->end); } } - for (i = 0; i < PNP_MAX_IRQ; i++) { - if (pnp_irq_valid(dev, i)) { + for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) { + if (pnp_resource_valid(res)) { pnp_printf(buffer, "irq"); - if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED) + if (res->flags & IORESOURCE_DISABLED) pnp_printf(buffer, " disabled\n"); else pnp_printf(buffer, " %lld\n", - (unsigned long long)pnp_irq(dev, i)); + (unsigned long long) res->start); } } - for (i = 0; i < PNP_MAX_DMA; i++) { - if (pnp_dma_valid(dev, i)) { + for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) { + if (pnp_resource_valid(res)) { pnp_printf(buffer, "dma"); - if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED) + if (res->flags & IORESOURCE_DISABLED) pnp_printf(buffer, " disabled\n"); else pnp_printf(buffer, " %lld\n", - (unsigned long long)pnp_dma(dev, i)); + (unsigned long long) res->start); } } ret = (buffer->curr - buf); -- cgit v1.2.3 From 21855d69d1e3ace3efdb8159a4a7ab1ab98a6f19 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:32 -0600 Subject: PNP: add pnp_resource index for ISAPNP Save the ISAPNP config register index in the struct pnp_resource. We need this because it is important to write ISAPNP configuration back to the same registers we read it from. For example, if we read valid regions from memory descriptors 0, 1, and 3, we'd better write them back to the same registers, without compressing them to descriptors 0, 1, and 2. This was previously guaranteed by using the index into the pnp_resource_table array as the ISAPNP config register index. However, I am removing those fixed-size arrays, so we need to save the ISAPNP register index elsewhere. Signed-off-by: Bjorn Helgaas Signed-off-by: Len Brown --- drivers/pnp/interface.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index e9e66ed4fa3..ead151242a6 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -320,6 +320,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, const char *ubuf, size_t count) { struct pnp_dev *dev = to_pnp_dev(dmdev); + struct pnp_resource *pnp_res; struct resource *res; char *buf = (void *)ubuf; int retval = 0; @@ -380,10 +381,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 2; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_IO, - nport); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_IO, nport); + if (!pnp_res) break; + pnp_res->index = nport; + res = &pnp_res->res; res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; @@ -402,10 +405,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_MEM, - nmem); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_MEM, nmem); + if (!pnp_res) break; + pnp_res->index = nmem; + res = &pnp_res->res; res->start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; @@ -424,10 +429,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_IRQ, - nirq); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_IRQ, nirq); + if (!pnp_res) break; + pnp_res->index = nirq; + res = &pnp_res->res; res->start = res->end = simple_strtoul(buf, &buf, 0); res->flags = IORESOURCE_IRQ; @@ -438,10 +445,12 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - res = pnp_get_resource(dev, IORESOURCE_DMA, - ndma); - if (!res) + pnp_res = pnp_get_pnp_resource(dev, + IORESOURCE_DMA, ndma); + if (!pnp_res) break; + pnp_res->index = ndma; + res = &pnp_res->res; res->start = res->end = simple_strtoul(buf, &buf, 0); res->flags = IORESOURCE_DMA; -- cgit v1.2.3 From dbddd0383c59d588f8db5e773b062756e39117ec Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:34 -0600 Subject: PNP: make generic pnp_add_irq_resource() Add a pnp_add_irq_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 Signed-off-by: Len Brown --- drivers/pnp/interface.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index ead151242a6..e8134c28620 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -324,6 +324,7 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, struct resource *res; char *buf = (void *)ubuf; int retval = 0; + resource_size_t start; if (dev->status & PNP_ATTACHED) { retval = -EBUSY; @@ -429,16 +430,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_IRQ, nirq); - if (!pnp_res) - break; - pnp_res->index = nirq; - res = &pnp_res->res; - res->start = res->end = - simple_strtoul(buf, &buf, 0); - res->flags = IORESOURCE_IRQ; - nirq++; + start = simple_strtoul(buf, &buf, 0); + pnp_res = pnp_add_irq_resource(dev, start, 0); + if (pnp_res) + nirq++; continue; } if (!strnicmp(buf, "dma", 3)) { -- cgit v1.2.3 From dc16f5f2ede8cc2acf8ac22857a7fecf3a4296c2 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:35 -0600 Subject: 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 Signed-off-by: Len Brown --- drivers/pnp/interface.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index e8134c28620..00c8a970a97 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, buf += 3; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_DMA, ndma); - if (!pnp_res) - break; - pnp_res->index = ndma; - res = &pnp_res->res; - res->start = res->end = - simple_strtoul(buf, &buf, 0); - res->flags = IORESOURCE_DMA; - ndma++; + start = simple_strtoul(buf, &buf, 0); + pnp_res = pnp_add_dma_resource(dev, start, 0); + if (pnp_res) + pnp_res->index = ndma++; continue; } break; -- cgit v1.2.3 From cc8c2e308194f0997c718c7c735550ff06754d20 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:36 -0600 Subject: 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 Signed-off-by: Len Brown --- drivers/pnp/interface.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 00c8a970a97..77d8bf01b48 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, struct resource *res; char *buf = (void *)ubuf; int retval = 0; - resource_size_t start; + resource_size_t start, end; if (dev->status & PNP_ATTACHED) { retval = -EBUSY; @@ -382,24 +382,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 2; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_IO, nport); - if (!pnp_res) - break; - pnp_res->index = nport; - res = &pnp_res->res; - res->start = simple_strtoul(buf, &buf, 0); + start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; if (*buf == '-') { buf += 1; while (isspace(*buf)) ++buf; - res->end = simple_strtoul(buf, &buf, 0); + end = simple_strtoul(buf, &buf, 0); } else - res->end = res->start; - res->flags = IORESOURCE_IO; - nport++; + end = start; + pnp_res = pnp_add_io_resource(dev, start, end, + 0); + if (pnp_res) + pnp_res->index = nport++; continue; } if (!strnicmp(buf, "mem", 3)) { -- cgit v1.2.3 From d6180f36617953990bf90d4c1ff85b77e9995cd1 Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Mon, 28 Apr 2008 16:34:37 -0600 Subject: PNP: make generic pnp_add_mem_resource() Add a pnp_add_mem_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 Signed-off-by: Len Brown --- drivers/pnp/interface.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'drivers/pnp/interface.c') diff --git a/drivers/pnp/interface.c b/drivers/pnp/interface.c index 77d8bf01b48..5d9301de177 100644 --- a/drivers/pnp/interface.c +++ b/drivers/pnp/interface.c @@ -321,7 +321,6 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, { struct pnp_dev *dev = to_pnp_dev(dmdev); struct pnp_resource *pnp_res; - struct resource *res; char *buf = (void *)ubuf; int retval = 0; resource_size_t start, end; @@ -402,24 +401,20 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr, buf += 3; while (isspace(*buf)) ++buf; - pnp_res = pnp_get_pnp_resource(dev, - IORESOURCE_MEM, nmem); - if (!pnp_res) - break; - pnp_res->index = nmem; - res = &pnp_res->res; - res->start = simple_strtoul(buf, &buf, 0); + start = simple_strtoul(buf, &buf, 0); while (isspace(*buf)) ++buf; if (*buf == '-') { buf += 1; while (isspace(*buf)) ++buf; - res->end = simple_strtoul(buf, &buf, 0); + end = simple_strtoul(buf, &buf, 0); } else - res->end = res->start; - res->flags = IORESOURCE_MEM; - nmem++; + end = start; + pnp_res = pnp_add_mem_resource(dev, start, end, + 0); + if (pnp_res) + pnp_res->index = nmem++; continue; } if (!strnicmp(buf, "irq", 3)) { -- cgit v1.2.3