]> err.no Git - linux-2.6/commitdiff
PNP: make pnp_resource_table private to PNP core
authorBjorn Helgaas <bjorn.helgaas@hp.com>
Mon, 28 Apr 2008 22:34:28 +0000 (16:34 -0600)
committerLen Brown <len.brown@intel.com>
Tue, 29 Apr 2008 07:22:27 +0000 (03:22 -0400)
There are no remaining references to the PNP_MAX_* constants or
the pnp_resource_table structure outside of the PNP core.  Make
them private to the PNP core.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/pnp/base.h
drivers/pnp/core.c
drivers/pnp/isapnp/core.c
drivers/pnp/manager.c
drivers/pnp/pnpacpi/rsparser.c
drivers/pnp/pnpbios/rsparser.c
drivers/pnp/resource.c
include/linux/pnp.h

index e739d4bba42354d420cff9de67a6c4cec4a2b387..b888a5fb6b7f2dbf62a661030950a1982780dab9 100644 (file)
@@ -20,3 +20,15 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res);
 void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
 
 void pnp_init_resource(struct resource *res);
+
+#define PNP_MAX_PORT           40
+#define PNP_MAX_MEM            24
+#define PNP_MAX_IRQ             2
+#define PNP_MAX_DMA             2
+
+struct pnp_resource_table {
+       struct resource port_resource[PNP_MAX_PORT];
+       struct resource mem_resource[PNP_MAX_MEM];
+       struct resource dma_resource[PNP_MAX_DMA];
+       struct resource irq_resource[PNP_MAX_IRQ];
+};
index cf37701a4f9ee4f2f7e6aef734f37ecc13d4292b..20771b7d4482562d18536aca252f9e870b08f907 100644 (file)
@@ -106,6 +106,7 @@ static void pnp_release_device(struct device *dmdev)
        pnp_free_option(dev->independent);
        pnp_free_option(dev->dependent);
        pnp_free_ids(dev);
+       kfree(dev->res);
        kfree(dev);
 }
 
@@ -118,6 +119,12 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
        if (!dev)
                return NULL;
 
+       dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
+       if (!dev->res) {
+               kfree(dev);
+               return NULL;
+       }
+
        dev->protocol = protocol;
        dev->number = id;
        dev->dma_mask = DMA_24BIT_MASK;
@@ -133,6 +140,7 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
 
        dev_id = pnp_add_id(dev, pnpid);
        if (!dev_id) {
+               kfree(dev->res);
                kfree(dev);
                return NULL;
        }
index 990d8cd6295c122a8af2d6c1f9be4110e37caf54..4407e844b5ea822298d852593362238bee1d9827 100644 (file)
@@ -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 pnp_resource_table *res = dev->res;
        int tmp, ret;
 
        dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
@@ -987,7 +987,7 @@ 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 pnp_resource_table *res = dev->res;
        int tmp;
 
        dev_dbg(&dev->dev, "set resources\n");
index 7c5ebddfc6afa71695a0b71155e219bca6ab0e0c..46a5e0e90d9a69394fb629cbc910c3f802df1cae 100644 (file)
@@ -247,22 +247,22 @@ void pnp_init_resources(struct pnp_dev *dev)
        int idx;
 
        for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
-               res = &dev->res.irq_resource[idx];
+               res = &dev->res->irq_resource[idx];
                res->flags = IORESOURCE_IRQ;
                pnp_init_resource(res);
        }
        for (idx = 0; idx < PNP_MAX_DMA; idx++) {
-               res = &dev->res.dma_resource[idx];
+               res = &dev->res->dma_resource[idx];
                res->flags = IORESOURCE_DMA;
                pnp_init_resource(res);
        }
        for (idx = 0; idx < PNP_MAX_PORT; idx++) {
-               res = &dev->res.port_resource[idx];
+               res = &dev->res->port_resource[idx];
                res->flags = IORESOURCE_IO;
                pnp_init_resource(res);
        }
        for (idx = 0; idx < PNP_MAX_MEM; idx++) {
-               res = &dev->res.mem_resource[idx];
+               res = &dev->res->mem_resource[idx];
                res->flags = IORESOURCE_MEM;
                pnp_init_resource(res);
        }
@@ -278,28 +278,28 @@ static void pnp_clean_resource_table(struct pnp_dev *dev)
        int idx;
 
        for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
-               res = &dev->res.irq_resource[idx];
+               res = &dev->res->irq_resource[idx];
                if (res->flags & IORESOURCE_AUTO) {
                        res->flags = IORESOURCE_IRQ;
                        pnp_init_resource(res);
                }
        }
        for (idx = 0; idx < PNP_MAX_DMA; idx++) {
-               res = &dev->res.dma_resource[idx];
+               res = &dev->res->dma_resource[idx];
                if (res->flags & IORESOURCE_AUTO) {
                        res->flags = IORESOURCE_DMA;
                        pnp_init_resource(res);
                }
        }
        for (idx = 0; idx < PNP_MAX_PORT; idx++) {
-               res = &dev->res.port_resource[idx];
+               res = &dev->res->port_resource[idx];
                if (res->flags & IORESOURCE_AUTO) {
                        res->flags = IORESOURCE_IO;
                        pnp_init_resource(res);
                }
        }
        for (idx = 0; idx < PNP_MAX_MEM; idx++) {
-               res = &dev->res.mem_resource[idx];
+               res = &dev->res->mem_resource[idx];
                if (res->flags & IORESOURCE_AUTO) {
                        res->flags = IORESOURCE_MEM;
                        pnp_init_resource(res);
index 000a1b39f0b6d15da640d8d60708761f870c9e50..2669518b4795a58d94155334c5df20f577e3e7d2 100644 (file)
@@ -21,6 +21,8 @@
 #include <linux/kernel.h>
 #include <linux/acpi.h>
 #include <linux/pci.h>
+#include <linux/pnp.h>
+#include "../base.h"
 #include "pnpacpi.h"
 
 #ifdef CONFIG_IA64
@@ -80,7 +82,7 @@ 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;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
        int irq;
        int p, t;
@@ -176,7 +178,7 @@ 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;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
        static unsigned char warned;
 
@@ -202,7 +204,7 @@ 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;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
        static unsigned char warned;
 
@@ -230,7 +232,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
                                                u64 mem, u64 len,
                                                int write_protect)
 {
-       struct pnp_resource_table *res = &dev->res;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
        static unsigned char warned;
 
index c1f9e162d2c599ff7aff1e57b243f259b7910cbd..9f0538af03213bb70fd35f1906084dccede26f06 100644 (file)
@@ -56,7 +56,7 @@ 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;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
 
        while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
@@ -76,7 +76,7 @@ static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
 
 static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
 {
-       struct pnp_resource_table *res = &dev->res;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
 
        while (i < PNP_MAX_DMA &&
@@ -96,7 +96,7 @@ static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
 static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
                                               int io, int len)
 {
-       struct pnp_resource_table *res = &dev->res;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
 
        while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
@@ -116,7 +116,7 @@ static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
 static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
                                                int mem, int len)
 {
-       struct pnp_resource_table *res = &dev->res;
+       struct pnp_resource_table *res = dev->res;
        int i = 0;
 
        while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
index 84362818fa8b968920aa254b561ea1a2317edbbe..f7adc7eefbf8d169369e41d49972e75799db32bb 100644 (file)
@@ -502,7 +502,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
 struct resource *pnp_get_resource(struct pnp_dev *dev,
                                  unsigned int type, unsigned int num)
 {
-       struct pnp_resource_table *res = &dev->res;
+       struct pnp_resource_table *res = dev->res;
 
        switch (type) {
        case IORESOURCE_IO:
index 1640562f3ebcb7300211ed8e6c944ad7105e267c..a5487b6a4e577e143666f5e0b12fd17e5d0044d9 100644 (file)
 #include <linux/errno.h>
 #include <linux/mod_devicetable.h>
 
-#define PNP_MAX_PORT           40
-#define PNP_MAX_MEM            24
-#define PNP_MAX_IRQ            2
-#define PNP_MAX_DMA            2
 #define PNP_NAME_LEN           50
 
 struct pnp_protocol;
 struct pnp_dev;
+struct pnp_resource_table;
 
 /*
  * Resource Management
@@ -184,13 +181,6 @@ struct pnp_option {
        struct pnp_option *next;        /* used to chain dependent resources */
 };
 
-struct pnp_resource_table {
-       struct resource port_resource[PNP_MAX_PORT];
-       struct resource mem_resource[PNP_MAX_MEM];
-       struct resource dma_resource[PNP_MAX_DMA];
-       struct resource irq_resource[PNP_MAX_IRQ];
-};
-
 /*
  * Device Management
  */
@@ -260,7 +250,7 @@ struct pnp_dev {
        int capabilities;
        struct pnp_option *independent;
        struct pnp_option *dependent;
-       struct pnp_resource_table res;
+       struct pnp_resource_table *res;
 
        char name[PNP_NAME_LEN];        /* contains a human-readable name */
        unsigned short regs;            /* ISAPnP: supported registers */