diff options
author | Sebastian Ott <sebott@linux.vnet.ibm.com> | 2013-08-29 13:34:37 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-08-30 02:57:10 -0400 |
commit | cb8091828757bbc9459ef59248f4a793e681f8cd (patch) | |
tree | 4e2b5d5a87e82f149ed9fb581f478f114c67d243 /arch/s390/pci | |
parent | 67f43f38eeb34da43b624a29d57b703f4c4844b4 (diff) |
s390/pci: use claim_resource
Use pci_claim_resource to find and request bus ressources in
pcibios_add_device. Also move some (de)initialization stuff to
pcibios_enable_device/pcibios_disable_device.
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/pci')
-rw-r--r-- | arch/s390/pci/pci.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 56f8a1c4d9bf..61167b1209a3 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c | |||
@@ -541,8 +541,6 @@ static void zpci_map_resources(struct zpci_dev *zdev) | |||
541 | continue; | 541 | continue; |
542 | pdev->resource[i].start = (resource_size_t) pci_iomap(pdev, i, 0); | 542 | pdev->resource[i].start = (resource_size_t) pci_iomap(pdev, i, 0); |
543 | pdev->resource[i].end = pdev->resource[i].start + len - 1; | 543 | pdev->resource[i].end = pdev->resource[i].start + len - 1; |
544 | pr_debug("BAR%i: -> start: %Lx end: %Lx\n", | ||
545 | i, pdev->resource[i].start, pdev->resource[i].end); | ||
546 | } | 544 | } |
547 | } | 545 | } |
548 | 546 | ||
@@ -574,32 +572,6 @@ void zpci_free_device(struct zpci_dev *zdev) | |||
574 | kfree(zdev); | 572 | kfree(zdev); |
575 | } | 573 | } |
576 | 574 | ||
577 | /* | ||
578 | * Too late for any s390 specific setup, since interrupts must be set up | ||
579 | * already which requires DMA setup too and the pci scan will access the | ||
580 | * config space, which only works if the function handle is enabled. | ||
581 | */ | ||
582 | int pcibios_enable_device(struct pci_dev *pdev, int mask) | ||
583 | { | ||
584 | struct resource *res; | ||
585 | u16 cmd; | ||
586 | int i; | ||
587 | |||
588 | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | ||
589 | |||
590 | for (i = 0; i < PCI_BAR_COUNT; i++) { | ||
591 | res = &pdev->resource[i]; | ||
592 | |||
593 | if (res->flags & IORESOURCE_IO) | ||
594 | return -EINVAL; | ||
595 | |||
596 | if (res->flags & IORESOURCE_MEM) | ||
597 | cmd |= PCI_COMMAND_MEMORY; | ||
598 | } | ||
599 | pci_write_config_word(pdev, PCI_COMMAND, cmd); | ||
600 | return 0; | ||
601 | } | ||
602 | |||
603 | int pcibios_add_platform_entries(struct pci_dev *pdev) | 575 | int pcibios_add_platform_entries(struct pci_dev *pdev) |
604 | { | 576 | { |
605 | return zpci_sysfs_add_device(&pdev->dev); | 577 | return zpci_sysfs_add_device(&pdev->dev); |
@@ -689,16 +661,49 @@ static void zpci_free_iomap(struct zpci_dev *zdev, int entry) | |||
689 | int pcibios_add_device(struct pci_dev *pdev) | 661 | int pcibios_add_device(struct pci_dev *pdev) |
690 | { | 662 | { |
691 | struct zpci_dev *zdev = get_zdev(pdev); | 663 | struct zpci_dev *zdev = get_zdev(pdev); |
664 | struct resource *res; | ||
665 | int i; | ||
666 | |||
667 | zdev->pdev = pdev; | ||
668 | zpci_map_resources(zdev); | ||
669 | |||
670 | for (i = 0; i < PCI_BAR_COUNT; i++) { | ||
671 | res = &pdev->resource[i]; | ||
672 | if (res->parent || !res->flags) | ||
673 | continue; | ||
674 | pci_claim_resource(pdev, i); | ||
675 | } | ||
676 | |||
677 | return 0; | ||
678 | } | ||
679 | |||
680 | int pcibios_enable_device(struct pci_dev *pdev, int mask) | ||
681 | { | ||
682 | struct zpci_dev *zdev = get_zdev(pdev); | ||
683 | struct resource *res; | ||
684 | u16 cmd; | ||
685 | int i; | ||
692 | 686 | ||
693 | zdev->pdev = pdev; | 687 | zdev->pdev = pdev; |
694 | zpci_debug_init_device(zdev); | 688 | zpci_debug_init_device(zdev); |
695 | zpci_fmb_enable_device(zdev); | 689 | zpci_fmb_enable_device(zdev); |
696 | zpci_map_resources(zdev); | 690 | zpci_map_resources(zdev); |
697 | 691 | ||
692 | pci_read_config_word(pdev, PCI_COMMAND, &cmd); | ||
693 | for (i = 0; i < PCI_BAR_COUNT; i++) { | ||
694 | res = &pdev->resource[i]; | ||
695 | |||
696 | if (res->flags & IORESOURCE_IO) | ||
697 | return -EINVAL; | ||
698 | |||
699 | if (res->flags & IORESOURCE_MEM) | ||
700 | cmd |= PCI_COMMAND_MEMORY; | ||
701 | } | ||
702 | pci_write_config_word(pdev, PCI_COMMAND, cmd); | ||
698 | return 0; | 703 | return 0; |
699 | } | 704 | } |
700 | 705 | ||
701 | void pcibios_release_device(struct pci_dev *pdev) | 706 | void pcibios_disable_device(struct pci_dev *pdev) |
702 | { | 707 | { |
703 | struct zpci_dev *zdev = get_zdev(pdev); | 708 | struct zpci_dev *zdev = get_zdev(pdev); |
704 | 709 | ||