提交 06cb58a6 编写于 作者: B Bjorn Helgaas 提交者: Len Brown

PNP: remove pnp_resource_table references from resource decoders

This removes a few more references to the pnp_resource_table.
No functional change.
Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 02d83b5d
......@@ -931,7 +931,7 @@ EXPORT_SYMBOL(isapnp_write_byte);
static int isapnp_read_resources(struct pnp_dev *dev)
{
struct pnp_resource_table *res = dev->res;
struct resource *res;
int tmp, ret;
dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
......@@ -940,16 +940,18 @@ static int isapnp_read_resources(struct pnp_dev *dev)
ret = isapnp_read_word(ISAPNP_CFG_PORT + (tmp << 1));
if (!ret)
continue;
res->port_resource[tmp].start = ret;
res->port_resource[tmp].flags = IORESOURCE_IO;
res = pnp_get_resource(dev, IORESOURCE_IO, tmp);
res->start = ret;
res->flags = IORESOURCE_IO;
}
for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
ret =
isapnp_read_word(ISAPNP_CFG_MEM + (tmp << 3)) << 8;
if (!ret)
continue;
res->mem_resource[tmp].start = ret;
res->mem_resource[tmp].flags = IORESOURCE_MEM;
res = pnp_get_resource(dev, IORESOURCE_MEM, tmp);
res->start = ret;
res->flags = IORESOURCE_MEM;
}
for (tmp = 0; tmp < ISAPNP_MAX_IRQ; tmp++) {
ret =
......@@ -957,17 +959,17 @@ static int isapnp_read_resources(struct pnp_dev *dev)
8);
if (!ret)
continue;
res->irq_resource[tmp].start =
res->irq_resource[tmp].end = ret;
res->irq_resource[tmp].flags = IORESOURCE_IRQ;
res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp);
res->start = res->end = ret;
res->flags = IORESOURCE_IRQ;
}
for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
ret = isapnp_read_byte(ISAPNP_CFG_DMA + tmp);
if (ret == 4)
continue;
res->dma_resource[tmp].start =
res->dma_resource[tmp].end = ret;
res->dma_resource[tmp].flags = IORESOURCE_DMA;
res = pnp_get_resource(dev, IORESOURCE_DMA, tmp);
res->start = res->end = ret;
res->flags = IORESOURCE_DMA;
}
}
return 0;
......@@ -987,52 +989,47 @@ static int isapnp_get_resources(struct pnp_dev *dev)
static int isapnp_set_resources(struct pnp_dev *dev)
{
struct pnp_resource_table *res = dev->res;
struct resource *res;
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
&& (res->port_resource[tmp].
flags & (IORESOURCE_IO | IORESOURCE_UNSET)) == IORESOURCE_IO;
tmp++) {
dev_dbg(&dev->dev, " set io %d to %#llx\n",
tmp, (unsigned long long) res->port_resource[tmp].start);
isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
res->port_resource[tmp].start);
for (tmp = 0; tmp < ISAPNP_MAX_PORT; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_IO, tmp);
if (pnp_resource_valid(res)) {
dev_dbg(&dev->dev, " set io %d to %#llx\n",
tmp, (unsigned long long) res->start);
isapnp_write_word(ISAPNP_CFG_PORT + (tmp << 1),
res->start);
}
}
for (tmp = 0;
tmp < ISAPNP_MAX_IRQ
&& (res->irq_resource[tmp].
flags & (IORESOURCE_IRQ | IORESOURCE_UNSET)) == IORESOURCE_IRQ;
tmp++) {
int irq = res->irq_resource[tmp].start;
if (irq == 2)
irq = 9;
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_IRQ; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_IRQ, tmp);
if (pnp_resource_valid(res)) {
int irq = res->start;
if (irq == 2)
irq = 9;
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
&& (res->dma_resource[tmp].
flags & (IORESOURCE_DMA | IORESOURCE_UNSET)) == IORESOURCE_DMA;
tmp++) {
dev_dbg(&dev->dev, " set dma %d to %lld\n",
tmp, (unsigned long long) res->dma_resource[tmp].start);
isapnp_write_byte(ISAPNP_CFG_DMA + tmp,
res->dma_resource[tmp].start);
for (tmp = 0; tmp < ISAPNP_MAX_DMA; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_DMA, tmp);
if (pnp_resource_valid(res)) {
dev_dbg(&dev->dev, " set dma %d to %lld\n",
tmp, (unsigned long long) res->start);
isapnp_write_byte(ISAPNP_CFG_DMA + tmp, res->start);
}
}
for (tmp = 0;
tmp < ISAPNP_MAX_MEM
&& (res->mem_resource[tmp].
flags & (IORESOURCE_MEM | IORESOURCE_UNSET)) == IORESOURCE_MEM;
tmp++) {
dev_dbg(&dev->dev, " set mem %d to %#llx\n",
tmp, (unsigned long long) res->mem_resource[tmp].start);
isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
(res->mem_resource[tmp].start >> 8) & 0xffff);
for (tmp = 0; tmp < ISAPNP_MAX_MEM; tmp++) {
res = pnp_get_resource(dev, IORESOURCE_MEM, tmp);
if (pnp_resource_valid(res)) {
dev_dbg(&dev->dev, " set mem %d to %#llx\n",
tmp, (unsigned long long) res->start);
isapnp_write_word(ISAPNP_CFG_MEM + (tmp << 3),
(res->start >> 8) & 0xffff);
}
}
/* FIXME: We aren't handling 32bit mems properly here */
isapnp_activate(dev->number);
......
......@@ -82,8 +82,8 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
u32 gsi, int triggering,
int polarity, int shareable)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
int irq;
int p, t;
static unsigned char warned;
......@@ -91,9 +91,11 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
if (!valid_IRQ(gsi))
return;
while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) &&
i < PNP_MAX_IRQ)
i++;
for (i = 0; i < PNP_MAX_IRQ; i++) {
res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
if (!pnp_resource_valid(res))
break;
}
if (i >= PNP_MAX_IRQ) {
if (!warned) {
printk(KERN_WARNING "pnpacpi: exceeded the max number"
......@@ -119,16 +121,16 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
}
}
res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
res->irq_resource[i].flags |= irq_flags(triggering, polarity, shareable);
res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag
res->flags |= irq_flags(triggering, polarity, shareable);
irq = acpi_register_gsi(gsi, triggering, polarity);
if (irq < 0) {
res->irq_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->irq_resource[i].start = irq;
res->irq_resource[i].end = irq;
res->start = irq;
res->end = irq;
pcibios_penalize_isa_irq(irq, 1);
}
......@@ -178,22 +180,24 @@ static int dma_flags(int type, int bus_master, int transfer)
static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
u32 dma, int flags)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
static unsigned char warned;
while (i < PNP_MAX_DMA &&
!(res->dma_resource[i].flags & IORESOURCE_UNSET))
i++;
for (i = 0; i < PNP_MAX_DMA; i++) {
res = pnp_get_resource(dev, IORESOURCE_DMA, i);
if (!pnp_resource_valid(res))
break;
}
if (i < PNP_MAX_DMA) {
res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
res->dma_resource[i].flags |= flags;
res->flags = IORESOURCE_DMA; // Also clears _UNSET flag
res->flags |= flags;
if (dma == -1) {
res->dma_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->dma_resource[i].start = dma;
res->dma_resource[i].end = dma;
res->start = dma;
res->end = dma;
} else if (!warned) {
printk(KERN_WARNING "pnpacpi: exceeded the max number of DMA "
"resources: %d \n", PNP_MAX_DMA);
......@@ -204,23 +208,25 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
u64 io, u64 len, int io_decode)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
static unsigned char warned;
while (!(res->port_resource[i].flags & IORESOURCE_UNSET) &&
i < PNP_MAX_PORT)
i++;
for (i = 0; i < PNP_MAX_PORT; i++) {
res = pnp_get_resource(dev, IORESOURCE_IO, i);
if (!pnp_resource_valid(res))
break;
}
if (i < PNP_MAX_PORT) {
res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
res->flags = IORESOURCE_IO; // Also clears _UNSET flag
if (io_decode == ACPI_DECODE_16)
res->port_resource[i].flags |= PNP_PORT_FLAG_16BITADDR;
res->flags |= PNP_PORT_FLAG_16BITADDR;
if (len <= 0 || (io + len - 1) >= 0x10003) {
res->port_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->port_resource[i].start = io;
res->port_resource[i].end = io + len - 1;
res->start = io;
res->end = io + len - 1;
} else if (!warned) {
printk(KERN_WARNING "pnpacpi: exceeded the max number of IO "
"resources: %d \n", PNP_MAX_PORT);
......@@ -232,24 +238,26 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
u64 mem, u64 len,
int write_protect)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
static unsigned char warned;
while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) &&
(i < PNP_MAX_MEM))
i++;
for (i = 0; i < PNP_MAX_MEM; i++) {
res = pnp_get_resource(dev, IORESOURCE_MEM, i);
if (!pnp_resource_valid(res))
break;
}
if (i < PNP_MAX_MEM) {
res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
res->flags = IORESOURCE_MEM; // Also clears _UNSET flag
if (len <= 0) {
res->mem_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
if (write_protect == ACPI_READ_WRITE_MEMORY)
res->mem_resource[i].flags |= IORESOURCE_MEM_WRITEABLE;
res->flags |= IORESOURCE_MEM_WRITEABLE;
res->mem_resource[i].start = mem;
res->mem_resource[i].end = mem + len - 1;
res->start = mem;
res->end = mem + len - 1;
} else if (!warned) {
printk(KERN_WARNING "pnpacpi: exceeded the max number of mem "
"resources: %d\n", PNP_MAX_MEM);
......
......@@ -56,80 +56,90 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
for (i = 0; i < PNP_MAX_IRQ; i++) {
res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
if (!pnp_resource_valid(res))
break;
}
while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
&& i < PNP_MAX_IRQ)
i++;
if (i < PNP_MAX_IRQ) {
res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
res->flags = IORESOURCE_IRQ; // Also clears _UNSET flag
if (irq == -1) {
res->irq_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->irq_resource[i].start =
res->irq_resource[i].end = (unsigned long)irq;
res->start = res->end = (unsigned long)irq;
pcibios_penalize_isa_irq(irq, 1);
}
}
static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
for (i = 0; i < PNP_MAX_DMA; i++) {
res = pnp_get_resource(dev, IORESOURCE_DMA, i);
if (!pnp_resource_valid(res))
break;
}
while (i < PNP_MAX_DMA &&
!(res->dma_resource[i].flags & IORESOURCE_UNSET))
i++;
if (i < PNP_MAX_DMA) {
res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
res->flags = IORESOURCE_DMA; // Also clears _UNSET flag
if (dma == -1) {
res->dma_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->dma_resource[i].start =
res->dma_resource[i].end = (unsigned long)dma;
res->start = res->end = (unsigned long)dma;
}
}
static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
int io, int len)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
for (i = 0; i < PNP_MAX_PORT; i++) {
res = pnp_get_resource(dev, IORESOURCE_IO, i);
if (!pnp_resource_valid(res))
break;
}
while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
&& i < PNP_MAX_PORT)
i++;
if (i < PNP_MAX_PORT) {
res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
res->flags = IORESOURCE_IO; // Also clears _UNSET flag
if (len <= 0 || (io + len - 1) >= 0x10003) {
res->port_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->port_resource[i].start = (unsigned long)io;
res->port_resource[i].end = (unsigned long)(io + len - 1);
res->start = (unsigned long)io;
res->end = (unsigned long)(io + len - 1);
}
}
static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
int mem, int len)
{
struct pnp_resource_table *res = dev->res;
int i = 0;
struct resource *res;
int i;
for (i = 0; i < PNP_MAX_MEM; i++) {
res = pnp_get_resource(dev, IORESOURCE_MEM, i);
if (!pnp_resource_valid(res))
break;
}
while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
&& i < PNP_MAX_MEM)
i++;
if (i < PNP_MAX_MEM) {
res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
res->flags = IORESOURCE_MEM; // Also clears _UNSET flag
if (len <= 0) {
res->mem_resource[i].flags |= IORESOURCE_DISABLED;
res->flags |= IORESOURCE_DISABLED;
return;
}
res->mem_resource[i].start = (unsigned long)mem;
res->mem_resource[i].end = (unsigned long)(mem + len - 1);
res->start = (unsigned long)mem;
res->end = (unsigned long)(mem + len - 1);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册