aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/pnp/pnpacpi/rsparser.c97
1 files changed, 47 insertions, 50 deletions
diff --git a/drivers/pnp/pnpacpi/rsparser.c b/drivers/pnp/pnpacpi/rsparser.c
index b13f85e0bc34..3a4a644c2686 100644
--- a/drivers/pnp/pnpacpi/rsparser.c
+++ b/drivers/pnp/pnpacpi/rsparser.c
@@ -36,13 +36,13 @@ static int irq_flags(int triggering, int polarity)
36{ 36{
37 int flag; 37 int flag;
38 if (triggering == ACPI_LEVEL_SENSITIVE) { 38 if (triggering == ACPI_LEVEL_SENSITIVE) {
39 if(polarity == ACPI_ACTIVE_LOW) 39 if (polarity == ACPI_ACTIVE_LOW)
40 flag = IORESOURCE_IRQ_LOWLEVEL; 40 flag = IORESOURCE_IRQ_LOWLEVEL;
41 else 41 else
42 flag = IORESOURCE_IRQ_HIGHLEVEL; 42 flag = IORESOURCE_IRQ_HIGHLEVEL;
43 } 43 }
44 else { 44 else {
45 if(polarity == ACPI_ACTIVE_LOW) 45 if (polarity == ACPI_ACTIVE_LOW)
46 flag = IORESOURCE_IRQ_LOWEDGE; 46 flag = IORESOURCE_IRQ_LOWEDGE;
47 else 47 else
48 flag = IORESOURCE_IRQ_HIGHEDGE; 48 flag = IORESOURCE_IRQ_HIGHEDGE;
@@ -57,7 +57,7 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity)
57 *triggering = ACPI_LEVEL_SENSITIVE; 57 *triggering = ACPI_LEVEL_SENSITIVE;
58 *polarity = ACPI_ACTIVE_LOW; 58 *polarity = ACPI_ACTIVE_LOW;
59 break; 59 break;
60 case IORESOURCE_IRQ_HIGHLEVEL: 60 case IORESOURCE_IRQ_HIGHLEVEL:
61 *triggering = ACPI_LEVEL_SENSITIVE; 61 *triggering = ACPI_LEVEL_SENSITIVE;
62 *polarity = ACPI_ACTIVE_HIGH; 62 *polarity = ACPI_ACTIVE_HIGH;
63 break; 63 break;
@@ -73,7 +73,7 @@ static void decode_irq_flags(int flag, int *triggering, int *polarity)
73} 73}
74 74
75static void 75static void
76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi, 76pnpacpi_parse_allocated_irqresource(struct pnp_resource_table *res, u32 gsi,
77 int triggering, int polarity) 77 int triggering, int polarity)
78{ 78{
79 int i = 0; 79 int i = 0;
@@ -101,7 +101,7 @@ pnpacpi_parse_allocated_irqresource(struct pnp_resource_table * res, u32 gsi,
101} 101}
102 102
103static void 103static void
104pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma) 104pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table *res, u32 dma)
105{ 105{
106 int i = 0; 106 int i = 0;
107 while (i < PNP_MAX_DMA && 107 while (i < PNP_MAX_DMA &&
@@ -119,7 +119,7 @@ pnpacpi_parse_allocated_dmaresource(struct pnp_resource_table * res, u32 dma)
119} 119}
120 120
121static void 121static void
122pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res, 122pnpacpi_parse_allocated_ioresource(struct pnp_resource_table *res,
123 u64 io, u64 len) 123 u64 io, u64 len)
124{ 124{
125 int i = 0; 125 int i = 0;
@@ -138,7 +138,7 @@ pnpacpi_parse_allocated_ioresource(struct pnp_resource_table * res,
138} 138}
139 139
140static void 140static void
141pnpacpi_parse_allocated_memresource(struct pnp_resource_table * res, 141pnpacpi_parse_allocated_memresource(struct pnp_resource_table *res,
142 u64 mem, u64 len) 142 u64 mem, u64 len)
143{ 143{
144 int i = 0; 144 int i = 0;
@@ -181,7 +181,7 @@ pnpacpi_parse_allocated_address_space(struct pnp_resource_table *res_table,
181static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res, 181static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
182 void *data) 182 void *data)
183{ 183{
184 struct pnp_resource_table * res_table = (struct pnp_resource_table *)data; 184 struct pnp_resource_table *res_table = (struct pnp_resource_table *)data;
185 int i; 185 int i;
186 186
187 switch (res->type) { 187 switch (res->type) {
@@ -266,11 +266,11 @@ static acpi_status pnpacpi_allocated_resource(struct acpi_resource *res,
266 pnp_warn("PnPACPI: unknown resource type %d", res->type); 266 pnp_warn("PnPACPI: unknown resource type %d", res->type);
267 return AE_ERROR; 267 return AE_ERROR;
268 } 268 }
269 269
270 return AE_OK; 270 return AE_OK;
271} 271}
272 272
273acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table * res) 273acpi_status pnpacpi_parse_allocated_resource(acpi_handle handle, struct pnp_resource_table *res)
274{ 274{
275 /* Blank the resource table values */ 275 /* Blank the resource table values */
276 pnp_init_resource_table(res); 276 pnp_init_resource_table(res);
@@ -328,17 +328,17 @@ static void pnpacpi_parse_dma_option(struct pnp_option *option, struct acpi_reso
328 pnp_err("Invalid DMA transfer type"); 328 pnp_err("Invalid DMA transfer type");
329 } 329 }
330 330
331 pnp_register_dma_resource(option,dma); 331 pnp_register_dma_resource(option, dma);
332 return; 332 return;
333} 333}
334 334
335 335
336static void pnpacpi_parse_irq_option(struct pnp_option *option, 336static void pnpacpi_parse_irq_option(struct pnp_option *option,
337 struct acpi_resource_irq *p) 337 struct acpi_resource_irq *p)
338{ 338{
339 int i; 339 int i;
340 struct pnp_irq * irq; 340 struct pnp_irq *irq;
341 341
342 if (p->interrupt_count == 0) 342 if (p->interrupt_count == 0)
343 return; 343 return;
344 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL); 344 irq = kcalloc(1, sizeof(struct pnp_irq), GFP_KERNEL);
@@ -358,7 +358,7 @@ static void pnpacpi_parse_ext_irq_option(struct pnp_option *option,
358 struct acpi_resource_extended_irq *p) 358 struct acpi_resource_extended_irq *p)
359{ 359{
360 int i; 360 int i;
361 struct pnp_irq * irq; 361 struct pnp_irq *irq;
362 362
363 if (p->interrupt_count == 0) 363 if (p->interrupt_count == 0)
364 return; 364 return;
@@ -379,7 +379,7 @@ static void
379pnpacpi_parse_port_option(struct pnp_option *option, 379pnpacpi_parse_port_option(struct pnp_option *option,
380 struct acpi_resource_io *io) 380 struct acpi_resource_io *io)
381{ 381{
382 struct pnp_port * port; 382 struct pnp_port *port;
383 383
384 if (io->address_length == 0) 384 if (io->address_length == 0)
385 return; 385 return;
@@ -392,7 +392,7 @@ pnpacpi_parse_port_option(struct pnp_option *option,
392 port->size = io->address_length; 392 port->size = io->address_length;
393 port->flags = ACPI_DECODE_16 == io->io_decode ? 393 port->flags = ACPI_DECODE_16 == io->io_decode ?
394 PNP_PORT_FLAG_16BITADDR : 0; 394 PNP_PORT_FLAG_16BITADDR : 0;
395 pnp_register_port_resource(option,port); 395 pnp_register_port_resource(option, port);
396 return; 396 return;
397} 397}
398 398
@@ -400,7 +400,7 @@ static void
400pnpacpi_parse_fixed_port_option(struct pnp_option *option, 400pnpacpi_parse_fixed_port_option(struct pnp_option *option,
401 struct acpi_resource_fixed_io *io) 401 struct acpi_resource_fixed_io *io)
402{ 402{
403 struct pnp_port * port; 403 struct pnp_port *port;
404 404
405 if (io->address_length == 0) 405 if (io->address_length == 0)
406 return; 406 return;
@@ -411,7 +411,7 @@ pnpacpi_parse_fixed_port_option(struct pnp_option *option,
411 port->size = io->address_length; 411 port->size = io->address_length;
412 port->align = 0; 412 port->align = 0;
413 port->flags = PNP_PORT_FLAG_FIXED; 413 port->flags = PNP_PORT_FLAG_FIXED;
414 pnp_register_port_resource(option,port); 414 pnp_register_port_resource(option, port);
415 return; 415 return;
416} 416}
417 417
@@ -419,7 +419,7 @@ static void
419pnpacpi_parse_mem24_option(struct pnp_option *option, 419pnpacpi_parse_mem24_option(struct pnp_option *option,
420 struct acpi_resource_memory24 *p) 420 struct acpi_resource_memory24 *p)
421{ 421{
422 struct pnp_mem * mem; 422 struct pnp_mem *mem;
423 423
424 if (p->address_length == 0) 424 if (p->address_length == 0)
425 return; 425 return;
@@ -434,7 +434,7 @@ pnpacpi_parse_mem24_option(struct pnp_option *option,
434 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 434 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
435 IORESOURCE_MEM_WRITEABLE : 0; 435 IORESOURCE_MEM_WRITEABLE : 0;
436 436
437 pnp_register_mem_resource(option,mem); 437 pnp_register_mem_resource(option, mem);
438 return; 438 return;
439} 439}
440 440
@@ -442,7 +442,7 @@ static void
442pnpacpi_parse_mem32_option(struct pnp_option *option, 442pnpacpi_parse_mem32_option(struct pnp_option *option,
443 struct acpi_resource_memory32 *p) 443 struct acpi_resource_memory32 *p)
444{ 444{
445 struct pnp_mem * mem; 445 struct pnp_mem *mem;
446 446
447 if (p->address_length == 0) 447 if (p->address_length == 0)
448 return; 448 return;
@@ -457,7 +457,7 @@ pnpacpi_parse_mem32_option(struct pnp_option *option,
457 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 457 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
458 IORESOURCE_MEM_WRITEABLE : 0; 458 IORESOURCE_MEM_WRITEABLE : 0;
459 459
460 pnp_register_mem_resource(option,mem); 460 pnp_register_mem_resource(option, mem);
461 return; 461 return;
462} 462}
463 463
@@ -465,7 +465,7 @@ static void
465pnpacpi_parse_fixed_mem32_option(struct pnp_option *option, 465pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
466 struct acpi_resource_fixed_memory32 *p) 466 struct acpi_resource_fixed_memory32 *p)
467{ 467{
468 struct pnp_mem * mem; 468 struct pnp_mem *mem;
469 469
470 if (p->address_length == 0) 470 if (p->address_length == 0)
471 return; 471 return;
@@ -479,7 +479,7 @@ pnpacpi_parse_fixed_mem32_option(struct pnp_option *option,
479 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ? 479 mem->flags = (ACPI_READ_WRITE_MEMORY == p->write_protect) ?
480 IORESOURCE_MEM_WRITEABLE : 0; 480 IORESOURCE_MEM_WRITEABLE : 0;
481 481
482 pnp_register_mem_resource(option,mem); 482 pnp_register_mem_resource(option, mem);
483 return; 483 return;
484} 484}
485 485
@@ -488,8 +488,8 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
488{ 488{
489 struct acpi_resource_address64 addr, *p = &addr; 489 struct acpi_resource_address64 addr, *p = &addr;
490 acpi_status status; 490 acpi_status status;
491 struct pnp_mem * mem; 491 struct pnp_mem *mem;
492 struct pnp_port * port; 492 struct pnp_port *port;
493 493
494 status = acpi_resource_to_address64(r, p); 494 status = acpi_resource_to_address64(r, p);
495 if (!ACPI_SUCCESS(status)) { 495 if (!ACPI_SUCCESS(status)) {
@@ -509,7 +509,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
509 mem->align = 0; 509 mem->align = 0;
510 mem->flags = (p->info.mem.write_protect == 510 mem->flags = (p->info.mem.write_protect ==
511 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0; 511 ACPI_READ_WRITE_MEMORY) ? IORESOURCE_MEM_WRITEABLE : 0;
512 pnp_register_mem_resource(option,mem); 512 pnp_register_mem_resource(option, mem);
513 } else if (p->resource_type == ACPI_IO_RANGE) { 513 } else if (p->resource_type == ACPI_IO_RANGE) {
514 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL); 514 port = kcalloc(1, sizeof(struct pnp_port), GFP_KERNEL);
515 if (!port) 515 if (!port)
@@ -518,7 +518,7 @@ pnpacpi_parse_address_option(struct pnp_option *option, struct acpi_resource *r)
518 port->size = p->address_length; 518 port->size = p->address_length;
519 port->align = 0; 519 port->align = 0;
520 port->flags = PNP_PORT_FLAG_FIXED; 520 port->flags = PNP_PORT_FLAG_FIXED;
521 pnp_register_port_resource(option,port); 521 pnp_register_port_resource(option, port);
522 } 522 }
523} 523}
524 524
@@ -542,7 +542,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
542 break; 542 break;
543 543
544 case ACPI_RESOURCE_TYPE_DMA: 544 case ACPI_RESOURCE_TYPE_DMA:
545 pnpacpi_parse_dma_option(option, &res->data.dma); 545 pnpacpi_parse_dma_option(option, &res->data.dma);
546 break; 546 break;
547 547
548 case ACPI_RESOURCE_TYPE_START_DEPENDENT: 548 case ACPI_RESOURCE_TYPE_START_DEPENDENT:
@@ -550,7 +550,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
550 case ACPI_GOOD_CONFIGURATION: 550 case ACPI_GOOD_CONFIGURATION:
551 priority = PNP_RES_PRIORITY_PREFERRED; 551 priority = PNP_RES_PRIORITY_PREFERRED;
552 break; 552 break;
553 553
554 case ACPI_ACCEPTABLE_CONFIGURATION: 554 case ACPI_ACCEPTABLE_CONFIGURATION:
555 priority = PNP_RES_PRIORITY_ACCEPTABLE; 555 priority = PNP_RES_PRIORITY_ACCEPTABLE;
556 break; 556 break;
@@ -566,7 +566,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
566 option = pnp_register_dependent_option(dev, priority); 566 option = pnp_register_dependent_option(dev, priority);
567 if (!option) 567 if (!option)
568 return AE_ERROR; 568 return AE_ERROR;
569 parse_data->option = option; 569 parse_data->option = option;
570 break; 570 break;
571 571
572 case ACPI_RESOURCE_TYPE_END_DEPENDENT: 572 case ACPI_RESOURCE_TYPE_END_DEPENDENT:
@@ -626,7 +626,7 @@ static acpi_status pnpacpi_option_resource(struct acpi_resource *res,
626 pnp_warn("PnPACPI: unknown resource type %d", res->type); 626 pnp_warn("PnPACPI: unknown resource type %d", res->type);
627 return AE_ERROR; 627 return AE_ERROR;
628 } 628 }
629 629
630 return AE_OK; 630 return AE_OK;
631} 631}
632 632
@@ -679,10 +679,9 @@ static acpi_status pnpacpi_count_resources(struct acpi_resource *res,
679 return AE_OK; 679 return AE_OK;
680} 680}
681 681
682static acpi_status pnpacpi_type_resources(struct acpi_resource *res, 682static acpi_status pnpacpi_type_resources(struct acpi_resource *res, void *data)
683 void *data)
684{ 683{
685 struct acpi_resource **resource = (struct acpi_resource **)data; 684 struct acpi_resource **resource = (struct acpi_resource **)data;
686 685
687 if (pnpacpi_supported_resource(res)) { 686 if (pnpacpi_supported_resource(res)) {
688 (*resource)->type = res->type; 687 (*resource)->type = res->type;
@@ -731,9 +730,8 @@ static void pnpacpi_encode_irq(struct acpi_resource *resource,
731 struct resource *p) 730 struct resource *p)
732{ 731{
733 int triggering, polarity; 732 int triggering, polarity;
734 733
735 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, 734 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
736 &polarity);
737 resource->data.irq.triggering = triggering; 735 resource->data.irq.triggering = triggering;
738 resource->data.irq.polarity = polarity; 736 resource->data.irq.polarity = polarity;
739 if (triggering == ACPI_EDGE_SENSITIVE) 737 if (triggering == ACPI_EDGE_SENSITIVE)
@@ -748,9 +746,8 @@ static void pnpacpi_encode_ext_irq(struct acpi_resource *resource,
748 struct resource *p) 746 struct resource *p)
749{ 747{
750 int triggering, polarity; 748 int triggering, polarity;
751 749
752 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, 750 decode_irq_flags(p->flags & IORESOURCE_BITS, &triggering, &polarity);
753 &polarity);
754 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER; 751 resource->data.extended_irq.producer_consumer = ACPI_CONSUMER;
755 resource->data.extended_irq.triggering = triggering; 752 resource->data.extended_irq.triggering = triggering;
756 resource->data.extended_irq.polarity = polarity; 753 resource->data.extended_irq.polarity = polarity;
@@ -862,37 +859,37 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
862 pnp_dbg("Encode dma"); 859 pnp_dbg("Encode dma");
863 pnpacpi_encode_dma(resource, 860 pnpacpi_encode_dma(resource,
864 &res_table->dma_resource[dma]); 861 &res_table->dma_resource[dma]);
865 dma ++; 862 dma++;
866 break; 863 break;
867 case ACPI_RESOURCE_TYPE_IO: 864 case ACPI_RESOURCE_TYPE_IO:
868 pnp_dbg("Encode io"); 865 pnp_dbg("Encode io");
869 pnpacpi_encode_io(resource, 866 pnpacpi_encode_io(resource,
870 &res_table->port_resource[port]); 867 &res_table->port_resource[port]);
871 port ++; 868 port++;
872 break; 869 break;
873 case ACPI_RESOURCE_TYPE_FIXED_IO: 870 case ACPI_RESOURCE_TYPE_FIXED_IO:
874 pnp_dbg("Encode fixed io"); 871 pnp_dbg("Encode fixed io");
875 pnpacpi_encode_fixed_io(resource, 872 pnpacpi_encode_fixed_io(resource,
876 &res_table->port_resource[port]); 873 &res_table->port_resource[port]);
877 port ++; 874 port++;
878 break; 875 break;
879 case ACPI_RESOURCE_TYPE_MEMORY24: 876 case ACPI_RESOURCE_TYPE_MEMORY24:
880 pnp_dbg("Encode mem24"); 877 pnp_dbg("Encode mem24");
881 pnpacpi_encode_mem24(resource, 878 pnpacpi_encode_mem24(resource,
882 &res_table->mem_resource[mem]); 879 &res_table->mem_resource[mem]);
883 mem ++; 880 mem++;
884 break; 881 break;
885 case ACPI_RESOURCE_TYPE_MEMORY32: 882 case ACPI_RESOURCE_TYPE_MEMORY32:
886 pnp_dbg("Encode mem32"); 883 pnp_dbg("Encode mem32");
887 pnpacpi_encode_mem32(resource, 884 pnpacpi_encode_mem32(resource,
888 &res_table->mem_resource[mem]); 885 &res_table->mem_resource[mem]);
889 mem ++; 886 mem++;
890 break; 887 break;
891 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: 888 case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
892 pnp_dbg("Encode fixed mem32"); 889 pnp_dbg("Encode fixed mem32");
893 pnpacpi_encode_fixed_mem32(resource, 890 pnpacpi_encode_fixed_mem32(resource,
894 &res_table->mem_resource[mem]); 891 &res_table->mem_resource[mem]);
895 mem ++; 892 mem++;
896 break; 893 break;
897 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ: 894 case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
898 pnp_dbg("Encode ext irq"); 895 pnp_dbg("Encode ext irq");
@@ -913,8 +910,8 @@ int pnpacpi_encode_resources(struct pnp_resource_table *res_table,
913 pnp_warn("unknown resource type %d", resource->type); 910 pnp_warn("unknown resource type %d", resource->type);
914 return -EINVAL; 911 return -EINVAL;
915 } 912 }
916 resource ++; 913 resource++;
917 i ++; 914 i++;
918 } 915 }
919 return 0; 916 return 0;
920} 917}