Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sameo/mfd-2.6
[safe/jmp/linux-2.6] / drivers / parisc / ccio-dma.c
index f46e843..0f0e0b9 100644 (file)
@@ -31,8 +31,8 @@
 **        the coherency design originally worked out. Only PCX-W does.
 */
 
-#include <linux/config.h>
 #include <linux/types.h>
+#include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/mm.h>
 #include <linux/spinlock.h>
 #include <linux/string.h>
 #include <linux/pci.h>
 #include <linux/reboot.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
+#include <linux/scatterlist.h>
+#include <linux/iommu-helper.h>
 
 #include <asm/byteorder.h>
 #include <asm/cache.h>         /* for L1_CACHE_BYTES */
 #undef DEBUG_CCIO_RUN_SG
 
 #ifdef CONFIG_PROC_FS
-/*
- * CCIO_SEARCH_TIME can help measure how fast the bitmap search is.
- * impacts performance though - ditch it if you don't use it.
- */
-#define CCIO_SEARCH_TIME
-#undef CCIO_MAP_STATS
-#else
-#undef CCIO_SEARCH_TIME
-#undef CCIO_MAP_STATS
+/* depends on proc fs support. But costs CPU performance. */
+#undef CCIO_COLLECT_STATS
 #endif
 
 #include <linux/proc_fs.h>
@@ -235,12 +232,10 @@ struct ioc {
        u32 res_size;                   /* size of resource map in bytes */
        spinlock_t res_lock;
 
-#ifdef CCIO_SEARCH_TIME
+#ifdef CCIO_COLLECT_STATS
 #define CCIO_SEARCH_SAMPLE 0x100
        unsigned long avg_search[CCIO_SEARCH_SAMPLE];
        unsigned long avg_idx;            /* current index into avg_search */
-#endif
-#ifdef CCIO_MAP_STATS
        unsigned long used_pages;
        unsigned long msingle_calls;
        unsigned long msingle_pages;
@@ -291,7 +286,6 @@ static int ioc_count;
 #define PDIR_INDEX(iovp)    ((iovp)>>IOVP_SHIFT)
 #define MKIOVP(pdir_idx)    ((long)(pdir_idx) << IOVP_SHIFT)
 #define MKIOVA(iovp,offset) (dma_addr_t)((long)iovp | (long)offset)
-#define ROUNDUP(x,y) ((x + ((y)-1)) & ~((y)-1))
 
 /*
 ** Don't worry about the 150% average search length on a miss.
@@ -300,13 +294,17 @@ static int ioc_count;
 */
 #define CCIO_SEARCH_LOOP(ioc, res_idx, mask, size)  \
        for(; res_ptr < res_end; ++res_ptr) { \
-               if(0 == (*res_ptr & mask)) { \
-                       *res_ptr |= mask; \
-                       res_idx = (unsigned int)((unsigned long)res_ptr - (unsigned long)ioc->res_map); \
-                       ioc->res_hint = res_idx + (size >> 3); \
-                       goto resource_found; \
-               } \
-       }
+               int ret;\
+               unsigned int idx;\
+               idx = (unsigned int)((unsigned long)res_ptr - (unsigned long)ioc->res_map); \
+               ret = iommu_is_span_boundary(idx << 3, pages_needed, 0, boundary_size);\
+               if ((0 == (*res_ptr & mask)) && !ret) { \
+                       *res_ptr |= mask; \
+                       res_idx = idx;\
+                       ioc->res_hint = res_idx + (size >> 3); \
+                       goto resource_found; \
+               } \
+       }
 
 #define CCIO_FIND_FREE_MAPPING(ioa, res_idx, mask, size) \
        u##size *res_ptr = (u##size *)&((ioc)->res_map[ioa->res_hint & ~((size >> 3) - 1)]); \
@@ -339,11 +337,12 @@ static int ioc_count;
  * of available pages for the requested size.
  */
 static int
-ccio_alloc_range(struct ioc *ioc, size_t size)
+ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
 {
        unsigned int pages_needed = size >> IOVP_SHIFT;
        unsigned int res_idx;
-#ifdef CCIO_SEARCH_TIME
+       unsigned long boundary_size;
+#ifdef CCIO_COLLECT_STATS
        unsigned long cr_start = mfctl(16);
 #endif
        
@@ -351,17 +350,20 @@ ccio_alloc_range(struct ioc *ioc, size_t size)
        BUG_ON((pages_needed * IOVP_SIZE) > DMA_CHUNK_SIZE);
      
        DBG_RES("%s() size: %d pages_needed %d\n", 
-               __FUNCTION__, size, pages_needed);
+               __func__, size, pages_needed);
 
        /*
        ** "seek and ye shall find"...praying never hurts either...
        ** ggg sacrifices another 710 to the computer gods.
        */
 
+       boundary_size = ALIGN((unsigned long long)dma_get_seg_boundary(dev) + 1,
+                             1ULL << IOVP_SHIFT) >> IOVP_SHIFT;
+
        if (pages_needed <= 8) {
                /*
                 * LAN traffic will not thrash the TLB IFF the same NIC
-                * uses 8 adjacent pages to map seperate payload data.
+                * uses 8 adjacent pages to map separate payload data.
                 * ie the same byte in the resource bit map.
                 */
 #if 0
@@ -384,18 +386,18 @@ ccio_alloc_range(struct ioc *ioc, size_t size)
 #endif
        } else {
                panic("%s: %s() Too many pages to map. pages_needed: %u\n",
-                      __FILE__,  __FUNCTION__, pages_needed);
+                      __FILE__,  __func__, pages_needed);
        }
 
        panic("%s: %s() I/O MMU is out of mapping resources.\n", __FILE__,
-             __FUNCTION__);
+             __func__);
        
 resource_found:
        
        DBG_RES("%s() res_idx %d res_hint: %d\n",
-               __FUNCTION__, res_idx, ioc->res_hint);
+               __func__, res_idx, ioc->res_hint);
 
-#ifdef CCIO_SEARCH_TIME
+#ifdef CCIO_COLLECT_STATS
        {
                unsigned long cr_end = mfctl(16);
                unsigned long tmp = cr_end - cr_start;
@@ -404,8 +406,6 @@ resource_found:
        }
        ioc->avg_search[ioc->avg_idx++] = cr_start;
        ioc->avg_idx &= CCIO_SEARCH_SAMPLE - 1;
-#endif
-#ifdef CCIO_MAP_STATS
        ioc->used_pages += pages_needed;
 #endif
        /* 
@@ -439,9 +439,9 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
        BUG_ON(pages_mapped > BITS_PER_LONG);
 
        DBG_RES("%s():  res_idx: %d pages_mapped %d\n", 
-               __FUNCTION__, res_idx, pages_mapped);
+               __func__, res_idx, pages_mapped);
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
        ioc->used_pages -= pages_mapped;
 #endif
 
@@ -451,10 +451,10 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
                unsigned long mask = ~(~0UL >> pages_mapped);
                CCIO_FREE_MAPPINGS(ioc, res_idx, mask, 8);
 #else
-               CCIO_FREE_MAPPINGS(ioc, res_idx, 0xff, 8);
+               CCIO_FREE_MAPPINGS(ioc, res_idx, 0xffUL, 8);
 #endif
        } else if(pages_mapped <= 16) {
-               CCIO_FREE_MAPPINGS(ioc, res_idx, 0xffff, 16);
+               CCIO_FREE_MAPPINGS(ioc, res_idx, 0xffffUL, 16);
        } else if(pages_mapped <= 32) {
                CCIO_FREE_MAPPINGS(ioc, res_idx, ~(unsigned int)0, 32);
 #ifdef __LP64__
@@ -463,7 +463,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
 #endif
        } else {
                panic("%s:%s() Too many pages to unmap.\n", __FILE__,
-                     __FUNCTION__);
+                     __func__);
        }
 }
 
@@ -485,7 +485,7 @@ typedef unsigned long space_t;
 **   This bit tells U2 to do R/M/W for partial cachelines. "Streaming"
 **   data can avoid this if the mapping covers full cache lines.
 ** o STOP_MOST is needed for atomicity across cachelines.
-**   Apperently only "some EISA devices" need this.
+**   Apparently only "some EISA devices" need this.
 **   Using CONFIG_ISA is hack. Only the IOA with EISA under it needs
 **   to use this hint iff the EISA devices needs this feature.
 **   According to the U2 ERS, STOP_MOST enabled pages hurt performance.
@@ -553,7 +553,7 @@ static u32 hint_lookup[] = {
  * (Load Coherence Index) instruction.  The 8 bits used for the virtual
  * index are bits 12:19 of the value returned by LCI.
  */ 
-void CCIO_INLINE
+static void CCIO_INLINE
 ccio_io_pdir_entry(u64 *pdir_ptr, space_t sid, unsigned long vba,
                   unsigned long hints)
 {
@@ -667,7 +667,7 @@ ccio_mark_invalid(struct ioc *ioc, dma_addr_t iova, size_t byte_cnt)
        size_t saved_byte_cnt;
 
        /* round up to nearest page size */
-       saved_byte_cnt = byte_cnt = ROUNDUP(byte_cnt, IOVP_SIZE);
+       saved_byte_cnt = byte_cnt = ALIGN(byte_cnt, IOVP_SIZE);
 
        while(byte_cnt > 0) {
                /* invalidate one page at a time */
@@ -750,21 +750,21 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
        offset = ((unsigned long) addr) & ~IOVP_MASK;
 
        /* round up to nearest IOVP_SIZE */
-       size = ROUNDUP(size + offset, IOVP_SIZE);
+       size = ALIGN(size + offset, IOVP_SIZE);
        spin_lock_irqsave(&ioc->res_lock, flags);
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
        ioc->msingle_calls++;
        ioc->msingle_pages += size >> IOVP_SHIFT;
 #endif
 
-       idx = ccio_alloc_range(ioc, size);
+       idx = ccio_alloc_range(ioc, dev, size);
        iovp = (dma_addr_t)MKIOVP(idx);
 
        pdir_start = &(ioc->pdir_base[idx]);
 
        DBG_RUN("%s() 0x%p -> 0x%lx size: %0x%x\n",
-               __FUNCTION__, addr, (long)iovp | offset, size);
+               __func__, addr, (long)iovp | offset, size);
 
        /* If not cacheline aligned, force SAFE_DMA on the whole mess */
        if((size % L1_CACHE_BYTES) || ((unsigned long)addr % L1_CACHE_BYTES))
@@ -809,15 +809,15 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
        ioc = GET_IOC(dev);
 
        DBG_RUN("%s() iovp 0x%lx/%x\n",
-               __FUNCTION__, (long)iova, size);
+               __func__, (long)iova, size);
 
        iova ^= offset;        /* clear offset bits */
        size += offset;
-       size = ROUNDUP(size, IOVP_SIZE);
+       size = ALIGN(size, IOVP_SIZE);
 
        spin_lock_irqsave(&ioc->res_lock, flags);
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
        ioc->usingle_calls++;
        ioc->usingle_pages += size >> IOVP_SHIFT;
 #endif
@@ -883,7 +883,7 @@ ccio_free_consistent(struct device *dev, size_t size, void *cpu_addr,
 */
 #define PIDE_FLAG 0x80000000UL
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
 #define IOMMU_MAP_STATS
 #endif
 #include "iommu-helpers.h"
@@ -911,7 +911,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
        BUG_ON(!dev);
        ioc = GET_IOC(dev);
        
-       DBG_RUN_SG("%s() START %d entries\n", __FUNCTION__, nents);
+       DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
 
        /* Fast path single entry scatterlists. */
        if (nents == 1) {
@@ -927,7 +927,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
        
        spin_lock_irqsave(&ioc->res_lock, flags);
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
        ioc->msg_calls++;
 #endif
 
@@ -939,7 +939,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
        ** w/o this association, we wouldn't have coherent DMA!
        ** Access to the virtual address is what forces a two pass algorithm.
        */
-       coalesced = iommu_coalesce_chunks(ioc, sglist, nents, ccio_alloc_range);
+       coalesced = iommu_coalesce_chunks(ioc, dev, sglist, nents, ccio_alloc_range);
 
        /*
        ** Program the I/O Pdir
@@ -955,7 +955,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
 
        BUG_ON(coalesced != filled);
 
-       DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, filled);
+       DBG_RUN_SG("%s() DONE %d mappings\n", __func__, filled);
 
        for (i = 0; i < filled; i++)
                current_len += sg_dma_len(sglist + i);
@@ -984,15 +984,15 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
        ioc = GET_IOC(dev);
 
        DBG_RUN_SG("%s() START %d entries,  %08lx,%x\n",
-               __FUNCTION__, nents, sg_virt_addr(sglist), sglist->length);
+               __func__, nents, sg_virt_addr(sglist), sglist->length);
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
        ioc->usg_calls++;
 #endif
 
        while(sg_dma_len(sglist) && nents--) {
 
-#ifdef CCIO_MAP_STATS
+#ifdef CCIO_COLLECT_STATS
                ioc->usg_pages += sg_dma_len(sglist) >> PAGE_SHIFT;
 #endif
                ccio_unmap_single(dev, sg_dma_address(sglist),
@@ -1000,7 +1000,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
                ++sglist;
        }
 
-       DBG_RUN_SG("%s() DONE (nents %d)\n", __FUNCTION__, nents);
+       DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
 }
 
 static struct hppa_dma_ops ccio_ops = {
@@ -1019,63 +1019,36 @@ static struct hppa_dma_ops ccio_ops = {
 };
 
 #ifdef CONFIG_PROC_FS
-static int proc_append(char *src, int len, char **dst, off_t *offset, int *max)
+static int ccio_proc_info(struct seq_file *m, void *p)
 {
-       if (len < *offset) {
-               *offset -= len;
-               return 0;
-       }
-       if (*offset > 0) {
-               src += *offset;
-               len -= *offset;
-               *offset = 0;
-       }
-       if (len > *max) {
-               len = *max;
-       }
-       memcpy(*dst, src, len);
-       *dst += len;
-       *max -= len;
-       return (*max == 0);
-}
-
-static int ccio_proc_info(char *buf, char **start, off_t offset, int count,
-                         int *eof, void *data)
-{
-       int max = count;
-       char tmp[80]; /* width of an ANSI-standard terminal */
+       int len = 0;
        struct ioc *ioc = ioc_list;
 
        while (ioc != NULL) {
                unsigned int total_pages = ioc->res_size << 3;
+#ifdef CCIO_COLLECT_STATS
                unsigned long avg = 0, min, max;
-               int j, len;
+               int j;
+#endif
 
-               len = sprintf(tmp, "%s\n", ioc->name);
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
+               len += seq_printf(m, "%s\n", ioc->name);
                
-               len = sprintf(tmp, "Cujo 2.0 bug    : %s\n",
-                             (ioc->cujo20_bug ? "yes" : "no"));
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
+               len += seq_printf(m, "Cujo 2.0 bug    : %s\n",
+                                 (ioc->cujo20_bug ? "yes" : "no"));
                
-               len = sprintf(tmp, "IO PDIR size    : %d bytes (%d entries)\n",
-                             total_pages * 8, total_pages);
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
-#ifdef CCIO_MAP_STATS
-               len = sprintf(tmp, "IO PDIR entries : %ld free  %ld used (%d%%)\n",
-                             total_pages - ioc->used_pages, ioc->used_pages,
-                             (int)(ioc->used_pages * 100 / total_pages));
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
+               len += seq_printf(m, "IO PDIR size    : %d bytes (%d entries)\n",
+                              total_pages * 8, total_pages);
+
+#ifdef CCIO_COLLECT_STATS
+               len += seq_printf(m, "IO PDIR entries : %ld free  %ld used (%d%%)\n",
+                                 total_pages - ioc->used_pages, ioc->used_pages,
+                                 (int)(ioc->used_pages * 100 / total_pages));
 #endif
-               len = sprintf(tmp, "Resource bitmap : %d bytes (%d pages)\n", 
-                       ioc->res_size, total_pages);
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
-#ifdef CCIO_SEARCH_TIME
+
+               len += seq_printf(m, "Resource bitmap : %d bytes (%d pages)\n", 
+                                 ioc->res_size, total_pages);
+
+#ifdef CCIO_COLLECT_STATS
                min = max = ioc->avg_search[0];
                for(j = 0; j < CCIO_SEARCH_SAMPLE; ++j) {
                        avg += ioc->avg_search[j];
@@ -1085,71 +1058,83 @@ static int ccio_proc_info(char *buf, char **start, off_t offset, int count,
                                min = ioc->avg_search[j];
                }
                avg /= CCIO_SEARCH_SAMPLE;
-               len = sprintf(tmp, "  Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n",
-                             min, avg, max);
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
-#endif
-#ifdef CCIO_MAP_STATS
-               len = sprintf(tmp, "pci_map_single(): %8ld calls  %8ld pages (avg %d/1000)\n",
-                             ioc->msingle_calls, ioc->msingle_pages,
-                             (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls));
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
-               
+               len += seq_printf(m, "  Bitmap search : %ld/%ld/%ld (min/avg/max CPU Cycles)\n",
+                                 min, avg, max);
+
+               len += seq_printf(m, "pci_map_single(): %8ld calls  %8ld pages (avg %d/1000)\n",
+                                 ioc->msingle_calls, ioc->msingle_pages,
+                                 (int)((ioc->msingle_pages * 1000)/ioc->msingle_calls));
 
                /* KLUGE - unmap_sg calls unmap_single for each mapped page */
                min = ioc->usingle_calls - ioc->usg_calls;
                max = ioc->usingle_pages - ioc->usg_pages;
-               len = sprintf(tmp, "pci_unmap_single: %8ld calls  %8ld pages (avg %d/1000)\n",
-                             min, max, (int)((max * 1000)/min));
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
+               len += seq_printf(m, "pci_unmap_single: %8ld calls  %8ld pages (avg %d/1000)\n",
+                                 min, max, (int)((max * 1000)/min));
  
-               len = sprintf(tmp, "pci_map_sg()    : %8ld calls  %8ld pages (avg %d/1000)\n",
-                             ioc->msg_calls, ioc->msg_pages,
-                             (int)((ioc->msg_pages * 1000)/ioc->msg_calls));
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
-               len = sprintf(tmp, "pci_unmap_sg()  : %8ld calls  %8ld pages (avg %d/1000)\n\n\n",
-                             ioc->usg_calls, ioc->usg_pages,
-                             (int)((ioc->usg_pages * 1000)/ioc->usg_calls));
-               if (proc_append(tmp, len, &buf, &offset, &count))
-                       break;
-#endif /* CCIO_MAP_STATS */
+               len += seq_printf(m, "pci_map_sg()    : %8ld calls  %8ld pages (avg %d/1000)\n",
+                                 ioc->msg_calls, ioc->msg_pages,
+                                 (int)((ioc->msg_pages * 1000)/ioc->msg_calls));
+
+               len += seq_printf(m, "pci_unmap_sg()  : %8ld calls  %8ld pages (avg %d/1000)\n\n\n",
+                                 ioc->usg_calls, ioc->usg_pages,
+                                 (int)((ioc->usg_pages * 1000)/ioc->usg_calls));
+#endif /* CCIO_COLLECT_STATS */
+
                ioc = ioc->next;
        }
 
-       if (count == 0) {
-               *eof = 1;
-       }
-       return (max - count);
+       return 0;
+}
+
+static int ccio_proc_info_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, &ccio_proc_info, NULL);
 }
 
-static int ccio_resource_map(char *buf, char **start, off_t offset, int len,
-                            int *eof, void *data)
+static const struct file_operations ccio_proc_info_fops = {
+       .owner = THIS_MODULE,
+       .open = ccio_proc_info_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+
+static int ccio_proc_bitmap_info(struct seq_file *m, void *p)
 {
+       int len = 0;
        struct ioc *ioc = ioc_list;
 
-       buf[0] = '\0';
        while (ioc != NULL) {
                u32 *res_ptr = (u32 *)ioc->res_map;
                int j;
 
                for (j = 0; j < (ioc->res_size / sizeof(u32)); j++) {
                        if ((j & 7) == 0)
-                               strcat(buf,"\n   ");
-                       sprintf(buf, "%s %08x", buf, *res_ptr);
+                               len += seq_puts(m, "\n   ");
+                       len += seq_printf(m, "%08x", *res_ptr);
                        res_ptr++;
                }
-               strcat(buf, "\n\n");
+               len += seq_puts(m, "\n\n");
                ioc = ioc->next;
                break; /* XXX - remove me */
        }
 
-       return strlen(buf);
+       return 0;
 }
-#endif
+
+static int ccio_proc_bitmap_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, &ccio_proc_bitmap_info, NULL);
+}
+
+static const struct file_operations ccio_proc_bitmap_fops = {
+       .owner = THIS_MODULE,
+       .open = ccio_proc_bitmap_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+#endif /* CONFIG_PROC_FS */
 
 /**
  * ccio_find_ioc - Find the ioc in the ioc_list
@@ -1230,7 +1215,7 @@ static int
 ccio_get_iotlb_size(struct parisc_device *dev)
 {
        if (dev->spa_shift == 0) {
-               panic("%s() : Can't determine I/O TLB size.\n", __FUNCTION__);
+               panic("%s() : Can't determine I/O TLB size.\n", __func__);
        }
        return (1 << dev->spa_shift);
 }
@@ -1242,7 +1227,7 @@ ccio_get_iotlb_size(struct parisc_device *dev)
 #endif /* 0 */
 
 /* We *can't* support JAVA (T600). Venture there at your own risk. */
-static struct parisc_device_id ccio_tbl[] = {
+static const struct parisc_device_id ccio_tbl[] = {
        { HPHW_IOA, HVERSION_REV_ANY_ID, U2_IOA_RUNWAY, 0xb }, /* U2 */
        { HPHW_IOA, HVERSION_REV_ANY_ID, UTURN_IOA_RUNWAY, 0xb }, /* UTurn */
        { 0, }
@@ -1320,7 +1305,7 @@ ccio_ioc_init(struct ioc *ioc)
        BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT));
 
        DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n",
-                       __FUNCTION__, ioc->ioc_regs,
+                       __func__, ioc->ioc_regs,
                        (unsigned long) num_physpages >> (20 - PAGE_SHIFT),
                        iova_space_size>>20,
                        iov_order + PAGE_SHIFT);
@@ -1328,7 +1313,7 @@ ccio_ioc_init(struct ioc *ioc)
        ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, 
                                                 get_order(ioc->pdir_size));
        if(NULL == ioc->pdir_base) {
-               panic("%s() could not allocate I/O Page Table\n", __FUNCTION__);
+               panic("%s() could not allocate I/O Page Table\n", __func__);
        }
        memset(ioc->pdir_base, 0, ioc->pdir_size);
 
@@ -1337,12 +1322,12 @@ ccio_ioc_init(struct ioc *ioc)
 
        /* resource map size dictated by pdir_size */
        ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3;
-       DBG_INIT("%s() res_size 0x%x\n", __FUNCTION__, ioc->res_size);
+       DBG_INIT("%s() res_size 0x%x\n", __func__, ioc->res_size);
        
        ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, 
                                              get_order(ioc->res_size));
        if(NULL == ioc->res_map) {
-               panic("%s() could not allocate resource map\n", __FUNCTION__);
+               panic("%s() could not allocate resource map\n", __func__);
        }
        memset(ioc->res_map, 0, ioc->res_size);
 
@@ -1385,7 +1370,7 @@ ccio_ioc_init(struct ioc *ioc)
        }
 }
 
-static void
+static void __init
 ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
 {
        int result;
@@ -1414,7 +1399,7 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
        result = insert_resource(&iomem_resource, res);
        if (result < 0) {
                printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n", 
-                       __FUNCTION__, res->start, res->end);
+                       __func__, (unsigned long)res->start, (unsigned long)res->end);
        }
 }
 
@@ -1552,11 +1537,11 @@ int ccio_request_resource(const struct parisc_device *dev,
  * If so, initialize the chip and tell other partners in crime they
  * have work to do.
  */
-static int ccio_probe(struct parisc_device *dev)
+static int __init ccio_probe(struct parisc_device *dev)
 {
        int i;
        struct ioc *ioc, **ioc_p = &ioc_list;
-       
+
        ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
        if (ioc == NULL) {
                printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
@@ -1565,7 +1550,8 @@ static int ccio_probe(struct parisc_device *dev)
 
        ioc->name = dev->id.hversion == U2_IOA_RUNWAY ? "U2" : "UTurn";
 
-       printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name, dev->hpa.start);
+       printk(KERN_INFO "Found %s at 0x%lx\n", ioc->name,
+               (unsigned long)dev->hpa.start);
 
        for (i = 0; i < ioc_count; i++) {
                ioc_p = &(*ioc_p)->next;
@@ -1573,7 +1559,7 @@ static int ccio_probe(struct parisc_device *dev)
        *ioc_p = ioc;
 
        ioc->hw_path = dev->hw_path;
-       ioc->ioc_regs = ioremap(dev->hpa.start, 4096);
+       ioc->ioc_regs = ioremap_nocache(dev->hpa.start, 4096);
        ccio_ioc_init(ioc);
        ccio_init_resources(ioc);
        hppa_dma_ops = &ccio_ops;
@@ -1582,26 +1568,23 @@ static int ccio_probe(struct parisc_device *dev)
        /* if this fails, no I/O cards will work, so may as well bug */
        BUG_ON(dev->dev.platform_data == NULL);
        HBA_DATA(dev->dev.platform_data)->iommu = ioc;
-       
 
+#ifdef CONFIG_PROC_FS
        if (ioc_count == 0) {
-               /* FIXME: Create separate entries for each ioc */
-               create_proc_read_entry(MODULE_NAME, S_IRWXU, proc_runway_root,
-                                      ccio_proc_info, NULL);
-               create_proc_read_entry(MODULE_NAME"-bitmap", S_IRWXU,
-                                      proc_runway_root, ccio_resource_map, NULL);
+               proc_create(MODULE_NAME, 0, proc_runway_root,
+                           &ccio_proc_info_fops);
+               proc_create(MODULE_NAME"-bitmap", 0, proc_runway_root,
+                           &ccio_proc_bitmap_fops);
        }
-
+#endif
        ioc_count++;
 
-       parisc_vmerge_boundary = IOVP_SIZE;
-       parisc_vmerge_max_size = BITS_PER_LONG * IOVP_SIZE;
        parisc_has_iommu();
        return 0;
 }
 
 /**
- * ccio_init - ccio initalization procedure.
+ * ccio_init - ccio initialization procedure.
  *
  * Register this driver.
  */