aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/drivers/mmapper_kern.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/drivers/mmapper_kern.c')
-rw-r--r--arch/um/drivers/mmapper_kern.c64
1 files changed, 30 insertions, 34 deletions
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c
index 867666a02339..67b2f55a602f 100644
--- a/arch/um/drivers/mmapper_kern.c
+++ b/arch/um/drivers/mmapper_kern.c
@@ -9,27 +9,29 @@
9 * 9 *
10 */ 10 */
11 11
12#include <linux/init.h> 12#include <linux/stddef.h>
13#include <linux/module.h> 13#include <linux/types.h>
14#include <linux/mm.h>
15#include <linux/fs.h> 14#include <linux/fs.h>
15#include <linux/init.h>
16#include <linux/miscdevice.h> 16#include <linux/miscdevice.h>
17#include <linux/module.h>
18#include <linux/mm.h>
17#include <asm/uaccess.h> 19#include <asm/uaccess.h>
18#include "mem_user.h" 20#include "mem_user.h"
19 21
20/* These are set in mmapper_init, which is called at boot time */ 22/* These are set in mmapper_init, which is called at boot time */
21static unsigned long mmapper_size; 23static unsigned long mmapper_size;
22static unsigned long p_buf = 0; 24static unsigned long p_buf;
23static char *v_buf = NULL; 25static char *v_buf;
24 26
25static ssize_t 27static ssize_t mmapper_read(struct file *file, char __user *buf, size_t count,
26mmapper_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) 28 loff_t *ppos)
27{ 29{
28 return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size); 30 return simple_read_from_buffer(buf, count, ppos, v_buf, mmapper_size);
29} 31}
30 32
31static ssize_t 33static ssize_t mmapper_write(struct file *file, const char __user *buf,
32mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 34 size_t count, loff_t *ppos)
33{ 35{
34 if (*ppos > mmapper_size) 36 if (*ppos > mmapper_size)
35 return -EINVAL; 37 return -EINVAL;
@@ -39,48 +41,46 @@ mmapper_write(struct file *file, const char __user *buf, size_t count, loff_t *p
39 41
40 if (copy_from_user(&v_buf[*ppos], buf, count)) 42 if (copy_from_user(&v_buf[*ppos], buf, count))
41 return -EFAULT; 43 return -EFAULT;
42 44
43 return count; 45 return count;
44} 46}
45 47
46static int 48static int mmapper_ioctl(struct inode *inode, struct file *file,
47mmapper_ioctl(struct inode *inode, struct file *file, unsigned int cmd, 49 unsigned int cmd, unsigned long arg)
48 unsigned long arg)
49{ 50{
50 return(-ENOIOCTLCMD); 51 return -ENOIOCTLCMD;
51} 52}
52 53
53static int 54static int mmapper_mmap(struct file *file, struct vm_area_struct *vma)
54mmapper_mmap(struct file *file, struct vm_area_struct * vma)
55{ 55{
56 int ret = -EINVAL; 56 int ret = -EINVAL;
57 int size; 57 int size;
58 58
59 if (vma->vm_pgoff != 0) 59 if (vma->vm_pgoff != 0)
60 goto out; 60 goto out;
61 61
62 size = vma->vm_end - vma->vm_start; 62 size = vma->vm_end - vma->vm_start;
63 if(size > mmapper_size) return(-EFAULT); 63 if (size > mmapper_size)
64 return -EFAULT;
64 65
65 /* XXX A comment above remap_pfn_range says it should only be 66 /*
67 * XXX A comment above remap_pfn_range says it should only be
66 * called when the mm semaphore is held 68 * called when the mm semaphore is held
67 */ 69 */
68 if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size, 70 if (remap_pfn_range(vma, vma->vm_start, p_buf >> PAGE_SHIFT, size,
69 vma->vm_page_prot)) 71 vma->vm_page_prot))
70 goto out; 72 goto out;
71 ret = 0; 73 ret = 0;
72out: 74out:
73 return ret; 75 return ret;
74} 76}
75 77
76static int 78static int mmapper_open(struct inode *inode, struct file *file)
77mmapper_open(struct inode *inode, struct file *file)
78{ 79{
79 return 0; 80 return 0;
80} 81}
81 82
82static int 83static int mmapper_release(struct inode *inode, struct file *file)
83mmapper_release(struct inode *inode, struct file *file)
84{ 84{
85 return 0; 85 return 0;
86} 86}
@@ -95,7 +95,9 @@ static const struct file_operations mmapper_fops = {
95 .release = mmapper_release, 95 .release = mmapper_release,
96}; 96};
97 97
98/* No locking needed - only used (and modified) by below initcall and exitcall. */ 98/*
99 * No locking needed - only used (and modified) by below initcall and exitcall.
100 */
99static struct miscdevice mmapper_dev = { 101static struct miscdevice mmapper_dev = {
100 .minor = MISC_DYNAMIC_MINOR, 102 .minor = MISC_DYNAMIC_MINOR,
101 .name = "mmapper", 103 .name = "mmapper",
@@ -109,13 +111,13 @@ static int __init mmapper_init(void)
109 printk(KERN_INFO "Mapper v0.1\n"); 111 printk(KERN_INFO "Mapper v0.1\n");
110 112
111 v_buf = (char *) find_iomem("mmapper", &mmapper_size); 113 v_buf = (char *) find_iomem("mmapper", &mmapper_size);
112 if(mmapper_size == 0){ 114 if (mmapper_size == 0) {
113 printk(KERN_ERR "mmapper_init - find_iomem failed\n"); 115 printk(KERN_ERR "mmapper_init - find_iomem failed\n");
114 goto out; 116 goto out;
115 } 117 }
116 118
117 err = misc_register(&mmapper_dev); 119 err = misc_register(&mmapper_dev);
118 if(err){ 120 if (err) {
119 printk(KERN_ERR "mmapper - misc_register failed, err = %d\n", 121 printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
120 err); 122 err);
121 goto out; 123 goto out;
@@ -136,9 +138,3 @@ module_exit(mmapper_exit);
136 138
137MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>"); 139MODULE_AUTHOR("Greg Lonnon <glonnon@ridgerun.com>");
138MODULE_DESCRIPTION("DSPLinux simulator mmapper driver"); 140MODULE_DESCRIPTION("DSPLinux simulator mmapper driver");
139/*
140 * ---------------------------------------------------------------------------
141 * Local variables:
142 * c-file-style: "linux"
143 * End:
144 */