aboutsummaryrefslogtreecommitdiffstats
path: root/arch/ppc
diff options
context:
space:
mode:
authorBjorn Helgaas <bjorn.helgaas@hp.com>2008-03-04 13:56:57 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-04-21 00:47:05 -0400
commite789920d0497bb3d7eb146382b9ca8137662fabb (patch)
tree560b9021840188ec50363e940ddc9c2a4db50e01 /arch/ppc
parent7cfb5f9aaec6f0fc45ff323841e6d62f67e7ffad (diff)
PCI: ppc: use generic pci_enable_resources()
Use the generic pci_enable_resources() instead of the arch-specific code. Unlike this arch-specific code, the generic version: - checks PCI_NUM_RESOURCES (11), not 6, resources - skips resources that have neither IORESOURCE_IO nor IORESOURCE_MEM set - skips ROM resources unless IORESOURCE_ROM_ENABLE is set - checks for resource collisions with "!r->parent", not IORESOURCE_UNSET Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/ppc')
-rw-r--r--arch/ppc/kernel/pci.c59
1 files changed, 2 insertions, 57 deletions
diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c
index c2ec13bea006..50ce83f20adb 100644
--- a/arch/ppc/kernel/pci.c
+++ b/arch/ppc/kernel/pci.c
@@ -578,39 +578,6 @@ pcibios_assign_resources(void)
578} 578}
579 579
580 580
581int
582pcibios_enable_resources(struct pci_dev *dev, int mask)
583{
584 u16 cmd, old_cmd;
585 int idx;
586 struct resource *r;
587
588 pci_read_config_word(dev, PCI_COMMAND, &cmd);
589 old_cmd = cmd;
590 for (idx=0; idx<6; idx++) {
591 /* Only set up the requested stuff */
592 if (!(mask & (1<<idx)))
593 continue;
594
595 r = &dev->resource[idx];
596 if (r->flags & IORESOURCE_UNSET) {
597 printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
598 return -EINVAL;
599 }
600 if (r->flags & IORESOURCE_IO)
601 cmd |= PCI_COMMAND_IO;
602 if (r->flags & IORESOURCE_MEM)
603 cmd |= PCI_COMMAND_MEMORY;
604 }
605 if (dev->resource[PCI_ROM_RESOURCE].start)
606 cmd |= PCI_COMMAND_MEMORY;
607 if (cmd != old_cmd) {
608 printk("PCI: Enabling device %s (%04x -> %04x)\n", pci_name(dev), old_cmd, cmd);
609 pci_write_config_word(dev, PCI_COMMAND, cmd);
610 }
611 return 0;
612}
613
614static int next_controller_index; 581static int next_controller_index;
615 582
616struct pci_controller * __init 583struct pci_controller * __init
@@ -785,33 +752,11 @@ pcibios_update_irq(struct pci_dev *dev, int irq)
785 752
786int pcibios_enable_device(struct pci_dev *dev, int mask) 753int pcibios_enable_device(struct pci_dev *dev, int mask)
787{ 754{
788 u16 cmd, old_cmd;
789 int idx;
790 struct resource *r;
791
792 if (ppc_md.pcibios_enable_device_hook) 755 if (ppc_md.pcibios_enable_device_hook)
793 if (ppc_md.pcibios_enable_device_hook(dev, 0)) 756 if (ppc_md.pcibios_enable_device_hook(dev, 0))
794 return -EINVAL; 757 return -EINVAL;
795 758
796 pci_read_config_word(dev, PCI_COMMAND, &cmd); 759 return pci_enable_resources(dev, mask);
797 old_cmd = cmd;
798 for (idx=0; idx<6; idx++) {
799 r = &dev->resource[idx];
800 if (r->flags & IORESOURCE_UNSET) {
801 printk(KERN_ERR "PCI: Device %s not available because of resource collisions\n", pci_name(dev));
802 return -EINVAL;
803 }
804 if (r->flags & IORESOURCE_IO)
805 cmd |= PCI_COMMAND_IO;
806 if (r->flags & IORESOURCE_MEM)
807 cmd |= PCI_COMMAND_MEMORY;
808 }
809 if (cmd != old_cmd) {
810 printk("PCI: Enabling device %s (%04x -> %04x)\n",
811 pci_name(dev), old_cmd, cmd);
812 pci_write_config_word(dev, PCI_COMMAND, cmd);
813 }
814 return 0;
815} 760}
816 761
817struct pci_controller* 762struct pci_controller*