diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c index f1fdd96..21719e5 100644 --- a/drivers/pnp/resource.c +++ b/drivers/pnp/resource.c @@ -219,13 +219,14 @@ int pnp_check_port(struct pnp_dev *dev, int idx) struct pnp_dev *tdev; resource_size_t *port, *end, *tport, *tend; - port = &dev->res.port_resource[idx].start; - end = &dev->res.port_resource[idx].end; - /* if the resource doesn't exist, don't complain about it */ - if (cannot_compare(dev->res.port_resource[idx].flags)) + if (!pnp_port_ok(dev, idx) || + cannot_compare(dev->res.port_resource[idx].flags)) return 1; + port = &dev->res.port_resource[idx].start; + end = &dev->res.port_resource[idx].end; + /* check if the resource is already in use, skip if the * device is active because it itself may be in use */ if (!dev->active) { @@ -277,13 +278,14 @@ int pnp_check_mem(struct pnp_dev *dev, int idx) struct pnp_dev *tdev; resource_size_t *addr, *end, *taddr, *tend; - addr = &dev->res.mem_resource[idx].start; - end = &dev->res.mem_resource[idx].end; - /* if the resource doesn't exist, don't complain about it */ - if (cannot_compare(dev->res.mem_resource[idx].flags)) + if (!pnp_mem_ok(dev, idx) || + cannot_compare(dev->res.mem_resource[idx].flags)) return 1; + addr = &dev->res.mem_resource[idx].start; + end = &dev->res.mem_resource[idx].end; + /* check if the resource is already in use, skip if the * device is active because it itself may be in use */ if (!dev->active) { @@ -338,12 +340,15 @@ int pnp_check_irq(struct pnp_dev *dev, int idx) { int tmp; struct pnp_dev *tdev; - resource_size_t *irq = &dev->res.irq_resource[idx].start; + resource_size_t *irq; /* if the resource doesn't exist, don't complain about it */ - if (cannot_compare(dev->res.irq_resource[idx].flags)) + if (!pnp_irq_ok(dev, idx) || + cannot_compare(dev->res.irq_resource[idx].flags)) return 1; + irq = &dev->res.irq_resource[idx].start; + /* check if the resource is valid */ if (*irq < 0 || *irq > 15) return 0; @@ -407,12 +412,15 @@ int pnp_check_dma(struct pnp_dev *dev, int idx) #ifndef CONFIG_IA64 int tmp; struct pnp_dev *tdev; - resource_size_t *dma = &dev->res.dma_resource[idx].start; + resource_size_t *dma; /* if the resource doesn't exist, don't complain about it */ - if (cannot_compare(dev->res.dma_resource[idx].flags)) + if (!pnp_dma_ok(dev, idx) || + cannot_compare(dev->res.dma_resource[idx].flags)) return 1; + dma = &dev->res.dma_resource[idx].start; + /* check if the resource is valid */ if (*dma < 0 || *dma == 4 || *dma > 7) return 0;