aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios/rsparser.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2007-07-26 13:41:21 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-26 14:35:21 -0400
commit07d4e9af109221ab731c5aaf832e89776c64b013 (patch)
tree05d05620af7b1b009f48dbad5f38004b682db271 /drivers/pnp/pnpbios/rsparser.c
parent9dd78466c956ac4b4f38e12032dc4249ccf57ad1 (diff)
PNP: fix up after Lindent
These are manual fixups after running Lindent. No functional change. 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.c99
1 files changed, 46 insertions, 53 deletions
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 54c34d4d4f44..04ecd7b67230 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -1,6 +1,5 @@
1/* 1/*
2 * rsparser.c - parses and encodes pnpbios resource data streams 2 * rsparser.c - parses and encodes pnpbios resource data streams
3 *
4 */ 3 */
5 4
6#include <linux/ctype.h> 5#include <linux/ctype.h>
@@ -15,7 +14,7 @@
15inline void pcibios_penalize_isa_irq(int irq, int active) 14inline void pcibios_penalize_isa_irq(int irq, int active)
16{ 15{
17} 16}
18#endif /* CONFIG_PCI */ 17#endif /* CONFIG_PCI */
19 18
20#include "pnpbios.h" 19#include "pnpbios.h"
21 20
@@ -54,10 +53,11 @@ inline void pcibios_penalize_isa_irq(int irq, int active)
54 * Allocated Resources 53 * Allocated Resources
55 */ 54 */
56 55
57static void 56static void pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res,
58pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq) 57 int irq)
59{ 58{
60 int i = 0; 59 int i = 0;
60
61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET) 61 while (!(res->irq_resource[i].flags & IORESOURCE_UNSET)
62 && i < PNP_MAX_IRQ) 62 && i < PNP_MAX_IRQ)
63 i++; 63 i++;
@@ -73,10 +73,11 @@ pnpbios_parse_allocated_irqresource(struct pnp_resource_table *res, int irq)
73 } 73 }
74} 74}
75 75
76static void 76static void pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res,
77pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma) 77 int dma)
78{ 78{
79 int i = 0; 79 int i = 0;
80
80 while (i < PNP_MAX_DMA && 81 while (i < PNP_MAX_DMA &&
81 !(res->dma_resource[i].flags & IORESOURCE_UNSET)) 82 !(res->dma_resource[i].flags & IORESOURCE_UNSET))
82 i++; 83 i++;
@@ -91,11 +92,11 @@ pnpbios_parse_allocated_dmaresource(struct pnp_resource_table *res, int dma)
91 } 92 }
92} 93}
93 94
94static void 95static void pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res,
95pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io, 96 int io, int len)
96 int len)
97{ 97{
98 int i = 0; 98 int i = 0;
99
99 while (!(res->port_resource[i].flags & IORESOURCE_UNSET) 100 while (!(res->port_resource[i].flags & IORESOURCE_UNSET)
100 && i < PNP_MAX_PORT) 101 && i < PNP_MAX_PORT)
101 i++; 102 i++;
@@ -110,11 +111,11 @@ pnpbios_parse_allocated_ioresource(struct pnp_resource_table *res, int io,
110 } 111 }
111} 112}
112 113
113static void 114static void pnpbios_parse_allocated_memresource(struct pnp_resource_table *res,
114pnpbios_parse_allocated_memresource(struct pnp_resource_table *res, int mem, 115 int mem, int len)
115 int len)
116{ 116{
117 int i = 0; 117 int i = 0;
118
118 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET) 119 while (!(res->mem_resource[i].flags & IORESOURCE_UNSET)
119 && i < PNP_MAX_MEM) 120 && i < PNP_MAX_MEM)
120 i++; 121 i++;
@@ -261,10 +262,11 @@ static unsigned char *pnpbios_parse_allocated_resource_data(unsigned char *p,
261 * Resource Configuration Options 262 * Resource Configuration Options
262 */ 263 */
263 264
264static void 265static void pnpbios_parse_mem_option(unsigned char *p, int size,
265pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option) 266 struct pnp_option *option)
266{ 267{
267 struct pnp_mem *mem; 268 struct pnp_mem *mem;
269
268 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 270 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
269 if (!mem) 271 if (!mem)
270 return; 272 return;
@@ -274,14 +276,13 @@ pnpbios_parse_mem_option(unsigned char *p, int size, struct pnp_option *option)
274 mem->size = ((p[11] << 8) | p[10]) << 8; 276 mem->size = ((p[11] << 8) | p[10]) << 8;
275 mem->flags = p[3]; 277 mem->flags = p[3];
276 pnp_register_mem_resource(option, mem); 278 pnp_register_mem_resource(option, mem);
277 return;
278} 279}
279 280
280static void 281static void pnpbios_parse_mem32_option(unsigned char *p, int size,
281pnpbios_parse_mem32_option(unsigned char *p, int size, 282 struct pnp_option *option)
282 struct pnp_option *option)
283{ 283{
284 struct pnp_mem *mem; 284 struct pnp_mem *mem;
285
285 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 286 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
286 if (!mem) 287 if (!mem)
287 return; 288 return;
@@ -291,12 +292,10 @@ pnpbios_parse_mem32_option(unsigned char *p, int size,
291 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16]; 292 mem->size = (p[19] << 24) | (p[18] << 16) | (p[17] << 8) | p[16];
292 mem->flags = p[3]; 293 mem->flags = p[3];
293 pnp_register_mem_resource(option, mem); 294 pnp_register_mem_resource(option, mem);
294 return;
295} 295}
296 296
297static void 297static void pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
298pnpbios_parse_fixed_mem32_option(unsigned char *p, int size, 298 struct pnp_option *option)
299 struct pnp_option *option)
300{ 299{
301 struct pnp_mem *mem; 300 struct pnp_mem *mem;
302 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL); 301 mem = kzalloc(sizeof(struct pnp_mem), GFP_KERNEL);
@@ -307,11 +306,10 @@ pnpbios_parse_fixed_mem32_option(unsigned char *p, int size,
307 mem->align = 0; 306 mem->align = 0;
308 mem->flags = p[3]; 307 mem->flags = p[3];
309 pnp_register_mem_resource(option, mem); 308 pnp_register_mem_resource(option, mem);
310 return;
311} 309}
312 310
313static void 311static void pnpbios_parse_irq_option(unsigned char *p, int size,
314pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option) 312 struct pnp_option *option)
315{ 313{
316 struct pnp_irq *irq; 314 struct pnp_irq *irq;
317 unsigned long bits; 315 unsigned long bits;
@@ -326,26 +324,26 @@ pnpbios_parse_irq_option(unsigned char *p, int size, struct pnp_option *option)
326 else 324 else
327 irq->flags = IORESOURCE_IRQ_HIGHEDGE; 325 irq->flags = IORESOURCE_IRQ_HIGHEDGE;
328 pnp_register_irq_resource(option, irq); 326 pnp_register_irq_resource(option, irq);
329 return;
330} 327}
331 328
332static void 329static void pnpbios_parse_dma_option(unsigned char *p, int size,
333pnpbios_parse_dma_option(unsigned char *p, int size, struct pnp_option *option) 330 struct pnp_option *option)
334{ 331{
335 struct pnp_dma *dma; 332 struct pnp_dma *dma;
333
336 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL); 334 dma = kzalloc(sizeof(struct pnp_dma), GFP_KERNEL);
337 if (!dma) 335 if (!dma)
338 return; 336 return;
339 dma->map = p[1]; 337 dma->map = p[1];
340 dma->flags = p[2]; 338 dma->flags = p[2];
341 pnp_register_dma_resource(option, dma); 339 pnp_register_dma_resource(option, dma);
342 return;
343} 340}
344 341
345static void 342static void pnpbios_parse_port_option(unsigned char *p, int size,
346pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option) 343 struct pnp_option *option)
347{ 344{
348 struct pnp_port *port; 345 struct pnp_port *port;
346
349 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 347 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
350 if (!port) 348 if (!port)
351 return; 349 return;
@@ -355,14 +353,13 @@ pnpbios_parse_port_option(unsigned char *p, int size, struct pnp_option *option)
355 port->size = p[7]; 353 port->size = p[7];
356 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0; 354 port->flags = p[1] ? PNP_PORT_FLAG_16BITADDR : 0;
357 pnp_register_port_resource(option, port); 355 pnp_register_port_resource(option, port);
358 return;
359} 356}
360 357
361static void 358static void pnpbios_parse_fixed_port_option(unsigned char *p, int size,
362pnpbios_parse_fixed_port_option(unsigned char *p, int size, 359 struct pnp_option *option)
363 struct pnp_option *option)
364{ 360{
365 struct pnp_port *port; 361 struct pnp_port *port;
362
366 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL); 363 port = kzalloc(sizeof(struct pnp_port), GFP_KERNEL);
367 if (!port) 364 if (!port)
368 return; 365 return;
@@ -371,7 +368,6 @@ pnpbios_parse_fixed_port_option(unsigned char *p, int size,
371 port->align = 0; 368 port->align = 0;
372 port->flags = PNP_PORT_FLAG_FIXED; 369 port->flags = PNP_PORT_FLAG_FIXED;
373 pnp_register_port_resource(option, port); 370 pnp_register_port_resource(option, port);
374 return;
375} 371}
376 372
377static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p, 373static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
@@ -498,7 +494,6 @@ static unsigned char *pnpbios_parse_resource_option_data(unsigned char *p,
498 494
499#define HEX(id,a) hex[((id)>>a) & 15] 495#define HEX(id,a) hex[((id)>>a) & 15]
500#define CHAR(id,a) (0x40 + (((id)>>a) & 31)) 496#define CHAR(id,a) (0x40 + (((id)>>a) & 31))
501//
502 497
503void pnpid32_to_pnpid(u32 id, char *str) 498void pnpid32_to_pnpid(u32 id, char *str)
504{ 499{
@@ -513,11 +508,8 @@ void pnpid32_to_pnpid(u32 id, char *str)
513 str[5] = HEX(id, 4); 508 str[5] = HEX(id, 4);
514 str[6] = HEX(id, 0); 509 str[6] = HEX(id, 0);
515 str[7] = '\0'; 510 str[7] = '\0';
516
517 return;
518} 511}
519 512
520//
521#undef CHAR 513#undef CHAR
522#undef HEX 514#undef HEX
523 515
@@ -598,19 +590,20 @@ static void pnpbios_encode_mem(unsigned char *p, struct resource *res)
598{ 590{
599 unsigned long base = res->start; 591 unsigned long base = res->start;
600 unsigned long len = res->end - res->start + 1; 592 unsigned long len = res->end - res->start + 1;
593
601 p[4] = (base >> 8) & 0xff; 594 p[4] = (base >> 8) & 0xff;
602 p[5] = ((base >> 8) >> 8) & 0xff; 595 p[5] = ((base >> 8) >> 8) & 0xff;
603 p[6] = (base >> 8) & 0xff; 596 p[6] = (base >> 8) & 0xff;
604 p[7] = ((base >> 8) >> 8) & 0xff; 597 p[7] = ((base >> 8) >> 8) & 0xff;
605 p[10] = (len >> 8) & 0xff; 598 p[10] = (len >> 8) & 0xff;
606 p[11] = ((len >> 8) >> 8) & 0xff; 599 p[11] = ((len >> 8) >> 8) & 0xff;
607 return;
608} 600}
609 601
610static void pnpbios_encode_mem32(unsigned char *p, struct resource *res) 602static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
611{ 603{
612 unsigned long base = res->start; 604 unsigned long base = res->start;
613 unsigned long len = res->end - res->start + 1; 605 unsigned long len = res->end - res->start + 1;
606
614 p[4] = base & 0xff; 607 p[4] = base & 0xff;
615 p[5] = (base >> 8) & 0xff; 608 p[5] = (base >> 8) & 0xff;
616 p[6] = (base >> 16) & 0xff; 609 p[6] = (base >> 16) & 0xff;
@@ -623,13 +616,13 @@ static void pnpbios_encode_mem32(unsigned char *p, struct resource *res)
623 p[17] = (len >> 8) & 0xff; 616 p[17] = (len >> 8) & 0xff;
624 p[18] = (len >> 16) & 0xff; 617 p[18] = (len >> 16) & 0xff;
625 p[19] = (len >> 24) & 0xff; 618 p[19] = (len >> 24) & 0xff;
626 return;
627} 619}
628 620
629static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res) 621static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
630{ 622{
631 unsigned long base = res->start; 623 unsigned long base = res->start;
632 unsigned long len = res->end - res->start + 1; 624 unsigned long len = res->end - res->start + 1;
625
633 p[4] = base & 0xff; 626 p[4] = base & 0xff;
634 p[5] = (base >> 8) & 0xff; 627 p[5] = (base >> 8) & 0xff;
635 p[6] = (base >> 16) & 0xff; 628 p[6] = (base >> 16) & 0xff;
@@ -638,46 +631,45 @@ static void pnpbios_encode_fixed_mem32(unsigned char *p, struct resource *res)
638 p[9] = (len >> 8) & 0xff; 631 p[9] = (len >> 8) & 0xff;
639 p[10] = (len >> 16) & 0xff; 632 p[10] = (len >> 16) & 0xff;
640 p[11] = (len >> 24) & 0xff; 633 p[11] = (len >> 24) & 0xff;
641 return;
642} 634}
643 635
644static void pnpbios_encode_irq(unsigned char *p, struct resource *res) 636static void pnpbios_encode_irq(unsigned char *p, struct resource *res)
645{ 637{
646 unsigned long map = 0; 638 unsigned long map = 0;
639
647 map = 1 << res->start; 640 map = 1 << res->start;
648 p[1] = map & 0xff; 641 p[1] = map & 0xff;
649 p[2] = (map >> 8) & 0xff; 642 p[2] = (map >> 8) & 0xff;
650 return;
651} 643}
652 644
653static void pnpbios_encode_dma(unsigned char *p, struct resource *res) 645static void pnpbios_encode_dma(unsigned char *p, struct resource *res)
654{ 646{
655 unsigned long map = 0; 647 unsigned long map = 0;
648
656 map = 1 << res->start; 649 map = 1 << res->start;
657 p[1] = map & 0xff; 650 p[1] = map & 0xff;
658 return;
659} 651}
660 652
661static void pnpbios_encode_port(unsigned char *p, struct resource *res) 653static void pnpbios_encode_port(unsigned char *p, struct resource *res)
662{ 654{
663 unsigned long base = res->start; 655 unsigned long base = res->start;
664 unsigned long len = res->end - res->start + 1; 656 unsigned long len = res->end - res->start + 1;
657
665 p[2] = base & 0xff; 658 p[2] = base & 0xff;
666 p[3] = (base >> 8) & 0xff; 659 p[3] = (base >> 8) & 0xff;
667 p[4] = base & 0xff; 660 p[4] = base & 0xff;
668 p[5] = (base >> 8) & 0xff; 661 p[5] = (base >> 8) & 0xff;
669 p[7] = len & 0xff; 662 p[7] = len & 0xff;
670 return;
671} 663}
672 664
673static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res) 665static void pnpbios_encode_fixed_port(unsigned char *p, struct resource *res)
674{ 666{
675 unsigned long base = res->start; 667 unsigned long base = res->start;
676 unsigned long len = res->end - res->start + 1; 668 unsigned long len = res->end - res->start + 1;
669
677 p[1] = base & 0xff; 670 p[1] = base & 0xff;
678 p[2] = (base >> 8) & 0xff; 671 p[2] = (base >> 8) & 0xff;
679 p[3] = len & 0xff; 672 p[3] = len & 0xff;
680 return;
681} 673}
682 674
683static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p, 675static unsigned char *pnpbios_encode_allocated_resource_data(unsigned char *p,
@@ -792,6 +784,7 @@ int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
792{ 784{
793 unsigned char *p = (char *)node->data; 785 unsigned char *p = (char *)node->data;
794 unsigned char *end = (char *)(node->data + node->size); 786 unsigned char *end = (char *)(node->data + node->size);
787
795 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res); 788 p = pnpbios_parse_allocated_resource_data(p, end, &dev->res);
796 if (!p) 789 if (!p)
797 return -EIO; 790 return -EIO;
@@ -804,24 +797,24 @@ int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node *node)
804 return 0; 797 return 0;
805} 798}
806 799
807int 800int pnpbios_read_resources_from_node(struct pnp_resource_table *res,
808pnpbios_read_resources_from_node(struct pnp_resource_table *res, 801 struct pnp_bios_node *node)
809 struct pnp_bios_node *node)
810{ 802{
811 unsigned char *p = (char *)node->data; 803 unsigned char *p = (char *)node->data;
812 unsigned char *end = (char *)(node->data + node->size); 804 unsigned char *end = (char *)(node->data + node->size);
805
813 p = pnpbios_parse_allocated_resource_data(p, end, res); 806 p = pnpbios_parse_allocated_resource_data(p, end, res);
814 if (!p) 807 if (!p)
815 return -EIO; 808 return -EIO;
816 return 0; 809 return 0;
817} 810}
818 811
819int 812int pnpbios_write_resources_to_node(struct pnp_resource_table *res,
820pnpbios_write_resources_to_node(struct pnp_resource_table *res, 813 struct pnp_bios_node *node)
821 struct pnp_bios_node *node)
822{ 814{
823 unsigned char *p = (char *)node->data; 815 unsigned char *p = (char *)node->data;
824 unsigned char *end = (char *)(node->data + node->size); 816 unsigned char *end = (char *)(node->data + node->size);
817
825 p = pnpbios_encode_allocated_resource_data(p, end, res); 818 p = pnpbios_encode_allocated_resource_data(p, end, res);
826 if (!p) 819 if (!p)
827 return -EIO; 820 return -EIO;