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 e9e66ed..ead1512 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.1