Mercurial > mplayer.hg
comparison vidix/kernelhelper/dhahelper.c @ 26753:502f04b67653
cosmetics: Remove useless parentheses from return statements.
author | diego |
---|---|
date | Fri, 16 May 2008 00:13:03 +0000 |
parents | a9e111b88c4a |
children |
comparison
equal
deleted
inserted
replaced
26752:65f61607e32f | 26753:502f04b67653 |
---|---|
104 { | 104 { |
105 if (dhahelper_verbosity > 1) | 105 if (dhahelper_verbosity > 1) |
106 printk(KERN_DEBUG "dhahelper: device opened\n"); | 106 printk(KERN_DEBUG "dhahelper: device opened\n"); |
107 | 107 |
108 if (MINOR(inode->i_rdev) != 0) | 108 if (MINOR(inode->i_rdev) != 0) |
109 return(-ENXIO); | 109 return -ENXIO; |
110 | 110 |
111 MOD_INC_USE_COUNT; | 111 MOD_INC_USE_COUNT; |
112 | 112 |
113 return(0); | 113 return 0; |
114 } | 114 } |
115 | 115 |
116 static int dhahelper_release(struct inode *inode, struct file *file) | 116 static int dhahelper_release(struct inode *inode, struct file *file) |
117 { | 117 { |
118 if (dhahelper_verbosity > 1) | 118 if (dhahelper_verbosity > 1) |
119 printk(KERN_DEBUG "dhahelper: device released\n"); | 119 printk(KERN_DEBUG "dhahelper: device released\n"); |
120 | 120 |
121 if (MINOR(inode->i_rdev) != 0) | 121 if (MINOR(inode->i_rdev) != 0) |
122 return(-ENXIO); | 122 return -ENXIO; |
123 | 123 |
124 MOD_DEC_USE_COUNT; | 124 MOD_DEC_USE_COUNT; |
125 | 125 |
126 return(0); | 126 return 0; |
127 } | 127 } |
128 | 128 |
129 static int dhahelper_ioctl(struct inode *inode, struct file *file, | 129 static int dhahelper_ioctl(struct inode *inode, struct file *file, |
130 unsigned int cmd, unsigned long arg) | 130 unsigned int cmd, unsigned long arg) |
131 { | 131 { |
132 if (dhahelper_verbosity > 1) | 132 if (dhahelper_verbosity > 1) |
133 printk(KERN_DEBUG "dhahelper: ioctl(cmd=%x, arg=%lx)\n", | 133 printk(KERN_DEBUG "dhahelper: ioctl(cmd=%x, arg=%lx)\n", |
134 cmd, arg); | 134 cmd, arg); |
135 | 135 |
136 if (MINOR(inode->i_rdev) != 0) | 136 if (MINOR(inode->i_rdev) != 0) |
137 return(-ENXIO); | 137 return -ENXIO; |
138 | 138 |
139 switch(cmd) | 139 switch(cmd) |
140 { | 140 { |
141 case DHAHELPER_GET_VERSION: | 141 case DHAHELPER_GET_VERSION: |
142 { | 142 { |
144 | 144 |
145 if (copy_to_user((int *)arg, &version, sizeof(int))) | 145 if (copy_to_user((int *)arg, &version, sizeof(int))) |
146 { | 146 { |
147 if (dhahelper_verbosity > 0) | 147 if (dhahelper_verbosity > 0) |
148 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); | 148 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); |
149 return(-EFAULT); | 149 return -EFAULT; |
150 } | 150 } |
151 | 151 |
152 break; | 152 break; |
153 } | 153 } |
154 case DHAHELPER_PORT: | 154 case DHAHELPER_PORT: |
157 | 157 |
158 if (copy_from_user(&port, (dhahelper_port_t *)arg, sizeof(dhahelper_port_t))) | 158 if (copy_from_user(&port, (dhahelper_port_t *)arg, sizeof(dhahelper_port_t))) |
159 { | 159 { |
160 if (dhahelper_verbosity > 0) | 160 if (dhahelper_verbosity > 0) |
161 printk(KERN_ERR "dhahelper: failed copy from userspace\n"); | 161 printk(KERN_ERR "dhahelper: failed copy from userspace\n"); |
162 return(-EFAULT); | 162 return -EFAULT; |
163 } | 163 } |
164 | 164 |
165 switch(port.operation) | 165 switch(port.operation) |
166 { | 166 { |
167 case PORT_OP_READ: | 167 case PORT_OP_READ: |
179 break; | 179 break; |
180 default: | 180 default: |
181 if (dhahelper_verbosity > 0) | 181 if (dhahelper_verbosity > 0) |
182 printk(KERN_ERR "dhahelper: invalid port read size (%d)\n", | 182 printk(KERN_ERR "dhahelper: invalid port read size (%d)\n", |
183 port.size); | 183 port.size); |
184 return(-EINVAL); | 184 return -EINVAL; |
185 } | 185 } |
186 break; | 186 break; |
187 } | 187 } |
188 case PORT_OP_WRITE: | 188 case PORT_OP_WRITE: |
189 { | 189 { |
200 break; | 200 break; |
201 default: | 201 default: |
202 if (dhahelper_verbosity > 0) | 202 if (dhahelper_verbosity > 0) |
203 printk(KERN_ERR "dhahelper: invalid port write size (%d)\n", | 203 printk(KERN_ERR "dhahelper: invalid port write size (%d)\n", |
204 port.size); | 204 port.size); |
205 return(-EINVAL); | 205 return -EINVAL; |
206 } | 206 } |
207 break; | 207 break; |
208 } | 208 } |
209 default: | 209 default: |
210 if (dhahelper_verbosity > 0) | 210 if (dhahelper_verbosity > 0) |
211 printk(KERN_ERR "dhahelper: invalid port operation (%d)\n", | 211 printk(KERN_ERR "dhahelper: invalid port operation (%d)\n", |
212 port.operation); | 212 port.operation); |
213 return(-EINVAL); | 213 return -EINVAL; |
214 } | 214 } |
215 | 215 |
216 /* copy back only if read was performed */ | 216 /* copy back only if read was performed */ |
217 if (port.operation == PORT_OP_READ) | 217 if (port.operation == PORT_OP_READ) |
218 if (copy_to_user((dhahelper_port_t *)arg, &port, sizeof(dhahelper_port_t))) | 218 if (copy_to_user((dhahelper_port_t *)arg, &port, sizeof(dhahelper_port_t))) |
219 { | 219 { |
220 if (dhahelper_verbosity > 0) | 220 if (dhahelper_verbosity > 0) |
221 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); | 221 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); |
222 return(-EFAULT); | 222 return -EFAULT; |
223 } | 223 } |
224 | 224 |
225 break; | 225 break; |
226 } | 226 } |
227 case DHAHELPER_MEMORY: | 227 case DHAHELPER_MEMORY: |
230 | 230 |
231 if (copy_from_user(&mem, (dhahelper_memory_t *)arg, sizeof(dhahelper_memory_t))) | 231 if (copy_from_user(&mem, (dhahelper_memory_t *)arg, sizeof(dhahelper_memory_t))) |
232 { | 232 { |
233 if (dhahelper_verbosity > 0) | 233 if (dhahelper_verbosity > 0) |
234 printk(KERN_ERR "dhahelper: failed copy from userspace\n"); | 234 printk(KERN_ERR "dhahelper: failed copy from userspace\n"); |
235 return(-EFAULT); | 235 return -EFAULT; |
236 } | 236 } |
237 | 237 |
238 switch(mem.operation) | 238 switch(mem.operation) |
239 { | 239 { |
240 case MEMORY_OP_MAP: | 240 case MEMORY_OP_MAP: |
252 break; | 252 break; |
253 default: | 253 default: |
254 if (dhahelper_verbosity > 0) | 254 if (dhahelper_verbosity > 0) |
255 printk(KERN_ERR "dhahelper: invalid memory operation (%d)\n", | 255 printk(KERN_ERR "dhahelper: invalid memory operation (%d)\n", |
256 mem.operation); | 256 mem.operation); |
257 return(-EINVAL); | 257 return -EINVAL; |
258 } | 258 } |
259 | 259 |
260 if (copy_to_user((dhahelper_memory_t *)arg, &mem, sizeof(dhahelper_memory_t))) | 260 if (copy_to_user((dhahelper_memory_t *)arg, &mem, sizeof(dhahelper_memory_t))) |
261 { | 261 { |
262 if (dhahelper_verbosity > 0) | 262 if (dhahelper_verbosity > 0) |
263 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); | 263 printk(KERN_ERR "dhahelper: failed copy to userspace\n"); |
264 return(-EFAULT); | 264 return -EFAULT; |
265 } | 265 } |
266 | 266 |
267 break; | 267 break; |
268 } | 268 } |
269 default: | 269 default: |
270 if (dhahelper_verbosity > 0) | 270 if (dhahelper_verbosity > 0) |
271 printk(KERN_ERR "dhahelper: invalid ioctl (%x)\n", cmd); | 271 printk(KERN_ERR "dhahelper: invalid ioctl (%x)\n", cmd); |
272 return(-EINVAL); | 272 return -EINVAL; |
273 } | 273 } |
274 | 274 |
275 return(0); | 275 return 0; |
276 } | 276 } |
277 | 277 |
278 static int dhahelper_mmap(struct file *file, struct vm_area_struct *vma) | 278 static int dhahelper_mmap(struct file *file, struct vm_area_struct *vma) |
279 { | 279 { |
280 if (last_mem_request.operation != MEMORY_OP_MAP) | 280 if (last_mem_request.operation != MEMORY_OP_MAP) |
281 { | 281 { |
282 if (dhahelper_verbosity > 0) | 282 if (dhahelper_verbosity > 0) |
283 printk(KERN_ERR "dhahelper: mapping not requested before mmap\n"); | 283 printk(KERN_ERR "dhahelper: mapping not requested before mmap\n"); |
284 return(-EFAULT); | 284 return -EFAULT; |
285 } | 285 } |
286 | 286 |
287 if (dhahelper_verbosity > 1) | 287 if (dhahelper_verbosity > 1) |
288 printk(KERN_INFO "dhahelper: mapping %x (size: %x)\n", | 288 printk(KERN_INFO "dhahelper: mapping %x (size: %x)\n", |
289 last_mem_request.start+last_mem_request.offset, last_mem_request.size); | 289 last_mem_request.start+last_mem_request.offset, last_mem_request.size); |
291 if (remap_page_range(0, last_mem_request.start + last_mem_request.offset, | 291 if (remap_page_range(0, last_mem_request.start + last_mem_request.offset, |
292 last_mem_request.size, vma->vm_page_prot)) | 292 last_mem_request.size, vma->vm_page_prot)) |
293 { | 293 { |
294 if (dhahelper_verbosity > 0) | 294 if (dhahelper_verbosity > 0) |
295 printk(KERN_ERR "dhahelper: error mapping memory\n"); | 295 printk(KERN_ERR "dhahelper: error mapping memory\n"); |
296 return(-EFAULT); | 296 return -EFAULT; |
297 } | 297 } |
298 | 298 |
299 return(0); | 299 return 0; |
300 } | 300 } |
301 | 301 |
302 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) | 302 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0) |
303 static struct file_operations dhahelper_fops = | 303 static struct file_operations dhahelper_fops = |
304 { | 304 { |
336 if(register_chrdev(dhahelper_major, "dhahelper", &dhahelper_fops)) | 336 if(register_chrdev(dhahelper_major, "dhahelper", &dhahelper_fops)) |
337 { | 337 { |
338 if (dhahelper_verbosity > 0) | 338 if (dhahelper_verbosity > 0) |
339 printk(KERN_ERR "dhahelper: unable to register character device (major: %d)\n", | 339 printk(KERN_ERR "dhahelper: unable to register character device (major: %d)\n", |
340 dhahelper_major); | 340 dhahelper_major); |
341 return(-EIO); | 341 return -EIO; |
342 } | 342 } |
343 | 343 |
344 return(0); | 344 return 0; |
345 } | 345 } |
346 | 346 |
347 #if KERNEL_VERSION < KERNEL_VERSION(2,4,0) | 347 #if KERNEL_VERSION < KERNEL_VERSION(2,4,0) |
348 void cleanup_module(void) | 348 void cleanup_module(void) |
349 #else | 349 #else |