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 <bjorn.helgaas@hp.com> Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
f6505fef18
commit
95ab3669f7
|
@ -248,6 +248,7 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct pnp_dev *dev = to_pnp_dev(dmdev);
|
struct pnp_dev *dev = to_pnp_dev(dmdev);
|
||||||
|
struct resource *res;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
pnp_info_buffer_t *buffer;
|
pnp_info_buffer_t *buffer;
|
||||||
|
|
||||||
|
@ -267,50 +268,46 @@ static ssize_t pnp_show_current_resources(struct device *dmdev,
|
||||||
else
|
else
|
||||||
pnp_printf(buffer, "disabled\n");
|
pnp_printf(buffer, "disabled\n");
|
||||||
|
|
||||||
for (i = 0; i < PNP_MAX_PORT; i++) {
|
for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
|
||||||
if (pnp_port_valid(dev, i)) {
|
if (pnp_resource_valid(res)) {
|
||||||
pnp_printf(buffer, "io");
|
pnp_printf(buffer, "io");
|
||||||
if (pnp_port_flags(dev, i) & IORESOURCE_DISABLED)
|
if (res->flags & IORESOURCE_DISABLED)
|
||||||
pnp_printf(buffer, " disabled\n");
|
pnp_printf(buffer, " disabled\n");
|
||||||
else
|
else
|
||||||
pnp_printf(buffer, " 0x%llx-0x%llx\n",
|
pnp_printf(buffer, " 0x%llx-0x%llx\n",
|
||||||
(unsigned long long)
|
(unsigned long long) res->start,
|
||||||
pnp_port_start(dev, i),
|
(unsigned long long) res->end);
|
||||||
(unsigned long long)pnp_port_end(dev,
|
|
||||||
i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < PNP_MAX_MEM; i++) {
|
for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
|
||||||
if (pnp_mem_valid(dev, i)) {
|
if (pnp_resource_valid(res)) {
|
||||||
pnp_printf(buffer, "mem");
|
pnp_printf(buffer, "mem");
|
||||||
if (pnp_mem_flags(dev, i) & IORESOURCE_DISABLED)
|
if (res->flags & IORESOURCE_DISABLED)
|
||||||
pnp_printf(buffer, " disabled\n");
|
pnp_printf(buffer, " disabled\n");
|
||||||
else
|
else
|
||||||
pnp_printf(buffer, " 0x%llx-0x%llx\n",
|
pnp_printf(buffer, " 0x%llx-0x%llx\n",
|
||||||
(unsigned long long)
|
(unsigned long long) res->start,
|
||||||
pnp_mem_start(dev, i),
|
(unsigned long long) res->end);
|
||||||
(unsigned long long)pnp_mem_end(dev,
|
|
||||||
i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < PNP_MAX_IRQ; i++) {
|
for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
|
||||||
if (pnp_irq_valid(dev, i)) {
|
if (pnp_resource_valid(res)) {
|
||||||
pnp_printf(buffer, "irq");
|
pnp_printf(buffer, "irq");
|
||||||
if (pnp_irq_flags(dev, i) & IORESOURCE_DISABLED)
|
if (res->flags & IORESOURCE_DISABLED)
|
||||||
pnp_printf(buffer, " disabled\n");
|
pnp_printf(buffer, " disabled\n");
|
||||||
else
|
else
|
||||||
pnp_printf(buffer, " %lld\n",
|
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++) {
|
for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
|
||||||
if (pnp_dma_valid(dev, i)) {
|
if (pnp_resource_valid(res)) {
|
||||||
pnp_printf(buffer, "dma");
|
pnp_printf(buffer, "dma");
|
||||||
if (pnp_dma_flags(dev, i) & IORESOURCE_DISABLED)
|
if (res->flags & IORESOURCE_DISABLED)
|
||||||
pnp_printf(buffer, " disabled\n");
|
pnp_printf(buffer, " disabled\n");
|
||||||
else
|
else
|
||||||
pnp_printf(buffer, " %lld\n",
|
pnp_printf(buffer, " %lld\n",
|
||||||
(unsigned long long)pnp_dma(dev, i));
|
(unsigned long long) res->start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ret = (buffer->curr - buf);
|
ret = (buffer->curr - buf);
|
||||||
|
|
|
@ -138,13 +138,15 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
|
||||||
|
|
||||||
pci_start = pci_resource_start(pdev, i);
|
pci_start = pci_resource_start(pdev, i);
|
||||||
pci_end = pci_resource_end(pdev, i);
|
pci_end = pci_resource_end(pdev, i);
|
||||||
for (j = 0; j < PNP_MAX_MEM; j++) {
|
for (j = 0;
|
||||||
if (!pnp_mem_valid(dev, j) ||
|
(res = pnp_get_resource(dev, IORESOURCE_MEM, j));
|
||||||
pnp_mem_len(dev, j) == 0)
|
j++) {
|
||||||
|
if (res->flags & IORESOURCE_UNSET ||
|
||||||
|
(res->start == 0 && res->end == 0))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
pnp_start = pnp_mem_start(dev, j);
|
pnp_start = res->start;
|
||||||
pnp_end = pnp_mem_end(dev, j);
|
pnp_end = res->end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the PNP region doesn't overlap the PCI
|
* If the PNP region doesn't overlap the PCI
|
||||||
|
@ -177,7 +179,6 @@ static void quirk_system_pci_resources(struct pnp_dev *dev)
|
||||||
pci_name(pdev), i,
|
pci_name(pdev), i,
|
||||||
(unsigned long long) pci_start,
|
(unsigned long long) pci_start,
|
||||||
(unsigned long long) pci_end);
|
(unsigned long long) pci_end);
|
||||||
res = pnp_get_resource(dev, IORESOURCE_MEM, j);
|
|
||||||
res->flags = 0;
|
res->flags = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,9 +269,8 @@ int pnp_check_port(struct pnp_dev *dev, struct resource *res)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for internal conflicts */
|
/* check for internal conflicts */
|
||||||
for (i = 0; i < PNP_MAX_PORT; i++) {
|
for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
|
||||||
tres = pnp_get_resource(dev, IORESOURCE_IO, i);
|
if (tres != res && tres->flags & IORESOURCE_IO) {
|
||||||
if (tres && tres != res && tres->flags & IORESOURCE_IO) {
|
|
||||||
tport = &tres->start;
|
tport = &tres->start;
|
||||||
tend = &tres->end;
|
tend = &tres->end;
|
||||||
if (ranged_conflict(port, end, tport, tend))
|
if (ranged_conflict(port, end, tport, tend))
|
||||||
|
@ -283,9 +282,10 @@ int pnp_check_port(struct pnp_dev *dev, struct resource *res)
|
||||||
pnp_for_each_dev(tdev) {
|
pnp_for_each_dev(tdev) {
|
||||||
if (tdev == dev)
|
if (tdev == dev)
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < PNP_MAX_PORT; i++) {
|
for (i = 0;
|
||||||
tres = pnp_get_resource(tdev, IORESOURCE_IO, i);
|
(tres = pnp_get_resource(tdev, IORESOURCE_IO, i));
|
||||||
if (tres && tres->flags & IORESOURCE_IO) {
|
i++) {
|
||||||
|
if (tres->flags & IORESOURCE_IO) {
|
||||||
if (cannot_compare(tres->flags))
|
if (cannot_compare(tres->flags))
|
||||||
continue;
|
continue;
|
||||||
tport = &tres->start;
|
tport = &tres->start;
|
||||||
|
@ -329,9 +329,8 @@ int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for internal conflicts */
|
/* check for internal conflicts */
|
||||||
for (i = 0; i < PNP_MAX_MEM; i++) {
|
for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
|
||||||
tres = pnp_get_resource(dev, IORESOURCE_MEM, i);
|
if (tres != res && tres->flags & IORESOURCE_MEM) {
|
||||||
if (tres && tres != res && tres->flags & IORESOURCE_MEM) {
|
|
||||||
taddr = &tres->start;
|
taddr = &tres->start;
|
||||||
tend = &tres->end;
|
tend = &tres->end;
|
||||||
if (ranged_conflict(addr, end, taddr, tend))
|
if (ranged_conflict(addr, end, taddr, tend))
|
||||||
|
@ -343,9 +342,10 @@ int pnp_check_mem(struct pnp_dev *dev, struct resource *res)
|
||||||
pnp_for_each_dev(tdev) {
|
pnp_for_each_dev(tdev) {
|
||||||
if (tdev == dev)
|
if (tdev == dev)
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < PNP_MAX_MEM; i++) {
|
for (i = 0;
|
||||||
tres = pnp_get_resource(tdev, IORESOURCE_MEM, i);
|
(tres = pnp_get_resource(tdev, IORESOURCE_MEM, i));
|
||||||
if (tres && tres->flags & IORESOURCE_MEM) {
|
i++) {
|
||||||
|
if (tres->flags & IORESOURCE_MEM) {
|
||||||
if (cannot_compare(tres->flags))
|
if (cannot_compare(tres->flags))
|
||||||
continue;
|
continue;
|
||||||
taddr = &tres->start;
|
taddr = &tres->start;
|
||||||
|
@ -388,9 +388,8 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for internal conflicts */
|
/* check for internal conflicts */
|
||||||
for (i = 0; i < PNP_MAX_IRQ; i++) {
|
for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_IRQ, i)); i++) {
|
||||||
tres = pnp_get_resource(dev, IORESOURCE_IRQ, i);
|
if (tres != res && tres->flags & IORESOURCE_IRQ) {
|
||||||
if (tres && tres != res && tres->flags & IORESOURCE_IRQ) {
|
|
||||||
if (tres->start == *irq)
|
if (tres->start == *irq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -422,9 +421,10 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
|
||||||
pnp_for_each_dev(tdev) {
|
pnp_for_each_dev(tdev) {
|
||||||
if (tdev == dev)
|
if (tdev == dev)
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < PNP_MAX_IRQ; i++) {
|
for (i = 0;
|
||||||
tres = pnp_get_resource(tdev, IORESOURCE_IRQ, i);
|
(tres = pnp_get_resource(tdev, IORESOURCE_IRQ, i));
|
||||||
if (tres && tres->flags & IORESOURCE_IRQ) {
|
i++) {
|
||||||
|
if (tres->flags & IORESOURCE_IRQ) {
|
||||||
if (cannot_compare(tres->flags))
|
if (cannot_compare(tres->flags))
|
||||||
continue;
|
continue;
|
||||||
if (tres->start == *irq)
|
if (tres->start == *irq)
|
||||||
|
@ -461,9 +461,8 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check for internal conflicts */
|
/* check for internal conflicts */
|
||||||
for (i = 0; i < PNP_MAX_DMA; i++) {
|
for (i = 0; (tres = pnp_get_resource(dev, IORESOURCE_DMA, i)); i++) {
|
||||||
tres = pnp_get_resource(dev, IORESOURCE_DMA, i);
|
if (tres != res && tres->flags & IORESOURCE_DMA) {
|
||||||
if (tres && tres != res && tres->flags & IORESOURCE_DMA) {
|
|
||||||
if (tres->start == *dma)
|
if (tres->start == *dma)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -481,9 +480,10 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
|
||||||
pnp_for_each_dev(tdev) {
|
pnp_for_each_dev(tdev) {
|
||||||
if (tdev == dev)
|
if (tdev == dev)
|
||||||
continue;
|
continue;
|
||||||
for (i = 0; i < PNP_MAX_DMA; i++) {
|
for (i = 0;
|
||||||
tres = pnp_get_resource(tdev, IORESOURCE_DMA, i);
|
(tres = pnp_get_resource(tdev, IORESOURCE_DMA, i));
|
||||||
if (tres && tres->flags & IORESOURCE_DMA) {
|
i++) {
|
||||||
|
if (tres->flags & IORESOURCE_DMA) {
|
||||||
if (cannot_compare(tres->flags))
|
if (cannot_compare(tres->flags))
|
||||||
continue;
|
continue;
|
||||||
if (tres->start == *dma)
|
if (tres->start == *dma)
|
||||||
|
|
|
@ -56,14 +56,15 @@ static void reserve_range(struct pnp_dev *dev, resource_size_t start,
|
||||||
|
|
||||||
static void reserve_resources_of_dev(struct pnp_dev *dev)
|
static void reserve_resources_of_dev(struct pnp_dev *dev)
|
||||||
{
|
{
|
||||||
|
struct resource *res;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < PNP_MAX_PORT; i++) {
|
for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_IO, i)); i++) {
|
||||||
if (!pnp_port_valid(dev, i))
|
if (res->flags & IORESOURCE_UNSET)
|
||||||
continue;
|
continue;
|
||||||
if (pnp_port_start(dev, i) == 0)
|
if (res->start == 0)
|
||||||
continue; /* disabled */
|
continue; /* disabled */
|
||||||
if (pnp_port_start(dev, i) < 0x100)
|
if (res->start < 0x100)
|
||||||
/*
|
/*
|
||||||
* Below 0x100 is only standard PC hardware
|
* Below 0x100 is only standard PC hardware
|
||||||
* (pics, kbd, timer, dma, ...)
|
* (pics, kbd, timer, dma, ...)
|
||||||
|
@ -73,19 +74,17 @@ static void reserve_resources_of_dev(struct pnp_dev *dev)
|
||||||
* So, do nothing
|
* So, do nothing
|
||||||
*/
|
*/
|
||||||
continue;
|
continue;
|
||||||
if (pnp_port_end(dev, i) < pnp_port_start(dev, i))
|
if (res->end < res->start)
|
||||||
continue; /* invalid */
|
continue; /* invalid */
|
||||||
|
|
||||||
reserve_range(dev, pnp_port_start(dev, i),
|
reserve_range(dev, res->start, res->end, 1);
|
||||||
pnp_port_end(dev, i), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < PNP_MAX_MEM; i++) {
|
for (i = 0; (res = pnp_get_resource(dev, IORESOURCE_MEM, i)); i++) {
|
||||||
if (!pnp_mem_valid(dev, i))
|
if (res->flags & IORESOURCE_UNSET)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
reserve_range(dev, pnp_mem_start(dev, i),
|
reserve_range(dev, res->start, res->end, 0);
|
||||||
pnp_mem_end(dev, i), 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue