[POWERPC] 83xx: Update mpc83xx_defconfig
[powerpc.git] / arch / sparc / mm / io-unit.c
index 4ccda77..b86dfce 100644 (file)
@@ -11,8 +11,8 @@
 #include <linux/mm.h>
 #include <linux/highmem.h>     /* pte_offset_map => kmap_atomic */
 #include <linux/bitops.h>
+#include <linux/scatterlist.h>
 
-#include <asm/scatterlist.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <asm/sbus.h>
@@ -66,7 +66,7 @@ iounit_init(int sbi_node, int io_node, struct sbus_bus *sbus)
        }
        if(!xpt) panic("Cannot map External Page Table.");
        
-       sbus->iommu = (struct iommu_struct *)iounit;
+       sbus->ofdev.dev.archdata.iommu = iounit;
        iounit->page_table = xpt;
        spin_lock_init(&iounit->lock);
        
@@ -127,7 +127,7 @@ nexti:      scan = find_next_zero_bit(iounit->bmap, limit, scan);
 static __u32 iounit_get_scsi_one(char *vaddr, unsigned long len, struct sbus_bus *sbus)
 {
        unsigned long ret, flags;
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
        
        spin_lock_irqsave(&iounit->lock, flags);
        ret = iounit_get_area(iounit, (unsigned long)vaddr, len);
@@ -138,14 +138,15 @@ static __u32 iounit_get_scsi_one(char *vaddr, unsigned long len, struct sbus_bus
 static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus)
 {
        unsigned long flags;
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
 
        /* FIXME: Cache some resolved pages - often several sg entries are to the same page */
        spin_lock_irqsave(&iounit->lock, flags);
        while (sz != 0) {
                --sz;
-               sg[sz].dvma_address = iounit_get_area(iounit, (unsigned long)page_address(sg[sz].page) + sg[sz].offset, sg[sz].length);
-               sg[sz].dvma_length = sg[sz].length;
+               sg->dvma_address = iounit_get_area(iounit, (unsigned long) sg_virt(sg), sg->length);
+               sg->dvma_length = sg->length;
+               sg = sg_next(sg);
        }
        spin_unlock_irqrestore(&iounit->lock, flags);
 }
@@ -153,7 +154,7 @@ static void iounit_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus
 static void iounit_release_scsi_one(__u32 vaddr, unsigned long len, struct sbus_bus *sbus)
 {
        unsigned long flags;
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
        
        spin_lock_irqsave(&iounit->lock, flags);
        len = ((vaddr & ~PAGE_MASK) + len + (PAGE_SIZE-1)) >> PAGE_SHIFT;
@@ -168,16 +169,17 @@ static void iounit_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_
 {
        unsigned long flags;
        unsigned long vaddr, len;
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
 
        spin_lock_irqsave(&iounit->lock, flags);
        while (sz != 0) {
                --sz;
-               len = ((sg[sz].dvma_address & ~PAGE_MASK) + sg[sz].length + (PAGE_SIZE-1)) >> PAGE_SHIFT;
-               vaddr = (sg[sz].dvma_address - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
+               len = ((sg->dvma_address & ~PAGE_MASK) + sg->length + (PAGE_SIZE-1)) >> PAGE_SHIFT;
+               vaddr = (sg->dvma_address - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
                IOD(("iounit_release %08lx-%08lx\n", (long)vaddr, (long)len+vaddr));
                for (len += vaddr; vaddr < len; vaddr++)
                        clear_bit(vaddr, iounit->bmap);
+               sg = sg_next(sg);
        }
        spin_unlock_irqrestore(&iounit->lock, flags);
 }
@@ -211,7 +213,7 @@ static int iounit_map_dma_area(dma_addr_t *pba, unsigned long va, __u32 addr, in
                        i = ((addr - IOUNIT_DMA_BASE) >> PAGE_SHIFT);
 
                        for_each_sbus(sbus) {
-                               struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+                               struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
 
                                iopte = (iopte_t *)(iounit->page_table + i);
                                *iopte = MKIOPTE(__pa(page));
@@ -235,7 +237,7 @@ static void iounit_unmap_dma_area(unsigned long addr, int len)
 static struct page *iounit_translate_dvma(unsigned long addr)
 {
        struct sbus_bus *sbus = sbus_root;      /* They are all the same */
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
        int i;
        iopte_t *iopte;
 
@@ -279,7 +281,7 @@ __u32 iounit_map_dma_init(struct sbus_bus *sbus, int size)
        unsigned long rotor, scan, limit;
        unsigned long flags;
        __u32 ret;
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
 
         npages = (size + (PAGE_SIZE-1)) >> PAGE_SHIFT;
        i = 0x0213;
@@ -315,7 +317,7 @@ nexti:      scan = find_next_zero_bit(iounit->bmap, limit, scan);
 __u32 iounit_map_dma_page(__u32 vaddr, void *addr, struct sbus_bus *sbus)
 {
        int scan = (vaddr - IOUNIT_DMA_BASE) >> PAGE_SHIFT;
-       struct iounit_struct *iounit = (struct iounit_struct *)sbus->iommu;
+       struct iounit_struct *iounit = sbus->ofdev.dev.archdata.iommu;
        
        iounit->page_table[scan] = MKIOPTE(__pa(((unsigned long)addr) & PAGE_MASK));
        return vaddr + (((unsigned long)addr) & ~PAGE_MASK);