]> Pileus Git - ~andy/linux/blobdiff - drivers/char/hpet.c
drivers/char/hpet.c: allow user controlled mmap for user processes
[~andy/linux] / drivers / char / hpet.c
index dca5834685cf93d0cd105e66a7cf656329fc3e2e..5d9c31dfc905eac973f167d4f77d1c8b628de0b0 100644 (file)
@@ -367,12 +367,29 @@ static unsigned int hpet_poll(struct file *file, poll_table * wait)
        return 0;
 }
 
+#ifdef CONFIG_HPET_MMAP
+#ifdef CONFIG_HPET_MMAP_DEFAULT
+static int hpet_mmap_enabled = 1;
+#else
+static int hpet_mmap_enabled = 0;
+#endif
+
+static __init int hpet_mmap_enable(char *str)
+{
+       get_option(&str, &hpet_mmap_enabled);
+       pr_info("HPET mmap %s\n", hpet_mmap_enabled ? "enabled" : "disabled");
+       return 1;
+}
+__setup("hpet_mmap", hpet_mmap_enable);
+
 static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
 {
-#ifdef CONFIG_HPET_MMAP
        struct hpet_dev *devp;
        unsigned long addr;
 
+       if (!hpet_mmap_enabled)
+               return -EACCES;
+
        devp = file->private_data;
        addr = devp->hd_hpets->hp_hpet_phys;
 
@@ -381,10 +398,13 @@ static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
 
        vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
        return vm_iomap_memory(vma, addr, PAGE_SIZE);
+}
 #else
+static int hpet_mmap(struct file *file, struct vm_area_struct *vma)
+{
        return -ENOSYS;
-#endif
 }
+#endif
 
 static int hpet_fasync(int fd, struct file *file, int on)
 {