aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp')
-rw-r--r--drivers/pnp/base.h12
-rw-r--r--drivers/pnp/core.c8
-rw-r--r--drivers/pnp/isapnp/core.c4
-rw-r--r--drivers/pnp/manager.c16
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c10
-rw-r--r--drivers/pnp/pnpbios/rsparser.c8
-rw-r--r--drivers/pnp/resource.c2
7 files changed, 41 insertions, 19 deletions
diff --git a/drivers/pnp/base.h b/drivers/pnp/base.h
index e739d4bba423..b888a5fb6b7f 100644
--- a/drivers/pnp/base.h
+++ b/drivers/pnp/base.h
@@ -20,3 +20,15 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res);
20void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc); 20void dbg_pnp_show_resources(struct pnp_dev *dev, char *desc);
21 21
22void pnp_init_resource(struct resource *res); 22void pnp_init_resource(struct resource *res);
23
24#define PNP_MAX_PORT 40
25#define PNP_MAX_MEM 24
26#define PNP_MAX_IRQ 2
27#define PNP_MAX_DMA 2
28
29struct pnp_resource_table {
30 struct resource port_resource[PNP_MAX_PORT];
31 struct resource mem_resource[PNP_MAX_MEM];
32 struct resource dma_resource[PNP_MAX_DMA];
33 struct resource irq_resource[PNP_MAX_IRQ];
34};
diff --git a/drivers/pnp/core.c b/drivers/pnp/core.c
index cf37701a4f9e..20771b7d4482 100644
--- a/drivers/pnp/core.c
+++ b/drivers/pnp/core.c
@@ -106,6 +106,7 @@ static void pnp_release_device(struct device *dmdev)
106 pnp_free_option(dev->independent); 106 pnp_free_option(dev->independent);
107 pnp_free_option(dev->dependent); 107 pnp_free_option(dev->dependent);
108 pnp_free_ids(dev); 108 pnp_free_ids(dev);
109 kfree(dev->res);
109 kfree(dev); 110 kfree(dev);
110} 111}
111 112
@@ -118,6 +119,12 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
118 if (!dev) 119 if (!dev)
119 return NULL; 120 return NULL;
120 121
122 dev->res = kzalloc(sizeof(struct pnp_resource_table), GFP_KERNEL);
123 if (!dev->res) {
124 kfree(dev);
125 return NULL;
126 }
127
121 dev->protocol = protocol; 128 dev->protocol = protocol;
122 dev->number = id; 129 dev->number = id;
123 dev->dma_mask = DMA_24BIT_MASK; 130 dev->dma_mask = DMA_24BIT_MASK;
@@ -133,6 +140,7 @@ struct pnp_dev *pnp_alloc_dev(struct pnp_protocol *protocol, int id, char *pnpid
133 140
134 dev_id = pnp_add_id(dev, pnpid); 141 dev_id = pnp_add_id(dev, pnpid);
135 if (!dev_id) { 142 if (!dev_id) {
143 kfree(dev->res);
136 kfree(dev); 144 kfree(dev);
137 return NULL; 145 return NULL;
138 } 146 }
diff --git a/drivers/pnp/isapnp/core.c b/drivers/pnp/isapnp/core.c
index 990d8cd6295c..4407e844b5ea 100644
--- a/drivers/pnp/isapnp/core.c
+++ b/drivers/pnp/isapnp/core.c
@@ -931,7 +931,7 @@ EXPORT_SYMBOL(isapnp_write_byte);
931 931
932static int isapnp_read_resources(struct pnp_dev *dev) 932static int isapnp_read_resources(struct pnp_dev *dev)
933{ 933{
934 struct pnp_resource_table *res = &dev->res; 934 struct pnp_resource_table *res = dev->res;
935 int tmp, ret; 935 int tmp, ret;
936 936
937 dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE); 937 dev->active = isapnp_read_byte(ISAPNP_CFG_ACTIVATE);
@@ -987,7 +987,7 @@ static int isapnp_get_resources(struct pnp_dev *dev)
987 987
988static int isapnp_set_resources(struct pnp_dev *dev) 988static int isapnp_set_resources(struct pnp_dev *dev)
989{ 989{
990 struct pnp_resource_table *res = &dev->res; 990 struct pnp_resource_table *res = dev->res;
991 int tmp; 991 int tmp;
992 992
993 dev_dbg(&dev->dev, "set resources\n"); 993 dev_dbg(&dev->dev, "set resources\n");
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index 7c5ebddfc6af..46a5e0e90d9a 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -247,22 +247,22 @@ void pnp_init_resources(struct pnp_dev *dev)
247 int idx; 247 int idx;
248 248
249 for (idx = 0; idx < PNP_MAX_IRQ; idx++) { 249 for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
250 res = &dev->res.irq_resource[idx]; 250 res = &dev->res->irq_resource[idx];
251 res->flags = IORESOURCE_IRQ; 251 res->flags = IORESOURCE_IRQ;
252 pnp_init_resource(res); 252 pnp_init_resource(res);
253 } 253 }
254 for (idx = 0; idx < PNP_MAX_DMA; idx++) { 254 for (idx = 0; idx < PNP_MAX_DMA; idx++) {
255 res = &dev->res.dma_resource[idx]; 255 res = &dev->res->dma_resource[idx];
256 res->flags = IORESOURCE_DMA; 256 res->flags = IORESOURCE_DMA;
257 pnp_init_resource(res); 257 pnp_init_resource(res);
258 } 258 }
259 for (idx = 0; idx < PNP_MAX_PORT; idx++) { 259 for (idx = 0; idx < PNP_MAX_PORT; idx++) {
260 res = &dev->res.port_resource[idx]; 260 res = &dev->res->port_resource[idx];
261 res->flags = IORESOURCE_IO; 261 res->flags = IORESOURCE_IO;
262 pnp_init_resource(res); 262 pnp_init_resource(res);
263 } 263 }
264 for (idx = 0; idx < PNP_MAX_MEM; idx++) { 264 for (idx = 0; idx < PNP_MAX_MEM; idx++) {
265 res = &dev->res.mem_resource[idx]; 265 res = &dev->res->mem_resource[idx];
266 res->flags = IORESOURCE_MEM; 266 res->flags = IORESOURCE_MEM;
267 pnp_init_resource(res); 267 pnp_init_resource(res);
268 } 268 }
@@ -278,28 +278,28 @@ static void pnp_clean_resource_table(struct pnp_dev *dev)
278 int idx; 278 int idx;
279 279
280 for (idx = 0; idx < PNP_MAX_IRQ; idx++) { 280 for (idx = 0; idx < PNP_MAX_IRQ; idx++) {
281 res = &dev->res.irq_resource[idx]; 281 res = &dev->res->irq_resource[idx];
282 if (res->flags & IORESOURCE_AUTO) { 282 if (res->flags & IORESOURCE_AUTO) {
283 res->flags = IORESOURCE_IRQ; 283 res->flags = IORESOURCE_IRQ;
284 pnp_init_resource(res); 284 pnp_init_resource(res);
285 } 285 }
286 } 286 }
287 for (idx = 0; idx < PNP_MAX_DMA; idx++) { 287 for (idx = 0; idx < PNP_MAX_DMA; idx++) {
288 res = &dev->res.dma_resource[idx]; 288 res = &dev->res->dma_resource[idx];
289 if (res->flags & IORESOURCE_AUTO) { 289 if (res->flags & IORESOURCE_AUTO) {
290 res->flags = IORESOURCE_DMA; 290 res->flags = IORESOURCE_DMA;
291 pnp_init_resource(res); 291 pnp_init_resource(res);
292 } 292 }
293 } 293 }
294 for (idx = 0; idx < PNP_MAX_PORT; idx++) { 294 for (idx = 0; idx < PNP_MAX_PORT; idx++) {
295 res = &dev->res.port_resource[idx]; 295 res = &dev->res->port_resource[idx];
296 if (res->flags & IORESOURCE_AUTO) { 296 if (res->flags & IORESOURCE_AUTO) {
297 res->flags = IORESOURCE_IO; 297 res->flags = IORESOURCE_IO;
298 pnp_init_resource(res); 298 pnp_init_resource(res);
299 } 299 }
300 } 300 }
301 for (idx = 0; idx < PNP_MAX_MEM; idx++) { 301 for (idx = 0; idx < PNP_MAX_MEM; idx++) {
302 res = &dev->res.mem_resource[idx]; 302 res = &dev->res->mem_resource[idx];
303 if (res->flags & IORESOURCE_AUTO) { 303 if (res->flags & IORESOURCE_AUTO) {
304 res->flags = IORESOURCE_MEM; 304 res->flags = IORESOURCE_MEM;
305 pnp_init_resource(res); 305 pnp_init_resource(res);
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index 000a1b39f0b6..2669518b4795 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -21,6 +21,8 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/acpi.h> 22#include <linux/acpi.h>
23#include <linux/pci.h> 23#include <linux/pci.h>
24#include <linux/pnp.h>
25#include "../base.h"
24#include "pnpacpi.h" 26#include "pnpacpi.h"
25 27
26#ifdef CONFIG_IA64 28#ifdef CONFIG_IA64
@@ -80,7 +82,7 @@ static void pnpacpi_parse_allocated_irqresource(struct pnp_dev *dev,
80 u32 gsi, int triggering, 82 u32 gsi, int triggering,
81 int polarity, int shareable) 83 int polarity, int shareable)
82{ 84{
83 struct pnp_resource_table *res = &dev->res; 85 struct pnp_resource_table *res = dev->res;
84 int i = 0; 86 int i = 0;
85 int irq; 87 int irq;
86 int p, t; 88 int p, t;
@@ -176,7 +178,7 @@ static int dma_flags(int type, int bus_master, int transfer)
176static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev, 178static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
177 u32 dma, int flags) 179 u32 dma, int flags)
178{ 180{
179 struct pnp_resource_table *res = &dev->res; 181 struct pnp_resource_table *res = dev->res;
180 int i = 0; 182 int i = 0;
181 static unsigned char warned; 183 static unsigned char warned;
182 184
@@ -202,7 +204,7 @@ static void pnpacpi_parse_allocated_dmaresource(struct pnp_dev *dev,
202static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev, 204static void pnpacpi_parse_allocated_ioresource(struct pnp_dev *dev,
203 u64 io, u64 len, int io_decode) 205 u64 io, u64 len, int io_decode)
204{ 206{
205 struct pnp_resource_table *res = &dev->res; 207 struct pnp_resource_table *res = dev->res;
206 int i = 0; 208 int i = 0;
207 static unsigned char warned; 209 static unsigned char warned;
208 210
@@ -230,7 +232,7 @@ static void pnpacpi_parse_allocated_memresource(struct pnp_dev *dev,
230 u64 mem, u64 len, 232 u64 mem, u64 len,
231 int write_protect) 233 int write_protect)
232{ 234{
233 struct pnp_resource_table *res = &dev->res; 235 struct pnp_resource_table *res = dev->res;
234 int i = 0; 236 int i = 0;
235 static unsigned char warned; 237 static unsigned char warned;
236 238
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index c1f9e162d2c5..9f0538af0321 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -56,7 +56,7 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
56 56
57static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq) 57static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
58{ 58{
59 struct pnp_resource_table *res = &dev->res; 59 struct pnp_resource_table *res = dev->res;
60 int i = 0; 60 int i = 0;
61 61
62 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) 62 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
@@ -76,7 +76,7 @@ static void pnpbios_parse_allocated_irqresource(struct pnp_dev *dev, int irq)
76 76
77static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma) 77static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
78{ 78{
79 struct pnp_resource_table *res = &dev->res; 79 struct pnp_resource_table *res = dev->res;
80 int i = 0; 80 int i = 0;
81 81
82 while (i < PNP_MAX_DMA && 82 while (i < PNP_MAX_DMA &&
@@ -96,7 +96,7 @@ static void pnpbios_parse_allocated_dmaresource(struct pnp_dev *dev, int dma)
96static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev, 96static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
97 int io, int len) 97 int io, int len)
98{ 98{
99 struct pnp_resource_table *res = &dev->res; 99 struct pnp_resource_table *res = dev->res;
100 int i = 0; 100 int i = 0;
101 101
102 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) 102 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
@@ -116,7 +116,7 @@ static void pnpbios_parse_allocated_ioresource(struct pnp_dev *dev,
116static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev, 116static void pnpbios_parse_allocated_memresource(struct pnp_dev *dev,
117 int mem, int len) 117 int mem, int len)
118{ 118{
119 struct pnp_resource_table *res = &dev->res; 119 struct pnp_resource_table *res = dev->res;
120 int i = 0; 120 int i = 0;
121 121
122 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) 122 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
index 84362818fa8b..f7adc7eefbf8 100644
--- a/drivers/pnp/resource.c
+++ b/drivers/pnp/resource.c
@@ -502,7 +502,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
502struct resource *pnp_get_resource(struct pnp_dev *dev, 502struct resource *pnp_get_resource(struct pnp_dev *dev,
503 unsigned int type, unsigned int num) 503 unsigned int type, unsigned int num)
504{ 504{
505 struct pnp_resource_table *res = &dev->res; 505 struct pnp_resource_table *res = dev->res;
506 506
507 switch (type) { 507 switch (type) {
508 case IORESOURCE_IO: 508 case IORESOURCE_IO: