diff options
Diffstat (limited to 'drivers/char/mem.c')
-rw-r--r-- | drivers/char/mem.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 934ffafedaea..672b08e694d0 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/bootmem.h> | 26 | #include <linux/bootmem.h> |
27 | #include <linux/splice.h> | 27 | #include <linux/splice.h> |
28 | #include <linux/pfn.h> | 28 | #include <linux/pfn.h> |
29 | #include <linux/smp_lock.h> | ||
29 | 30 | ||
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
31 | #include <asm/io.h> | 32 | #include <asm/io.h> |
@@ -79,7 +80,7 @@ static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) | |||
79 | } | 80 | } |
80 | #endif | 81 | #endif |
81 | 82 | ||
82 | #ifdef CONFIG_NONPROMISC_DEVMEM | 83 | #ifdef CONFIG_STRICT_DEVMEM |
83 | static inline int range_is_allowed(unsigned long pfn, unsigned long size) | 84 | static inline int range_is_allowed(unsigned long pfn, unsigned long size) |
84 | { | 85 | { |
85 | u64 from = ((u64)pfn) << PAGE_SHIFT; | 86 | u64 from = ((u64)pfn) << PAGE_SHIFT; |
@@ -326,7 +327,10 @@ static void mmap_mem_close(struct vm_area_struct *vma) | |||
326 | 327 | ||
327 | static struct vm_operations_struct mmap_mem_ops = { | 328 | static struct vm_operations_struct mmap_mem_ops = { |
328 | .open = mmap_mem_open, | 329 | .open = mmap_mem_open, |
329 | .close = mmap_mem_close | 330 | .close = mmap_mem_close, |
331 | #ifdef CONFIG_HAVE_IOREMAP_PROT | ||
332 | .access = generic_access_phys | ||
333 | #endif | ||
330 | }; | 334 | }; |
331 | 335 | ||
332 | static int mmap_mem(struct file * file, struct vm_area_struct * vma) | 336 | static int mmap_mem(struct file * file, struct vm_area_struct * vma) |
@@ -889,6 +893,9 @@ static const struct file_operations kmsg_fops = { | |||
889 | 893 | ||
890 | static int memory_open(struct inode * inode, struct file * filp) | 894 | static int memory_open(struct inode * inode, struct file * filp) |
891 | { | 895 | { |
896 | int ret = 0; | ||
897 | |||
898 | lock_kernel(); | ||
892 | switch (iminor(inode)) { | 899 | switch (iminor(inode)) { |
893 | case 1: | 900 | case 1: |
894 | filp->f_op = &mem_fops; | 901 | filp->f_op = &mem_fops; |
@@ -932,11 +939,13 @@ static int memory_open(struct inode * inode, struct file * filp) | |||
932 | break; | 939 | break; |
933 | #endif | 940 | #endif |
934 | default: | 941 | default: |
942 | unlock_kernel(); | ||
935 | return -ENXIO; | 943 | return -ENXIO; |
936 | } | 944 | } |
937 | if (filp->f_op && filp->f_op->open) | 945 | if (filp->f_op && filp->f_op->open) |
938 | return filp->f_op->open(inode,filp); | 946 | ret = filp->f_op->open(inode,filp); |
939 | return 0; | 947 | unlock_kernel(); |
948 | return ret; | ||
940 | } | 949 | } |
941 | 950 | ||
942 | static const struct file_operations memory_fops = { | 951 | static const struct file_operations memory_fops = { |
@@ -983,9 +992,9 @@ static int __init chr_dev_init(void) | |||
983 | 992 | ||
984 | mem_class = class_create(THIS_MODULE, "mem"); | 993 | mem_class = class_create(THIS_MODULE, "mem"); |
985 | for (i = 0; i < ARRAY_SIZE(devlist); i++) | 994 | for (i = 0; i < ARRAY_SIZE(devlist); i++) |
986 | device_create(mem_class, NULL, | 995 | device_create_drvdata(mem_class, NULL, |
987 | MKDEV(MEM_MAJOR, devlist[i].minor), | 996 | MKDEV(MEM_MAJOR, devlist[i].minor), |
988 | devlist[i].name); | 997 | NULL, devlist[i].name); |
989 | 998 | ||
990 | return 0; | 999 | return 0; |
991 | } | 1000 | } |