sanitize SN2 pci resource setup
PATCH 1/1 sanitize SN2 pci resource setup
A new function, sn_fixup_resource centralizes all handling of pci resource fixups. Code slightly cleaned up.
arch/ia64/sn/io/machvec/pci_bus_cvlink.c +34 -10
@@ -425,6 +425,39 @@ } } + +static void sn_fixup_resource (struct pci_dev *pdev,int idx) +{ +struct resource *resource = &pdev->resource[idx]; +vertex_hdl_t vhdl =PCIDEV_VERTEX (pdev); +pciio_space_t space =PCIIO_SPACE_WIN (idx); +unsigned long size = resource->end - resource->start; +caddr_t res =0 ; +unsigned flags =0 ; + +if (IS_PIC_DEVICE (pdev)) + flags |=PCIIO_BYTE_STREAM ; + +if (!size) +return ; + + res =pcibr_piotrans_addr (vhdl,NULL , space,0 , size, flags); +if (!res) { +struct pcibr_piomap_s *map; + + map =pcibr_piomap_alloc (vhdl,NULL , space,0 , + size, size, flags); +if (map) { + res =pcibr_piomap_addr (map,0 , size); +if (!res)/* XXX: handle error properly */ +pcibr_piomap_free (map); + } + } + + resource->start = (unsigned long )res | __IA64_UNCACHED_OFFSET; + resource->end = resource->start + size; +} +static void __init sn_pci_fixup_one (struct pci_dev *pdev) {struct sn_device_sysdata *device_sysdata;
@@ -461,17 +494,7 @@* Infrastructure .. */ for (idx =0 ; idx <PCI_ROM_RESOURCE ; idx++) { - size = pdev->resource[idx].end - - pdev->resource[idx].start; -if (!size) -continue ; - pdev->resource[idx].start - (unsigned long )pciio_pio_addr (device_vertex,0 , -PCIIO_SPACE_WIN (idx),0 , size,0 , - (IS_PIC_DEVICE (pdev)) ?0 : -PCIIO_BYTE_STREAM ); - pdev->resource[idx].start |= __IA64_UNCACHED_OFFSET; - pdev->resource[idx].end = pdev->resource[idx].start + size; +sn_fixup_resource (pdev, idx);if (pdev->resource[idx].flags &IORESOURCE_IO ) cmd |=PCI_COMMAND_IO ;
arch/ia64/sn/io/sn2/pciio.c +0 -43
49 lines not on this page · raw message