aboutsummaryrefslogtreecommitdiff
path: root/drivers/pnp/isapnp
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-06-27 16:56:53 -0600
committerAndi Kleen <andi@basil.nowhere.org>2008-07-16 23:27:05 +0200
commit87e4acf3ebc02c9d0a2f7a37b655c49176c4d765 (patch)
tree1d5ee98084c9de22d2de95dad84ae23a188f6429 /drivers/pnp/isapnp
parentb897f46cf7941fff8130ccdaf85f39528bff6a51 (diff)
PNP: remove pnp_resource.index
We used pnp_resource.index to keep track of which ISAPNP configuration register a resource should be written to. We needed this only to handle the case where a register is disabled but a subsequent register in the same set is enabled. Rather than explicitly maintaining the pnp_resource.index, this patch adds a resource every time we read an ISAPNP configuration register and marks the resource as IORESOURCE_DISABLED when appropriate. This makes the position in the pnp_resource_table always correspond to the config register index. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'drivers/pnp/isapnp')
-rw-r--r--drivers/pnp/isapnp/core.c84
1 files changed, 29 insertions, 55 deletions
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index f1bccdbdeb0..752b51fbaa6 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -928,7 +928,6 @@ EXPORT_SYMBOL(isapnp_write_byte);
static int isapnp_get_resources(struct pnp_dev *dev)
{
- struct pnp_resource *pnp_res;
int i, ret;
dev_dbg(&dev->dev, "get resources\n");
@@ -940,35 +939,23 @@ static int isapnp_get_resources(struct pnp_dev *dev)
for (i = 0; i < ISAPNP_MAX_PORT; i++) {
ret = isapnp_read_word(ISAPNP_CFG_PORT + (i << 1));
- if (ret) {
- pnp_res = pnp_add_io_resource(dev, ret, ret, 0);
- if (pnp_res)
- pnp_res->index = i;
- }
+ pnp_add_io_resource(dev, ret, ret,
+ ret == 0 ? IORESOURCE_DISABLED : 0);
}
for (i = 0; i < ISAPNP_MAX_MEM; i++) {
ret = isapnp_read_word(ISAPNP_CFG_MEM + (i << 3)) << 8;
- if (ret) {
- pnp_res = pnp_add_mem_resource(dev, ret, ret, 0);
- if (pnp_res)
- pnp_res->index = i;
- }
+ pnp_add_mem_resource(dev, ret, ret,
+ ret == 0 ? IORESOURCE_DISABLED : 0);
}
for (i = 0; i < ISAPNP_MAX_IRQ; i++) {
ret = isapnp_read_word(ISAPNP_CFG_IRQ + (i << 1)) >> 8;
- if (ret) {
- pnp_res = pnp_add_irq_resource(dev, ret, 0);
- if (pnp_res)
- pnp_res->index = i;
- }
+ pnp_add_irq_resource(dev, ret,
+ ret == 0 ? IORESOURCE_DISABLED : 0);
}
for (i = 0; i < ISAPNP_MAX_DMA; i++) {
ret = isapnp_read_byte(ISAPNP_CFG_DMA + i);
- if (ret != 4) {
- pnp_res = pnp_add_dma_resource(dev, ret, 0);
- if (pnp_res)
- pnp_res->index = i;
- }
+ pnp_add_dma_resource(dev, ret,
+ ret == 4 ? IORESOURCE_DISABLED : 0);
}
__end:
@@ -978,62 +965,49 @@ __end:
static int isapnp_set_resources(struct pnp_dev *dev)
{
- struct pnp_resource *pnp_res;
struct resource *res;
- int tmp, index;
+ int tmp;
dev_dbg(&dev->dev, "set resources\n");
isapnp_cfg_begin(dev->card->number, dev->number);
dev->active = 1;
for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
- pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, tmp);
- if (!pnp_res)
- continue;
- res = &pnp_res->res;
- if (pnp_resource_valid(res)) {
- index = pnp_res->index;
+ res = pnp_get_resource(dev, IORESOURCE_IO, tmp);
+ if (res && pnp_resource_valid(res) &&
+ !(res->flags & IORESOURCE_DISABLED)) {
dev_dbg(&dev->dev, " set io %d to %#llx\n",
- index, (unsigned long long) res->start);
- isapnp_write_word(ISAPNP_CFG_PORT + (index << 1),
+ tmp, (unsigned long long) res->start);
+ isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
res->start);
}
}
for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
- pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, tmp);
- if (!pnp_res)
- continue;
- res = &pnp_res->res;
- if (pnp_resource_valid(res)) {
+ res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp);
+ if (res && pnp_resource_valid(res) &&
+ !(res->flags & IORESOURCE_DISABLED)) {
int irq = res->start;
if (irq == 2)
irq = 9;
- index = pnp_res->index;
- dev_dbg(&dev->dev, " set irq %d to %d\n", index, irq);
- isapnp_write_byte(ISAPNP_CFG_IRQ + (index << 1), irq);
+ dev_dbg(&dev->dev, " set irq %d to %d\n", tmp, irq);
+ isapnp_write_byte(ISAPNP_CFG_IRQ + (tmp << 1), irq);
}
}
for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
- pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, tmp);
- if (!pnp_res)
- continue;
- res = &pnp_res->res;
- if (pnp_resource_valid(res)) {
- index = pnp_res->index;
+ res = pnp_get_resource(dev, IORESOURCE_DMA, tmp);
+ if (res && pnp_resource_valid(res) &&
+ !(res->flags & IORESOURCE_DISABLED)) {
dev_dbg(&dev->dev, " set dma %d to %lld\n",
- index, (unsigned long long) res->start);
- isapnp_write_byte(ISAPNP_CFG_DMA + index, res->start);
+ tmp, (unsigned long long) res->start);
+ isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start);
}
}
for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
- pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, tmp);
- if (!pnp_res)
- continue;
- res = &pnp_res->res;
- if (pnp_resource_valid(res)) {
- index = pnp_res->index;
+ res = pnp_get_resource(dev, IORESOURCE_MEM, tmp);
+ if (res && pnp_resource_valid(res) &&
+ !(res->flags & IORESOURCE_DISABLED)) {
dev_dbg(&dev->dev, " set mem %d to %#llx\n",
- index, (unsigned long long) res->start);
- isapnp_write_word(ISAPNP_CFG_MEM + (index << 3),
+ tmp, (unsigned long long) res->start);
+ isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
(res->start >> 8) & 0xffff);
}
}