Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / sparc / kernel / ioport.c
index 5b4a0e1..f9ff297 100644 (file)
 
 struct resource *_sparc_find_resource(struct resource *r, unsigned long);
 
-static void *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz);
-static void *_sparc_alloc_io(unsigned int busno, unsigned long phys,
+static void __iomem *_sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz);
+static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
     unsigned long size, char *name);
 static void _sparc_free_io(struct resource *res);
 
 /* This points to the next to use virtual memory for DVMA mappings */
 static struct resource _sparc_dvma = {
-       "sparc_dvma", DVMA_VADDR, DVMA_END - 1
+       .name = "sparc_dvma", .start = DVMA_VADDR, .end = DVMA_END - 1
 };
 /* This points to the start of I/O mappings, cluable from outside. */
 /*ext*/ struct resource sparc_iomap = {
-       "sparc_iomap", IOBASE_VADDR, IOBASE_END - 1
+       .name = "sparc_iomap", .start = IOBASE_VADDR, .end = IOBASE_END - 1
 };
 
 /*
@@ -103,7 +103,7 @@ static void xres_free(struct xresource *xrp) {
  *
  * Bus type is always zero on IIep.
  */
-void *ioremap(unsigned long offset, unsigned long size)
+void __iomem *ioremap(unsigned long offset, unsigned long size)
 {
        char name[14];
 
@@ -114,7 +114,7 @@ void *ioremap(unsigned long offset, unsigned long size)
 /*
  * Comlimentary to ioremap().
  */
-void iounmap(void *virtual)
+void iounmap(volatile void __iomem *virtual)
 {
        unsigned long vaddr = (unsigned long) virtual & PAGE_MASK;
        struct resource *res;
@@ -134,24 +134,24 @@ void iounmap(void *virtual)
 
 /*
  */
-unsigned long sbus_ioremap(struct resource *phyres, unsigned long offset,
+void __iomem *sbus_ioremap(struct resource *phyres, unsigned long offset,
     unsigned long size, char *name)
 {
-       return (unsigned long) _sparc_alloc_io(phyres->flags & 0xF,
+       return _sparc_alloc_io(phyres->flags & 0xF,
            phyres->start + offset, size, name);
 }
 
 /*
  */
-void sbus_iounmap(unsigned long addr, unsigned long size)
+void sbus_iounmap(volatile void __iomem *addr, unsigned long size)
 {
-       iounmap((void *)addr);
+       iounmap(addr);
 }
 
 /*
  * Meat of mapping
  */
-static void *_sparc_alloc_io(unsigned int busno, unsigned long phys,
+static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
     unsigned long size, char *name)
 {
        static int printed_full;
@@ -159,7 +159,7 @@ static void *_sparc_alloc_io(unsigned int busno, unsigned long phys,
        struct resource *res;
        char *tack;
        int tlen;
-       void *va;       /* P3 diag */
+       void __iomem *va;       /* P3 diag */
 
        if (name == NULL) name = "???";
 
@@ -189,7 +189,7 @@ static void *_sparc_alloc_io(unsigned int busno, unsigned long phys,
 
 /*
  */
-static void *
+static void __iomem *
 _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz)
 {
        unsigned long offset = ((unsigned long) pa) & (~PAGE_MASK);
@@ -206,7 +206,7 @@ _sparc_ioremap(struct resource *res, u32 bus, u32 pa, int sz)
        pa &= PAGE_MASK;
        sparc_mapiorange(bus, pa, res->start, res->end - res->start + 1);
 
-       return (void *) (res->start + offset);
+       return (void __iomem *) (res->start + offset);
 }
 
 /*
@@ -217,7 +217,7 @@ static void _sparc_free_io(struct resource *res)
        unsigned long plen;
 
        plen = res->end - res->start + 1;
-       if ((plen & (PAGE_SIZE-1)) != 0) BUG();
+       BUG_ON((plen & (PAGE_SIZE-1)) != 0);
        sparc_unmapiorange(res->start, plen);
        release_resource(res);
 }
@@ -252,7 +252,7 @@ void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp)
        }
 
        order = get_order(len_total);
-       if ((va = __get_free_pages(GFP_KERNEL, order)) == 0)
+       if ((va = __get_free_pages(GFP_KERNEL|__GFP_COMP, order)) == 0)
                goto err_nopages;
 
        if ((res = kmalloc(sizeof(struct resource), GFP_KERNEL)) == NULL)
@@ -274,6 +274,11 @@ void *sbus_alloc_consistent(struct sbus_dev *sdev, long len, u32 *dma_addrp)
        if (mmu_map_dma_area(dma_addrp, va, res->start, len_total) != 0)
                goto err_noiommu;
 
+       /* Set the resource name, if known. */
+       if (sdev) {
+               res->name = sdev->prom_name;
+       }
+
        return (void *)res->start;
 
 err_noiommu:
@@ -512,8 +517,7 @@ void pci_free_consistent(struct pci_dev *pdev, size_t n, void *p, dma_addr_t ba)
 dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size,
     int direction)
 {
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        /* IIep is write-through, not flushing. */
        return virt_to_phys(ptr);
 }
@@ -528,8 +532,7 @@ dma_addr_t pci_map_single(struct pci_dev *hwdev, void *ptr, size_t size,
 void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t ba, size_t size,
     int direction)
 {
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                mmu_inval_dma_area((unsigned long)phys_to_virt(ba),
                    (size + PAGE_SIZE-1) & PAGE_MASK);
@@ -542,8 +545,7 @@ void pci_unmap_single(struct pci_dev *hwdev, dma_addr_t ba, size_t size,
 dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
                        unsigned long offset, size_t size, int direction)
 {
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        /* IIep is write-through, not flushing. */
        return page_to_phys(page) + offset;
 }
@@ -551,8 +553,7 @@ dma_addr_t pci_map_page(struct pci_dev *hwdev, struct page *page,
 void pci_unmap_page(struct pci_dev *hwdev,
                        dma_addr_t dma_address, size_t size, int direction)
 {
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        /* mmu_inval_dma_area XXX */
 }
 
@@ -576,11 +577,10 @@ int pci_map_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
 {
        int n;
 
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        /* IIep is write-through, not flushing. */
        for (n = 0; n < nents; n++) {
-               if (page_address(sg->page) == NULL) BUG();
+               BUG_ON(page_address(sg->page) == NULL);
                sg->dvma_address = virt_to_phys(page_address(sg->page));
                sg->dvma_length = sg->length;
                sg++;
@@ -597,11 +597,10 @@ void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
 {
        int n;
 
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                for (n = 0; n < nents; n++) {
-                       if (page_address(sg->page) == NULL) BUG();
+                       BUG_ON(page_address(sg->page) == NULL);
                        mmu_inval_dma_area(
                            (unsigned long) page_address(sg->page),
                            (sg->length + PAGE_SIZE-1) & PAGE_MASK);
@@ -622,8 +621,7 @@ void pci_unmap_sg(struct pci_dev *hwdev, struct scatterlist *sg, int nents,
  */
 void pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t ba, size_t size, int direction)
 {
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                mmu_inval_dma_area((unsigned long)phys_to_virt(ba),
                    (size + PAGE_SIZE-1) & PAGE_MASK);
@@ -632,8 +630,7 @@ void pci_dma_sync_single_for_cpu(struct pci_dev *hwdev, dma_addr_t ba, size_t si
 
 void pci_dma_sync_single_for_device(struct pci_dev *hwdev, dma_addr_t ba, size_t size, int direction)
 {
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                mmu_inval_dma_area((unsigned long)phys_to_virt(ba),
                    (size + PAGE_SIZE-1) & PAGE_MASK);
@@ -650,11 +647,10 @@ void pci_dma_sync_sg_for_cpu(struct pci_dev *hwdev, struct scatterlist *sg, int
 {
        int n;
 
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                for (n = 0; n < nents; n++) {
-                       if (page_address(sg->page) == NULL) BUG();
+                       BUG_ON(page_address(sg->page) == NULL);
                        mmu_inval_dma_area(
                            (unsigned long) page_address(sg->page),
                            (sg->length + PAGE_SIZE-1) & PAGE_MASK);
@@ -667,11 +663,10 @@ void pci_dma_sync_sg_for_device(struct pci_dev *hwdev, struct scatterlist *sg, i
 {
        int n;
 
-       if (direction == PCI_DMA_NONE)
-               BUG();
+       BUG_ON(direction == PCI_DMA_NONE);
        if (direction != PCI_DMA_TODEVICE) {
                for (n = 0; n < nents; n++) {
-                       if (page_address(sg->page) == NULL) BUG();
+                       BUG_ON(page_address(sg->page) == NULL);
                        mmu_inval_dma_area(
                            (unsigned long) page_address(sg->page),
                            (sg->length + PAGE_SIZE-1) & PAGE_MASK);