]> err.no Git - linux-2.6/commitdiff
PNP: convert assign, interface to use pnp_get_resource(), not pnp_resource_table
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Mon, 28 Apr 2008 22:34:25 +0000 (16:34 -0600)
committerLen Brown <len.brown@intel.com>
Tue, 29 Apr 2008 07:22:26 +0000 (03:22 -0400)
This removes more direct references to pnp_resource_table from the
pnp_assign_resources() path and the /sys user interface path.

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

index 1801df3db1e83f16c8d73fd32ce711dd5bf86fac..a608054a3e5304ae9e7d00fd0a72c6369edd8c25 100644 (file)
@@ -383,7 +383,10 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
                                buf += 2;
                                while (isspace(*buf))
                                        ++buf;
-                               res = &dev->res.port_resource[nport];
+                               res = pnp_get_resource(dev, IORESOURCE_IO,
+                                                      nport);
+                               if (!res)
+                                       break;
                                res->start = simple_strtoul(buf, &buf, 0);
                                while (isspace(*buf))
                                        ++buf;
@@ -396,15 +399,16 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
                                        res->end = res->start;
                                res->flags = IORESOURCE_IO;
                                nport++;
-                               if (nport >= PNP_MAX_PORT)
-                                       break;
                                continue;
                        }
                        if (!strnicmp(buf, "mem", 3)) {
                                buf += 3;
                                while (isspace(*buf))
                                        ++buf;
-                               res = &dev->res.mem_resource[nmem];
+                               res = pnp_get_resource(dev, IORESOURCE_MEM,
+                                                      nmem);
+                               if (!res)
+                                       break;
                                res->start = simple_strtoul(buf, &buf, 0);
                                while (isspace(*buf))
                                        ++buf;
@@ -417,34 +421,34 @@ pnp_set_current_resources(struct device *dmdev, struct device_attribute *attr,
                                        res->end = res->start;
                                res->flags = IORESOURCE_MEM;
                                nmem++;
-                               if (nmem >= PNP_MAX_MEM)
-                                       break;
                                continue;
                        }
                        if (!strnicmp(buf, "irq", 3)) {
                                buf += 3;
                                while (isspace(*buf))
                                        ++buf;
-                               res = &dev->res.irq_resource[nirq];
+                               res = pnp_get_resource(dev, IORESOURCE_IRQ,
+                                                      nirq);
+                               if (!res)
+                                       break;
                                res->start = res->end =
                                    simple_strtoul(buf, &buf, 0);
                                res->flags = IORESOURCE_IRQ;
                                nirq++;
-                               if (nirq >= PNP_MAX_IRQ)
-                                       break;
                                continue;
                        }
                        if (!strnicmp(buf, "dma", 3)) {
                                buf += 3;
                                while (isspace(*buf))
                                        ++buf;
-                               res = &dev->res.dma_resource[ndma];
+                               res = pnp_get_resource(dev, IORESOURCE_DMA,
+                                                      ndma);
+                               if (!res)
+                                       break;
                                res->start = res->end =
                                    simple_strtoul(buf, &buf, 0);
                                res->flags = IORESOURCE_DMA;
                                ndma++;
-                               if (ndma >= PNP_MAX_DMA)
-                                       break;
                                continue;
                        }
                        break;
index 08865292fc958c390c51ae68561766cf33a66754..7c5ebddfc6afa71695a0b71155e219bca6ab0e0c 100644 (file)
@@ -21,14 +21,13 @@ static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
 {
        struct resource *res;
 
-       if (idx >= PNP_MAX_PORT) {
+       res = pnp_get_resource(dev, IORESOURCE_IO, idx);
+       if (!res) {
                dev_err(&dev->dev, "too many I/O port resources\n");
                /* pretend we were successful so at least the manager won't try again */
                return 1;
        }
 
-       res = &dev->res.port_resource[idx];
-
        /* check if this resource has been manually set, if so skip */
        if (!(res->flags & IORESOURCE_AUTO)) {
                dev_dbg(&dev->dev, "  io %d already set to %#llx-%#llx "
@@ -68,14 +67,13 @@ static int pnp_assign_mem(struct pnp_dev *dev, struct pnp_mem *rule, int idx)
 {
        struct resource *res;
 
-       if (idx >= PNP_MAX_MEM) {
+       res = pnp_get_resource(dev, IORESOURCE_MEM, idx);
+       if (!res) {
                dev_err(&dev->dev, "too many memory resources\n");
                /* pretend we were successful so at least the manager won't try again */
                return 1;
        }
 
-       res = &dev->res.mem_resource[idx];
-
        /* check if this resource has been manually set, if so skip */
        if (!(res->flags & IORESOURCE_AUTO)) {
                dev_dbg(&dev->dev, "  mem %d already set to %#llx-%#llx "
@@ -131,14 +129,13 @@ static int pnp_assign_irq(struct pnp_dev *dev, struct pnp_irq *rule, int idx)
                5, 10, 11, 12, 9, 14, 15, 7, 3, 4, 13, 0, 1, 6, 8, 2
        };
 
-       if (idx >= PNP_MAX_IRQ) {
+       res = pnp_get_resource(dev, IORESOURCE_IRQ, idx);
+       if (!res) {
                dev_err(&dev->dev, "too many IRQ resources\n");
                /* pretend we were successful so at least the manager won't try again */
                return 1;
        }
 
-       res = &dev->res.irq_resource[idx];
-
        /* check if this resource has been manually set, if so skip */
        if (!(res->flags & IORESOURCE_AUTO)) {
                dev_dbg(&dev->dev, "  irq %d already set to %d flags %#lx\n",
@@ -188,13 +185,12 @@ static void pnp_assign_dma(struct pnp_dev *dev, struct pnp_dma *rule, int idx)
                1, 3, 5, 6, 7, 0, 2, 4
        };
 
-       if (idx >= PNP_MAX_DMA) {
+       res = pnp_get_resource(dev, IORESOURCE_DMA, idx);
+       if (!res) {
                dev_err(&dev->dev, "too many DMA resources\n");
                return;
        }
 
-       res = &dev->res.dma_resource[idx];
-
        /* check if this resource has been manually set, if so skip */
        if (!(res->flags & IORESOURCE_AUTO)) {
                dev_dbg(&dev->dev, "  dma %d already set to %d flags %#lx\n",
index 3aeb154e27d6be240642f9c98d03a796e4a774a4..3eba85ed729cfb28634e9bdc65f91adb066080c8 100644 (file)
@@ -61,27 +61,27 @@ void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc)
        dev_dbg(&dev->dev, "current resources: %s\n", desc);
 
        for (i = 0; i < PNP_MAX_IRQ; i++) {
-               res = &dev->res.irq_resource[i];
-               if (!(res->flags & IORESOURCE_UNSET))
+               res = pnp_get_resource(dev, IORESOURCE_IRQ, i);
+               if (res && !(res->flags & IORESOURCE_UNSET))
                        dev_dbg(&dev->dev, "  irq %lld flags %#lx\n",
                                (unsigned long long) res->start, res->flags);
        }
        for (i = 0; i < PNP_MAX_DMA; i++) {
-               res = &dev->res.dma_resource[i];
-               if (!(res->flags & IORESOURCE_UNSET))
+               res = pnp_get_resource(dev, IORESOURCE_DMA, i);
+               if (res && !(res->flags & IORESOURCE_UNSET))
                        dev_dbg(&dev->dev, "  dma %lld flags %#lx\n",
                                (unsigned long long) res->start, res->flags);
        }
        for (i = 0; i < PNP_MAX_PORT; i++) {
-               res = &dev->res.port_resource[i];
-               if (!(res->flags & IORESOURCE_UNSET))
+               res = pnp_get_resource(dev, IORESOURCE_IO, i);
+               if (res && !(res->flags & IORESOURCE_UNSET))
                        dev_dbg(&dev->dev, "  io  %#llx-%#llx flags %#lx\n",
                                (unsigned long long) res->start,
                                (unsigned long long) res->end, res->flags);
        }
        for (i = 0; i < PNP_MAX_MEM; i++) {
-               res = &dev->res.mem_resource[i];
-               if (!(res->flags & IORESOURCE_UNSET))
+               res = pnp_get_resource(dev, IORESOURCE_MEM, i);
+               if (res && !(res->flags & IORESOURCE_UNSET))
                        dev_dbg(&dev->dev, "  mem %#llx-%#llx flags %#lx\n",
                                (unsigned long long) res->start,
                                (unsigned long long) res->end, res->flags);