aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/pnpbios/rsparser.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/pnpbios/rsparser.c')
-rw-r--r--drivers/pnp/pnpbios/rsparser.c95
1 files changed, 69 insertions, 26 deletions
diff --git a/drivers/pnp/pnpbios/rsparser.c b/drivers/pnp/pnpbios/rsparser.c
index 5ff9a4c0447e..01f0c3dd1b08 100644
--- a/drivers/pnp/pnpbios/rsparser.c
+++ b/drivers/pnp/pnpbios/rsparser.c
@@ -526,8 +526,16 @@ len_err:
526static void pnpbios_encode_mem(struct pnp_dev *dev, unsigned char *p, 526static void pnpbios_encode_mem(struct pnp_dev *dev, unsigned char *p,
527 struct resource *res) 527 struct resource *res)
528{ 528{
529 unsigned long base = res->start; 529 unsigned long base;
530 unsigned long len = res->end - res->start + 1; 530 unsigned long len;
531
532 if (pnp_resource_enabled(res)) {
533 base = res->start;
534 len = res->end - res->start + 1;
535 } else {
536 base = 0;
537 len = 0;
538 }
531 539
532 p[4] = (base >> 8) & 0xff; 540 p[4] = (base >> 8) & 0xff;
533 p[5] = ((base >> 8) >> 8) & 0xff; 541 p[5] = ((base >> 8) >> 8) & 0xff;
@@ -536,15 +544,22 @@ static void pnpbios_encode_mem(struct pnp_dev *dev, unsigned char *p,
536 p[10] = (len >> 8) & 0xff; 544 p[10] = (len >> 8) & 0xff;
537 p[11] = ((len >> 8) >> 8) & 0xff; 545 p[11] = ((len >> 8) >> 8) & 0xff;
538 546
539 dev_dbg(&dev->dev, " encode mem %#llx-%#llx\n", 547 dev_dbg(&dev->dev, " encode mem %#lx-%#lx\n", base, base + len - 1);
540 (unsigned long long) res->start, (unsigned long long) res->end);
541} 548}
542 549
543static void pnpbios_encode_mem32(struct pnp_dev *dev, unsigned char *p, 550static void pnpbios_encode_mem32(struct pnp_dev *dev, unsigned char *p,
544 struct resource *res) 551 struct resource *res)
545{ 552{
546 unsigned long base = res->start; 553 unsigned long base;
547 unsigned long len = res->end - res->start + 1; 554 unsigned long len;
555
556 if (pnp_resource_enabled(res)) {
557 base = res->start;
558 len = res->end - res->start + 1;
559 } else {
560 base = 0;
561 len = 0;
562 }
548 563
549 p[4] = base & 0xff; 564 p[4] = base & 0xff;
550 p[5] = (base >> 8) & 0xff; 565 p[5] = (base >> 8) & 0xff;
@@ -559,15 +574,22 @@ static void pnpbios_encode_mem32(struct pnp_dev *dev, unsigned char *p,
559 p[18] = (len >> 16) & 0xff; 574 p[18] = (len >> 16) & 0xff;
560 p[19] = (len >> 24) & 0xff; 575 p[19] = (len >> 24) & 0xff;
561 576
562 dev_dbg(&dev->dev, " encode mem32 %#llx-%#llx\n", 577 dev_dbg(&dev->dev, " encode mem32 %#lx-%#lx\n", base, base + len - 1);
563 (unsigned long long) res->start, (unsigned long long) res->end);
564} 578}
565 579
566static void pnpbios_encode_fixed_mem32(struct pnp_dev *dev, unsigned char *p, 580static void pnpbios_encode_fixed_mem32(struct pnp_dev *dev, unsigned char *p,
567 struct resource *res) 581 struct resource *res)
568{ 582{
569 unsigned long base = res->start; 583 unsigned long base;
570 unsigned long len = res->end - res->start + 1; 584 unsigned long len;
585
586 if (pnp_resource_enabled(res)) {
587 base = res->start;
588 len = res->end - res->start + 1;
589 } else {
590 base = 0;
591 len = 0;
592 }
571 593
572 p[4] = base & 0xff; 594 p[4] = base & 0xff;
573 p[5] = (base >> 8) & 0xff; 595 p[5] = (base >> 8) & 0xff;
@@ -578,40 +600,54 @@ static void pnpbios_encode_fixed_mem32(struct pnp_dev *dev, unsigned char *p,
578 p[10] = (len >> 16) & 0xff; 600 p[10] = (len >> 16) & 0xff;
579 p[11] = (len >> 24) & 0xff; 601 p[11] = (len >> 24) & 0xff;
580 602
581 dev_dbg(&dev->dev, " encode fixed_mem32 %#llx-%#llx\n", 603 dev_dbg(&dev->dev, " encode fixed_mem32 %#lx-%#lx\n", base,
582 (unsigned long long) res->start, (unsigned long long) res->end); 604 base + len - 1);
583} 605}
584 606
585static void pnpbios_encode_irq(struct pnp_dev *dev, unsigned char *p, 607static void pnpbios_encode_irq(struct pnp_dev *dev, unsigned char *p,
586 struct resource *res) 608 struct resource *res)
587{ 609{
588 unsigned long map = 0; 610 unsigned long map;
611
612 if (pnp_resource_enabled(res))
613 map = 1 << res->start;
614 else
615 map = 0;
589 616
590 map = 1 << res->start;
591 p[1] = map & 0xff; 617 p[1] = map & 0xff;
592 p[2] = (map >> 8) & 0xff; 618 p[2] = (map >> 8) & 0xff;
593 619
594 dev_dbg(&dev->dev, " encode irq %llu\n", 620 dev_dbg(&dev->dev, " encode irq mask %#lx\n", map);
595 (unsigned long long)res->start);
596} 621}
597 622
598static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p, 623static void pnpbios_encode_dma(struct pnp_dev *dev, unsigned char *p,
599 struct resource *res) 624 struct resource *res)
600{ 625{
601 unsigned long map = 0; 626 unsigned long map;
627
628 if (pnp_resource_enabled(res))
629 map = 1 << res->start;
630 else
631 map = 0;
602 632
603 map = 1 << res->start;
604 p[1] = map & 0xff; 633 p[1] = map & 0xff;
605 634
606 dev_dbg(&dev->dev, " encode dma %llu\n", 635 dev_dbg(&dev->dev, " encode dma mask %#lx\n", map);
607 (unsigned long long)res->start);
608} 636}
609 637
610static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p, 638static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p,
611 struct resource *res) 639 struct resource *res)
612{ 640{
613 unsigned long base = res->start; 641 unsigned long base;
614 unsigned long len = res->end - res->start + 1; 642 unsigned long len;
643
644 if (pnp_resource_enabled(res)) {
645 base = res->start;
646 len = res->end - res->start + 1;
647 } else {
648 base = 0;
649 len = 0;
650 }
615 651
616 p[2] = base & 0xff; 652 p[2] = base & 0xff;
617 p[3] = (base >> 8) & 0xff; 653 p[3] = (base >> 8) & 0xff;
@@ -619,8 +655,7 @@ static void pnpbios_encode_port(struct pnp_dev *dev, unsigned char *p,
619 p[5] = (base >> 8) & 0xff; 655 p[5] = (base >> 8) & 0xff;
620 p[7] = len & 0xff; 656 p[7] = len & 0xff;
621 657
622 dev_dbg(&dev->dev, " encode io %#llx-%#llx\n", 658 dev_dbg(&dev->dev, " encode io %#lx-%#lx\n", base, base + len - 1);
623 (unsigned long long) res->start, (unsigned long long) res->end);
624} 659}
625 660
626static void pnpbios_encode_fixed_port(struct pnp_dev *dev, unsigned char *p, 661static void pnpbios_encode_fixed_port(struct pnp_dev *dev, unsigned char *p,
@@ -629,12 +664,20 @@ static void pnpbios_encode_fixed_port(struct pnp_dev *dev, unsigned char *p,
629 unsigned long base = res->start; 664 unsigned long base = res->start;
630 unsigned long len = res->end - res->start + 1; 665 unsigned long len = res->end - res->start + 1;
631 666
667 if (pnp_resource_enabled(res)) {
668 base = res->start;
669 len = res->end - res->start + 1;
670 } else {
671 base = 0;
672 len = 0;
673 }
674
632 p[1] = base & 0xff; 675 p[1] = base & 0xff;
633 p[2] = (base >> 8) & 0xff; 676 p[2] = (base >> 8) & 0xff;
634 p[3] = len & 0xff; 677 p[3] = len & 0xff;
635 678
636 dev_dbg(&dev->dev, " encode fixed_io %#llx-%#llx\n", 679 dev_dbg(&dev->dev, " encode fixed_io %#lx-%#lx\n", base,
637 (unsigned long long) res->start, (unsigned long long) res->end); 680 base + len - 1);
638} 681}
639 682
640static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev 683static unsigned char *pnpbios_encode_allocated_resource_data(struct pnp_dev