aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios/rsparser.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-07-26 13:41:20 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-26 14:35:20 -0400
commit9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (patch)
tree57ee3822b79049d38c1df952fe77e72a97c718f3 /drivers/pnp/pnpbios/rsparser.c
parent8ec3cf7d29aef773eee5bc6cd9b0fa4d3fb42480 (diff)
PNP: Lindent all source files
Run Lindent on all PNP source files. Produced by: $ quilt new pnp-lindent $ find drivers/pnp -name \*.[ch] | xargs quilt add $ quilt add include/linux/{pnp.h,pnpbios.h} $ scripts/Lindent drivers/pnp/*.c drivers/pnp/*/*.c include/linux/pnp*.h $ quilt refresh --sort Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Len Brown <lenb@kernel.org> Cc: Adam Belay <ambx1@neo.rr.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pnp/pnpbios/rsparser.c')
-rw-r--r--drivers/pnp/pnpbios/rsparser.c278
1 files changed, 157 insertions, 121 deletions
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 3c2ab8394e3f..54c34d4d4f44 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -12,7 +12,9 @@
12#ifdef CONFIG_PCI 12#ifdef CONFIG_PCI
13#include <linux/pci.h> 13#include <linux/pci.h>
14#else 14#else
15inline void pcibios_penalize_isa_irq(int irq, int active) {} 15inline void pcibios_penalize_isa_irq(int irq, int active)
16{
17}
16#endif /* CONFIG_PCI */ 18#endif /* CONFIG_PCI */
17 19
18#include "pnpbios.h" 20#include "pnpbios.h"
@@ -53,74 +55,85 @@ inline void pcibios_penalize_isa_irq(int irq, int active) {}
53 */ 55 */
54 56
55static void 57static void
56pnpbios_parse_allocated_irqresource(struct pnp_resource_table * res, int irq) 58pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq)
57{ 59{
58 int i = 0; 60 int i = 0;
59 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_IRQ) i++; 61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
62 && i < PNP_MAX_IRQ)
63 i++;
60 if (i < PNP_MAX_IRQ) { 64 if (i < PNP_MAX_IRQ) {
61 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag 65 res->irq_resource[i].flags = IORESOURCE_IRQ; // Also clears _UNSET flag
62 if (irq == -1) { 66 if (irq == -1) {
63 res->irq_resource[i].flags |= IORESOURCE_DISABLED; 67 res->irq_resource[i].flags |= IORESOURCE_DISABLED;
64 return; 68 return;
65 } 69 }
66 res->irq_resource[i].start = 70 res->irq_resource[i].start =
67 res->irq_resource[i].end = (unsigned long) irq; 71 res->irq_resource[i].end = (unsigned long)irq;
68 pcibios_penalize_isa_irq(irq, 1); 72 pcibios_penalize_isa_irq(irq, 1);
69 } 73 }
70} 74}
71 75
72static void 76static void
73pnpbios_parse_allocated_dmaresource(struct pnp_resource_table * res, int dma) 77pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma)
74{ 78{
75 int i = 0; 79 int i = 0;
76 while (i < PNP_MAX_DMA && 80 while (i < PNP_MAX_DMA &&
77 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 81 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
78 i++; 82 i++;
79 if (i < PNP_MAX_DMA) { 83 if (i < PNP_MAX_DMA) {
80 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag 84 res->dma_resource[i].flags = IORESOURCE_DMA; // Also clears _UNSET flag
81 if (dma == -1) { 85 if (dma == -1) {
82 res->dma_resource[i].flags |= IORESOURCE_DISABLED; 86 res->dma_resource[i].flags |= IORESOURCE_DISABLED;
83 return; 87 return;
84 } 88 }
85 res->dma_resource[i].start = 89 res->dma_resource[i].start =
86 res->dma_resource[i].end = (unsigned long) dma; 90 res->dma_resource[i].end = (unsigned long)dma;
87 } 91 }
88} 92}
89 93
90static void 94static void
91pnpbios_parse_allocated_ioresource(struct pnp_resource_table * res, int io, int len) 95pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io,
96 int len)
92{ 97{
93 int i = 0; 98 int i = 0;
94 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_PORT) i++; 99 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
100 && i < PNP_MAX_PORT)
101 i++;
95 if (i < PNP_MAX_PORT) { 102 if (i < PNP_MAX_PORT) {
96 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag 103 res->port_resource[i].flags = IORESOURCE_IO; // Also clears _UNSET flag
97 if (len <= 0 || (io + len -1) >= 0x10003) { 104 if (len <= 0 || (io + len - 1) >= 0x10003) {
98 res->port_resource[i].flags |= IORESOURCE_DISABLED; 105 res->port_resource[i].flags |= IORESOURCE_DISABLED;
99 return; 106 return;
100 } 107 }
101 res->port_resource[i].start = (unsigned long) io; 108 res->port_resource[i].start = (unsigned long)io;
102 res->port_resource[i].end = (unsigned long)(io + len - 1); 109 res->port_resource[i].end = (unsigned long)(io + len - 1);
103 } 110 }
104} 111}
105 112
106static void 113static void
107pnpbios_parse_allocated_memresource(struct pnp_resource_table * res, int mem, int len) 114pnpbios_parse_allocated_memresource(struct pnp_resource_table *res, int mem,
115 int len)
108{ 116{
109 int i = 0; 117 int i = 0;
110 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) && i < PNP_MAX_MEM) i++; 118 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
119 && i < PNP_MAX_MEM)
120 i++;
111 if (i < PNP_MAX_MEM) { 121 if (i < PNP_MAX_MEM) {
112 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag 122 res->mem_resource[i].flags = IORESOURCE_MEM; // Also clears _UNSET flag
113 if (len <= 0) { 123 if (len <= 0) {
114 res->mem_resource[i].flags |= IORESOURCE_DISABLED; 124 res->mem_resource[i].flags |= IORESOURCE_DISABLED;
115 return; 125 return;
116 } 126 }
117 res->mem_resource[i].start = (unsigned long) mem; 127 res->mem_resource[i].start = (unsigned long)mem;
118 res->mem_resource[i].end = (unsigned long)(mem + len - 1); 128 res->mem_resource[i].end = (unsigned long)(mem + len - 1);
119 } 129 }
120} 130}
121 131
122static unsigned char * 132static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
123pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) 133 unsigned char *end,
134 struct
135 pnp_resource_table
136 *res)
124{ 137{
125 unsigned int len, tag; 138 unsigned int len, tag;
126 int io, size, mask, i; 139 int io, size, mask, i;
@@ -134,12 +147,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
134 while ((char *)p < (char *)end) { 147 while ((char *)p < (char *)end) {
135 148
136 /* determine the type of tag */ 149 /* determine the type of tag */
137 if (p[0] & LARGE_TAG) { /* large tag */ 150 if (p[0] & LARGE_TAG) { /* large tag */
138 len = (p[2] << 8) | p[1]; 151 len = (p[2] << 8) | p[1];
139 tag = p[0]; 152 tag = p[0];
140 } else { /* small tag */ 153 } else { /* small tag */
141 len = p[0] & 0x07; 154 len = p[0] & 0x07;
142 tag = ((p[0]>>3) & 0x0f); 155 tag = ((p[0] >> 3) & 0x0f);
143 } 156 }
144 157
145 switch (tag) { 158 switch (tag) {
@@ -147,8 +160,8 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
147 case LARGE_TAG_MEM: 160 case LARGE_TAG_MEM:
148 if (len != 9) 161 if (len != 9)
149 goto len_err; 162 goto len_err;
150 io = *(short *) &p[4]; 163 io = *(short *)&p[4];
151 size = *(short *) &p[10]; 164 size = *(short *)&p[10];
152 pnpbios_parse_allocated_memresource(res, io, size); 165 pnpbios_parse_allocated_memresource(res, io, size);
153 break; 166 break;
154 167
@@ -163,16 +176,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
163 case LARGE_TAG_MEM32: 176 case LARGE_TAG_MEM32:
164 if (len != 17) 177 if (len != 17)
165 goto len_err; 178 goto len_err;
166 io = *(int *) &p[4]; 179 io = *(int *)&p[4];
167 size = *(int *) &p[16]; 180 size = *(int *)&p[16];
168 pnpbios_parse_allocated_memresource(res, io, size); 181 pnpbios_parse_allocated_memresource(res, io, size);
169 break; 182 break;
170 183
171 case LARGE_TAG_FIXEDMEM32: 184 case LARGE_TAG_FIXEDMEM32:
172 if (len != 9) 185 if (len != 9)
173 goto len_err; 186 goto len_err;
174 io = *(int *) &p[4]; 187 io = *(int *)&p[4];
175 size = *(int *) &p[8]; 188 size = *(int *)&p[8];
176 pnpbios_parse_allocated_memresource(res, io, size); 189 pnpbios_parse_allocated_memresource(res, io, size);
177 break; 190 break;
178 191
@@ -180,9 +193,10 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
180 if (len < 2 || len > 3) 193 if (len < 2 || len > 3)
181 goto len_err; 194 goto len_err;
182 io = -1; 195 io = -1;
183 mask= p[1] + p[2]*256; 196 mask = p[1] + p[2] * 256;
184 for (i=0;i<16;i++, mask=mask>>1) 197 for (i = 0; i < 16; i++, mask = mask >> 1)
185 if(mask & 0x01) io=i; 198 if (mask & 0x01)
199 io = i;
186 pnpbios_parse_allocated_irqresource(res, io); 200 pnpbios_parse_allocated_irqresource(res, io);
187 break; 201 break;
188 202
@@ -191,15 +205,16 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
191 goto len_err; 205 goto len_err;
192 io = -1; 206 io = -1;
193 mask = p[1]; 207 mask = p[1];
194 for (i=0;i<8;i++, mask = mask>>1) 208 for (i = 0; i < 8; i++, mask = mask >> 1)
195 if(mask & 0x01) io=i; 209 if (mask & 0x01)
210 io = i;
196 pnpbios_parse_allocated_dmaresource(res, io); 211 pnpbios_parse_allocated_dmaresource(res, io);
197 break; 212 break;
198 213
199 case SMALL_TAG_PORT: 214 case SMALL_TAG_PORT:
200 if (len != 7) 215 if (len != 7)
201 goto len_err; 216 goto len_err;
202 io = p[2] + p[3] *256; 217 io = p[2] + p[3] * 256;
203 size = p[7]; 218 size = p[7];
204 pnpbios_parse_allocated_ioresource(res, io, size); 219 pnpbios_parse_allocated_ioresource(res, io, size);
205 break; 220 break;
@@ -218,12 +233,14 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
218 233
219 case SMALL_TAG_END: 234 case SMALL_TAG_END:
220 p = p + 2; 235 p = p + 2;
221 return (unsigned char *)p; 236 return (unsigned char *)p;
222 break; 237 break;
223 238
224 default: /* an unkown tag */ 239 default: /* an unkown tag */
225 len_err: 240 len_err:
226 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 241 printk(KERN_ERR
242 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
243 tag, len);
227 break; 244 break;
228 } 245 }
229 246
@@ -234,12 +251,12 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
234 p += len + 1; 251 p += len + 1;
235 } 252 }
236 253
237 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 254 printk(KERN_ERR
255 "PnPBIOS: Resource structure does not contain an end tag.\n");
238 256
239 return NULL; 257 return NULL;
240} 258}
241 259
242
243/* 260/*
244 * Resource Configuration Options 261 * Resource Configuration Options
245 */ 262 */
@@ -247,7 +264,7 @@ pnpbios_parse_allocated_resource_data(unsigned char * p, unsigned char * end, st
247static void 264static void
248pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) 265pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
249{ 266{
250 struct pnp_mem * mem; 267 struct pnp_mem *mem;
251 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 268 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
252 if (!mem) 269 if (!mem)
253 return; 270 return;
@@ -256,14 +273,15 @@ pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
256 mem->align = (p[9] << 8) | p[8]; 273 mem->align = (p[9] << 8) | p[8];
257 mem->size = ((p[11] << 8) | p[10]) << 8; 274 mem->size = ((p[11] << 8) | p[10]) << 8;
258 mem->flags = p[3]; 275 mem->flags = p[3];
259 pnp_register_mem_resource(option,mem); 276 pnp_register_mem_resource(option, mem);
260 return; 277 return;
261} 278}
262 279
263static void 280static void
264pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option) 281pnpbios_parse_mem32_option(unsigned char *p, int size,
282 struct pnp_option *option)
265{ 283{
266 struct pnp_mem * mem; 284 struct pnp_mem *mem;
267 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 285 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
268 if (!mem) 286 if (!mem)
269 return; 287 return;
@@ -272,14 +290,15 @@ pnpbios_parse_mem32_option(unsigned char *p, int size, struct pnp_option *option
272 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12]; 290 mem->align = (p[15] << 24) | (p[14] << 16) | (p[13] << 8) | p[12];
273 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 291 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
274 mem->flags = p[3]; 292 mem->flags = p[3];
275 pnp_register_mem_resource(option,mem); 293 pnp_register_mem_resource(option, mem);
276 return; 294 return;
277} 295}
278 296
279static void 297static void
280pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *option) 298pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
299 struct pnp_option *option)
281{ 300{
282 struct pnp_mem * mem; 301 struct pnp_mem *mem;
283 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 302 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
284 if (!mem) 303 if (!mem)
285 return; 304 return;
@@ -287,14 +306,14 @@ pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, struct pnp_option *
287 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8]; 306 mem->size = (p[11] << 24) | (p[10] << 16) | (p[9] << 8) | p[8];
288 mem->align = 0; 307 mem->align = 0;
289 mem->flags = p[3]; 308 mem->flags = p[3];
290 pnp_register_mem_resource(option,mem); 309 pnp_register_mem_resource(option, mem);
291 return; 310 return;
292} 311}
293 312
294static void 313static void
295pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) 314pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
296{ 315{
297 struct pnp_irq * irq; 316 struct pnp_irq *irq;
298 unsigned long bits; 317 unsigned long bits;
299 318
300 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL); 319 irq = kzalloc(sizeof(struct pnp_irq), GFP_KERNEL);
@@ -306,27 +325,27 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
306 irq->flags = p[3]; 325 irq->flags = p[3];
307 else 326 else
308 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 327 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
309 pnp_register_irq_resource(option,irq); 328 pnp_register_irq_resource(option, irq);
310 return; 329 return;
311} 330}
312 331
313static void 332static void
314pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) 333pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option)
315{ 334{
316 struct pnp_dma * dma; 335 struct pnp_dma *dma;
317 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); 336 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
318 if (!dma) 337 if (!dma)
319 return; 338 return;
320 dma->map = p[1]; 339 dma->map = p[1];
321 dma->flags = p[2]; 340 dma->flags = p[2];
322 pnp_register_dma_resource(option,dma); 341 pnp_register_dma_resource(option, dma);
323 return; 342 return;
324} 343}
325 344
326static void 345static void
327pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) 346pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
328{ 347{
329 struct pnp_port * port; 348 struct pnp_port *port;
330 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 349 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
331 if (!port) 350 if (!port)
332 return; 351 return;
@@ -335,14 +354,15 @@ pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
335 port->align = p[6]; 354 port->align = p[6];
336 port->size = p[7]; 355 port->size = p[7];
337 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; 356 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0;
338 pnp_register_port_resource(option,port); 357 pnp_register_port_resource(option, port);
339 return; 358 return;
340} 359}
341 360
342static void 361static void
343pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *option) 362pnpbios_parse_fixed_port_option(unsigned char *p, int size,
363 struct pnp_option *option)
344{ 364{
345 struct pnp_port * port; 365 struct pnp_port *port;
346 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 366 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
347 if (!port) 367 if (!port)
348 return; 368 return;
@@ -350,12 +370,13 @@ pnpbios_parse_fixed_port_option(unsigned char *p, int size, struct pnp_option *o
350 port->size = p[3]; 370 port->size = p[3];
351 port->align = 0; 371 port->align = 0;
352 port->flags = PNP_PORT_FLAG_FIXED; 372 port->flags = PNP_PORT_FLAG_FIXED;
353 pnp_register_port_resource(option,port); 373 pnp_register_port_resource(option, port);
354 return; 374 return;
355} 375}
356 376
357static unsigned char * 377static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
358pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struct pnp_dev *dev) 378 unsigned char *end,
379 struct pnp_dev *dev)
359{ 380{
360 unsigned int len, tag; 381 unsigned int len, tag;
361 int priority = 0; 382 int priority = 0;
@@ -371,12 +392,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
371 while ((char *)p < (char *)end) { 392 while ((char *)p < (char *)end) {
372 393
373 /* determine the type of tag */ 394 /* determine the type of tag */
374 if (p[0] & LARGE_TAG) { /* large tag */ 395 if (p[0] & LARGE_TAG) { /* large tag */
375 len = (p[2] << 8) | p[1]; 396 len = (p[2] << 8) | p[1];
376 tag = p[0]; 397 tag = p[0];
377 } else { /* small tag */ 398 } else { /* small tag */
378 len = p[0] & 0x07; 399 len = p[0] & 0x07;
379 tag = ((p[0]>>3) & 0x0f); 400 tag = ((p[0] >> 3) & 0x0f);
380 } 401 }
381 402
382 switch (tag) { 403 switch (tag) {
@@ -442,16 +463,19 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
442 if (len != 0) 463 if (len != 0)
443 goto len_err; 464 goto len_err;
444 if (option_independent == option) 465 if (option_independent == option)
445 printk(KERN_WARNING "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n"); 466 printk(KERN_WARNING
467 "PnPBIOS: Missing SMALL_TAG_STARTDEP tag\n");
446 option = option_independent; 468 option = option_independent;
447 break; 469 break;
448 470
449 case SMALL_TAG_END: 471 case SMALL_TAG_END:
450 return p + 2; 472 return p + 2;
451 473
452 default: /* an unkown tag */ 474 default: /* an unkown tag */
453 len_err: 475 len_err:
454 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 476 printk(KERN_ERR
477 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
478 tag, len);
455 break; 479 break;
456 } 480 }
457 481
@@ -462,12 +486,12 @@ pnpbios_parse_resource_option_data(unsigned char * p, unsigned char * end, struc
462 p += len + 1; 486 p += len + 1;
463 } 487 }
464 488
465 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 489 printk(KERN_ERR
490 "PnPBIOS: Resource structure does not contain an end tag.\n");
466 491
467 return NULL; 492 return NULL;
468} 493}
469 494
470
471/* 495/*
472 * Compatible Device IDs 496 * Compatible Device IDs
473 */ 497 */
@@ -483,7 +507,7 @@ void pnpid32_to_pnpid(u32 id, char *str)
483 id = be32_to_cpu(id); 507 id = be32_to_cpu(id);
484 str[0] = CHAR(id, 26); 508 str[0] = CHAR(id, 26);
485 str[1] = CHAR(id, 21); 509 str[1] = CHAR(id, 21);
486 str[2] = CHAR(id,16); 510 str[2] = CHAR(id, 16);
487 str[3] = HEX(id, 12); 511 str[3] = HEX(id, 12);
488 str[4] = HEX(id, 8); 512 str[4] = HEX(id, 8);
489 str[5] = HEX(id, 4); 513 str[5] = HEX(id, 4);
@@ -492,12 +516,14 @@ void pnpid32_to_pnpid(u32 id, char *str)
492 516
493 return; 517 return;
494} 518}
519
495// 520//
496#undef CHAR 521#undef CHAR
497#undef HEX 522#undef HEX
498 523
499static unsigned char * 524static unsigned char *pnpbios_parse_compatible_ids(unsigned char *p,
500pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_dev *dev) 525 unsigned char *end,
526 struct pnp_dev *dev)
501{ 527{
502 int len, tag; 528 int len, tag;
503 char id[8]; 529 char id[8];
@@ -509,40 +535,45 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
509 while ((char *)p < (char *)end) { 535 while ((char *)p < (char *)end) {
510 536
511 /* determine the type of tag */ 537 /* determine the type of tag */
512 if (p[0] & LARGE_TAG) { /* large tag */ 538 if (p[0] & LARGE_TAG) { /* large tag */
513 len = (p[2] << 8) | p[1]; 539 len = (p[2] << 8) | p[1];
514 tag = p[0]; 540 tag = p[0];
515 } else { /* small tag */ 541 } else { /* small tag */
516 len = p[0] & 0x07; 542 len = p[0] & 0x07;
517 tag = ((p[0]>>3) & 0x0f); 543 tag = ((p[0] >> 3) & 0x0f);
518 } 544 }
519 545
520 switch (tag) { 546 switch (tag) {
521 547
522 case LARGE_TAG_ANSISTR: 548 case LARGE_TAG_ANSISTR:
523 strncpy(dev->name, p + 3, len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len); 549 strncpy(dev->name, p + 3,
524 dev->name[len >= PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0'; 550 len >= PNP_NAME_LEN ? PNP_NAME_LEN - 2 : len);
551 dev->name[len >=
552 PNP_NAME_LEN ? PNP_NAME_LEN - 1 : len] = '\0';
525 break; 553 break;
526 554
527 case SMALL_TAG_COMPATDEVID: /* compatible ID */ 555 case SMALL_TAG_COMPATDEVID: /* compatible ID */
528 if (len != 4) 556 if (len != 4)
529 goto len_err; 557 goto len_err;
530 dev_id = kzalloc(sizeof (struct pnp_id), GFP_KERNEL); 558 dev_id = kzalloc(sizeof(struct pnp_id), GFP_KERNEL);
531 if (!dev_id) 559 if (!dev_id)
532 return NULL; 560 return NULL;
533 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] << 24,id); 561 pnpid32_to_pnpid(p[1] | p[2] << 8 | p[3] << 16 | p[4] <<
562 24, id);
534 memcpy(&dev_id->id, id, 7); 563 memcpy(&dev_id->id, id, 7);
535 pnp_add_id(dev_id, dev); 564 pnp_add_id(dev_id, dev);
536 break; 565 break;
537 566
538 case SMALL_TAG_END: 567 case SMALL_TAG_END:
539 p = p + 2; 568 p = p + 2;
540 return (unsigned char *)p; 569 return (unsigned char *)p;
541 break; 570 break;
542 571
543 default: /* an unkown tag */ 572 default: /* an unkown tag */
544 len_err: 573 len_err:
545 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 574 printk(KERN_ERR
575 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
576 tag, len);
546 break; 577 break;
547 } 578 }
548 579
@@ -553,17 +584,17 @@ pnpbios_parse_compatible_ids(unsigned char *p, unsigned char *end, struct pnp_de
553 p += len + 1; 584 p += len + 1;
554 } 585 }
555 586
556 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 587 printk(KERN_ERR
588 "PnPBIOS: Resource structure does not contain an end tag.\n");
557 589
558 return NULL; 590 return NULL;
559} 591}
560 592
561
562/* 593/*
563 * Allocated Resource Encoding 594 * Allocated Resource Encoding
564 */ 595 */
565 596
566static void pnpbios_encode_mem(unsigned char *p, struct resource * res) 597static void pnpbios_encode_mem(unsigned char *p, struct resource *res)
567{ 598{
568 unsigned long base = res->start; 599 unsigned long base = res->start;
569 unsigned long len = res->end - res->start + 1; 600 unsigned long len = res->end - res->start + 1;
@@ -576,7 +607,7 @@ static void pnpbios_encode_mem(unsigned char *p, struct resource * res)
576 return; 607 return;
577} 608}
578 609
579static void pnpbios_encode_mem32(unsigned char *p, struct resource * res) 610static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
580{ 611{
581 unsigned long base = res->start; 612 unsigned long base = res->start;
582 unsigned long len = res->end - res->start + 1; 613 unsigned long len = res->end - res->start + 1;
@@ -595,8 +626,9 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource * res)
595 return; 626 return;
596} 627}
597 628
598static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res) 629static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
599{ unsigned long base = res->start; 630{
631 unsigned long base = res->start;
600 unsigned long len = res->end - res->start + 1; 632 unsigned long len = res->end - res->start + 1;
601 p[4] = base & 0xff; 633 p[4] = base & 0xff;
602 p[5] = (base >> 8) & 0xff; 634 p[5] = (base >> 8) & 0xff;
@@ -609,7 +641,7 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource * res)
609 return; 641 return;
610} 642}
611 643
612static void pnpbios_encode_irq(unsigned char *p, struct resource * res) 644static void pnpbios_encode_irq(unsigned char *p, struct resource *res)
613{ 645{
614 unsigned long map = 0; 646 unsigned long map = 0;
615 map = 1 << res->start; 647 map = 1 << res->start;
@@ -618,7 +650,7 @@ static void pnpbios_encode_irq(unsigned char *p, struct resource * res)
618 return; 650 return;
619} 651}
620 652
621static void pnpbios_encode_dma(unsigned char *p, struct resource * res) 653static void pnpbios_encode_dma(unsigned char *p, struct resource *res)
622{ 654{
623 unsigned long map = 0; 655 unsigned long map = 0;
624 map = 1 << res->start; 656 map = 1 << res->start;
@@ -626,7 +658,7 @@ static void pnpbios_encode_dma(unsigned char *p, struct resource * res)
626 return; 658 return;
627} 659}
628 660
629static void pnpbios_encode_port(unsigned char *p, struct resource * res) 661static void pnpbios_encode_port(unsigned char *p, struct resource *res)
630{ 662{
631 unsigned long base = res->start; 663 unsigned long base = res->start;
632 unsigned long len = res->end - res->start + 1; 664 unsigned long len = res->end - res->start + 1;
@@ -638,7 +670,7 @@ static void pnpbios_encode_port(unsigned char *p, struct resource * res)
638 return; 670 return;
639} 671}
640 672
641static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res) 673static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res)
642{ 674{
643 unsigned long base = res->start; 675 unsigned long base = res->start;
644 unsigned long len = res->end - res->start + 1; 676 unsigned long len = res->end - res->start + 1;
@@ -648,8 +680,11 @@ static void pnpbios_encode_fixed_port(unsigned char *p, struct resource * res)
648 return; 680 return;
649} 681}
650 682
651static unsigned char * 683static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
652pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, struct pnp_resource_table * res) 684 unsigned char *end,
685 struct
686 pnp_resource_table
687 *res)
653{ 688{
654 unsigned int len, tag; 689 unsigned int len, tag;
655 int port = 0, irq = 0, dma = 0, mem = 0; 690 int port = 0, irq = 0, dma = 0, mem = 0;
@@ -660,12 +695,12 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
660 while ((char *)p < (char *)end) { 695 while ((char *)p < (char *)end) {
661 696
662 /* determine the type of tag */ 697 /* determine the type of tag */
663 if (p[0] & LARGE_TAG) { /* large tag */ 698 if (p[0] & LARGE_TAG) { /* large tag */
664 len = (p[2] << 8) | p[1]; 699 len = (p[2] << 8) | p[1];
665 tag = p[0]; 700 tag = p[0];
666 } else { /* small tag */ 701 } else { /* small tag */
667 len = p[0] & 0x07; 702 len = p[0] & 0x07;
668 tag = ((p[0]>>3) & 0x0f); 703 tag = ((p[0] >> 3) & 0x0f);
669 } 704 }
670 705
671 switch (tag) { 706 switch (tag) {
@@ -725,12 +760,14 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
725 760
726 case SMALL_TAG_END: 761 case SMALL_TAG_END:
727 p = p + 2; 762 p = p + 2;
728 return (unsigned char *)p; 763 return (unsigned char *)p;
729 break; 764 break;
730 765
731 default: /* an unkown tag */ 766 default: /* an unkown tag */
732 len_err: 767 len_err:
733 printk(KERN_ERR "PnPBIOS: Unknown tag '0x%x', length '%d'.\n", tag, len); 768 printk(KERN_ERR
769 "PnPBIOS: Unknown tag '0x%x', length '%d'.\n",
770 tag, len);
734 break; 771 break;
735 } 772 }
736 773
@@ -741,28 +778,27 @@ pnpbios_encode_allocated_resource_data(unsigned char * p, unsigned char * end, s
741 p += len + 1; 778 p += len + 1;
742 } 779 }
743 780
744 printk(KERN_ERR "PnPBIOS: Resource structure does not contain an end tag.\n"); 781 printk(KERN_ERR
782 "PnPBIOS: Resource structure does not contain an end tag.\n");
745 783
746 return NULL; 784 return NULL;
747} 785}
748 786
749
750/* 787/*
751 * Core Parsing Functions 788 * Core Parsing Functions
752 */ 789 */
753 790
754int 791int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
755pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node)
756{ 792{
757 unsigned char * p = (char *)node->data; 793 unsigned char *p = (char *)node->data;
758 unsigned char * end = (char *)(node->data + node->size); 794 unsigned char *end = (char *)(node->data + node->size);
759 p = pnpbios_parse_allocated_resource_data(p,end,&dev->res); 795 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res);
760 if (!p) 796 if (!p)
761 return -EIO; 797 return -EIO;
762 p = pnpbios_parse_resource_option_data(p,end,dev); 798 p = pnpbios_parse_resource_option_data(p, end, dev);
763 if (!p) 799 if (!p)
764 return -EIO; 800 return -EIO;
765 p = pnpbios_parse_compatible_ids(p,end,dev); 801 p = pnpbios_parse_compatible_ids(p, end, dev);
766 if (!p) 802 if (!p)
767 return -EIO; 803 return -EIO;
768 return 0; 804 return 0;
@@ -770,11 +806,11 @@ pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node)
770 806
771int 807int
772pnpbios_read_resources_from_node(struct pnp_resource_table *res, 808pnpbios_read_resources_from_node(struct pnp_resource_table *res,
773 struct pnp_bios_node * node) 809 struct pnp_bios_node *node)
774{ 810{
775 unsigned char * p = (char *)node->data; 811 unsigned char *p = (char *)node->data;
776 unsigned char * end = (char *)(node->data + node->size); 812 unsigned char *end = (char *)(node->data + node->size);
777 p = pnpbios_parse_allocated_resource_data(p,end,res); 813 p = pnpbios_parse_allocated_resource_data(p, end, res);
778 if (!p) 814 if (!p)
779 return -EIO; 815 return -EIO;
780 return 0; 816 return 0;
@@ -782,11 +818,11 @@ pnpbios_read_resources_from_node(struct pnp_resource_table *res,
782 818
783int 819int
784pnpbios_write_resources_to_node(struct pnp_resource_table *res, 820pnpbios_write_resources_to_node(struct pnp_resource_table *res,
785 struct pnp_bios_node * node) 821 struct pnp_bios_node *node)
786{ 822{
787 unsigned char * p = (char *)node->data; 823 unsigned char *p = (char *)node->data;
788 unsigned char * end = (char *)(node->data + node->size); 824 unsigned char *end = (char *)(node->data + node->size);
789 p = pnpbios_encode_allocated_resource_data(p,end,res); 825 p = pnpbios_encode_allocated_resource_data(p, end, res);
790 if (!p) 826 if (!p)
791 return -EIO; 827 return -EIO;
792 return 0; 828 return 0;