Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / char / mem.c
index 6f9c6cc..418da02 100644 (file)
@@ -8,6 +8,7 @@
  *  Shared /dev/zero mmaping support, Feb 2000, Kanoj Sarcar <kanoj@sgi.com>
  */
 
+#include <linux/config.h>
 #include <linux/mm.h>
 #include <linux/miscdevice.h>
 #include <linux/slab.h>
@@ -19,6 +20,7 @@
 #include <linux/tty.h>
 #include <linux/capability.h>
 #include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
 #include <linux/ptrace.h>
 #include <linux/device.h>
 #include <linux/highmem.h>
@@ -111,7 +113,7 @@ static inline int valid_phys_addr_range(unsigned long addr, size_t count)
        return 1;
 }
 
-static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
+static inline int valid_mmap_phys_addr_range(unsigned long addr, size_t size)
 {
        return 1;
 }
@@ -264,7 +266,7 @@ static int mmap_mem(struct file * file, struct vm_area_struct * vma)
 {
        size_t size = vma->vm_end - vma->vm_start;
 
-       if (!valid_mmap_phys_addr_range(vma->vm_pgoff, size))
+       if (!valid_mmap_phys_addr_range(vma->vm_pgoff << PAGE_SHIFT, size))
                return -EINVAL;
 
        vma->vm_page_prot = phys_mem_access_prot(file, vma->vm_pgoff,
@@ -682,7 +684,7 @@ static int open_port(struct inode * inode, struct file * filp)
 #define open_oldmem    open_mem
 
 #ifndef ARCH_HAS_DEV_MEM
-static const struct file_operations mem_fops = {
+static struct file_operations mem_fops = {
        .llseek         = memory_lseek,
        .read           = read_mem,
        .write          = write_mem,
@@ -693,14 +695,14 @@ static const struct file_operations mem_fops = {
 extern struct file_operations mem_fops;
 #endif
 
-static const struct file_operations kmem_fops = {
+static struct file_operations kmem_fops = {
        .llseek         = memory_lseek,
        .read           = read_kmem,
        .mmap           = mmap_kmem,
        .open           = open_kmem,
 };
 
-static const struct file_operations null_fops = {
+static struct file_operations null_fops = {
        .llseek         = null_lseek,
        .read           = read_null,
        .write          = write_null,
@@ -708,7 +710,7 @@ static const struct file_operations null_fops = {
 };
 
 #if defined(CONFIG_ISA) || !defined(__mc68000__)
-static const struct file_operations port_fops = {
+static struct file_operations port_fops = {
        .llseek         = memory_lseek,
        .read           = read_port,
        .write          = write_port,
@@ -716,7 +718,7 @@ static const struct file_operations port_fops = {
 };
 #endif
 
-static const struct file_operations zero_fops = {
+static struct file_operations zero_fops = {
        .llseek         = zero_lseek,
        .read           = read_zero,
        .write          = write_zero,
@@ -727,14 +729,14 @@ static struct backing_dev_info zero_bdi = {
        .capabilities   = BDI_CAP_MAP_COPY,
 };
 
-static const struct file_operations full_fops = {
+static struct file_operations full_fops = {
        .llseek         = full_lseek,
        .read           = read_full,
        .write          = write_full,
 };
 
 #ifdef CONFIG_CRASH_DUMP
-static const struct file_operations oldmem_fops = {
+static struct file_operations oldmem_fops = {
        .read   = read_oldmem,
        .open   = open_oldmem,
 };
@@ -761,7 +763,7 @@ static ssize_t kmsg_write(struct file * file, const char __user * buf,
        return ret;
 }
 
-static const struct file_operations kmsg_fops = {
+static struct file_operations kmsg_fops = {
        .write =        kmsg_write,
 };
 
@@ -811,7 +813,7 @@ static int memory_open(struct inode * inode, struct file * filp)
        return 0;
 }
 
-static const struct file_operations memory_fops = {
+static struct file_operations memory_fops = {
        .open           = memory_open,  /* just a selector for the real open */
 };
 
@@ -846,10 +848,13 @@ static int __init chr_dev_init(void)
                printk("unable to get major %d for memory devs\n", MEM_MAJOR);
 
        mem_class = class_create(THIS_MODULE, "mem");
-       for (i = 0; i < ARRAY_SIZE(devlist); i++)
+       for (i = 0; i < ARRAY_SIZE(devlist); i++) {
                class_device_create(mem_class, NULL,
                                        MKDEV(MEM_MAJOR, devlist[i].minor),
                                        NULL, devlist[i].name);
+               devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
+                               S_IFCHR | devlist[i].mode, devlist[i].name);
+       }
        
        return 0;
 }