]> err.no Git - linux-2.6/commitdiff
PNP: add pnp_new_resource() to find a new unset pnp_resource
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Mon, 28 Apr 2008 22:34:33 +0000 (16:34 -0600)
committerLen Brown <len.brown@intel.com>
Tue, 29 Apr 2008 07:22:28 +0000 (03:22 -0400)
This encapsulates the code to locate a new pnp_resource of the
desired type.  Currently this uses the pnp_resource_table, but
it will soon change to find a resource in a linked list.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/pnp/resource.c

index c57cfe51d52aab0da88270a93432c9fe0fbe5fa5..1f4134eea7b75dd1e9e90d98e012af5625f824a7 100644 (file)
@@ -538,6 +538,44 @@ struct resource *pnp_get_resource(struct pnp_dev *dev,
 }
 EXPORT_SYMBOL(pnp_get_resource);
 
+static struct pnp_resource *pnp_new_resource(struct pnp_dev *dev, int type)
+{
+       struct pnp_resource *pnp_res;
+       int i;
+
+       switch (type) {
+       case IORESOURCE_IO:
+               for (i = 0; i < PNP_MAX_PORT; i++) {
+                       pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IO, i);
+                       if (pnp_res && !pnp_resource_valid(&pnp_res->res))
+                               return pnp_res;
+               }
+               break;
+       case IORESOURCE_MEM:
+               for (i = 0; i < PNP_MAX_MEM; i++) {
+                       pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_MEM, i);
+                       if (pnp_res && !pnp_resource_valid(&pnp_res->res))
+                               return pnp_res;
+               }
+               break;
+       case IORESOURCE_IRQ:
+               for (i = 0; i < PNP_MAX_IRQ; i++) {
+                       pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_IRQ, i);
+                       if (pnp_res && !pnp_resource_valid(&pnp_res->res))
+                               return pnp_res;
+               }
+               break;
+       case IORESOURCE_DMA:
+               for (i = 0; i < PNP_MAX_DMA; i++) {
+                       pnp_res = pnp_get_pnp_resource(dev, IORESOURCE_DMA, i);
+                       if (pnp_res && !pnp_resource_valid(&pnp_res->res))
+                               return pnp_res;
+               }
+               break;
+       }
+       return NULL;
+}
+
 /* format is: pnp_reserve_irq=irq1[,irq2] .... */
 static int __init pnp_setup_reserve_irq(char *str)
 {