It looks at least odd to apply spin_unlock to a mutex.
[linux-2.6/mini2440.git] / drivers / sbus / char / vfc_dev.c
blobd4f8fcded51d8615e1da7cd5996ac715b0defd9e
1 /*
2 * drivers/sbus/char/vfc_dev.c
4 * Driver for the Videopix Frame Grabber.
5 *
6 * In order to use the VFC you need to program the video controller
7 * chip. This chip is the Phillips SAA9051. You need to call their
8 * documentation ordering line to get the docs.
10 * There is very little documentation on the VFC itself. There is
11 * some useful info that can be found in the manuals that come with
12 * the card. I will hopefully write some better docs at a later date.
14 * Copyright (C) 1996 Manish Vachharajani (mvachhar@noc.rutgers.edu)
15 * */
17 #include <linux/module.h>
18 #include <linux/kernel.h>
19 #include <linux/string.h>
20 #include <linux/slab.h>
21 #include <linux/errno.h>
22 #include <linux/fs.h>
23 #include <linux/delay.h>
24 #include <linux/spinlock.h>
25 #include <linux/mutex.h>
26 #include <linux/mm.h>
28 #include <asm/openprom.h>
29 #include <asm/oplib.h>
30 #include <asm/io.h>
31 #include <asm/system.h>
32 #include <asm/sbus.h>
33 #include <asm/page.h>
34 #include <asm/pgtable.h>
35 #include <asm/uaccess.h>
37 #define VFC_MAJOR (60)
39 #if 0
40 #define VFC_IOCTL_DEBUG
41 #endif
43 #include "vfc.h"
44 #include <asm/vfc_ioctls.h>
46 static const struct file_operations vfc_fops;
47 struct vfc_dev **vfc_dev_lst;
48 static char vfcstr[]="vfc";
49 static unsigned char saa9051_init_array[VFC_SAA9051_NR] = {
50 0x00, 0x64, 0x72, 0x52,
51 0x36, 0x18, 0xff, 0x20,
52 0xfc, 0x77, 0xe3, 0x50,
53 0x3e
56 void vfc_lock_device(struct vfc_dev *dev)
58 mutex_lock(&dev->device_lock_mtx);
61 void vfc_unlock_device(struct vfc_dev *dev)
63 mutex_unlock(&dev->device_lock_mtx);
67 void vfc_captstat_reset(struct vfc_dev *dev)
69 dev->control_reg |= VFC_CONTROL_CAPTRESET;
70 sbus_writel(dev->control_reg, &dev->regs->control);
71 dev->control_reg &= ~VFC_CONTROL_CAPTRESET;
72 sbus_writel(dev->control_reg, &dev->regs->control);
73 dev->control_reg |= VFC_CONTROL_CAPTRESET;
74 sbus_writel(dev->control_reg, &dev->regs->control);
77 void vfc_memptr_reset(struct vfc_dev *dev)
79 dev->control_reg |= VFC_CONTROL_MEMPTR;
80 sbus_writel(dev->control_reg, &dev->regs->control);
81 dev->control_reg &= ~VFC_CONTROL_MEMPTR;
82 sbus_writel(dev->control_reg, &dev->regs->control);
83 dev->control_reg |= VFC_CONTROL_MEMPTR;
84 sbus_writel(dev->control_reg, &dev->regs->control);
87 int vfc_csr_init(struct vfc_dev *dev)
89 dev->control_reg = 0x80000000;
90 sbus_writel(dev->control_reg, &dev->regs->control);
91 udelay(200);
92 dev->control_reg &= ~0x80000000;
93 sbus_writel(dev->control_reg, &dev->regs->control);
94 udelay(100);
95 sbus_writel(0x0f000000, &dev->regs->i2c_magic2);
97 vfc_memptr_reset(dev);
99 dev->control_reg &= ~VFC_CONTROL_DIAGMODE;
100 dev->control_reg &= ~VFC_CONTROL_CAPTURE;
101 dev->control_reg |= 0x40000000;
102 sbus_writel(dev->control_reg, &dev->regs->control);
104 vfc_captstat_reset(dev);
106 return 0;
109 int vfc_saa9051_init(struct vfc_dev *dev)
111 int i;
113 for (i = 0; i < VFC_SAA9051_NR; i++)
114 dev->saa9051_state_array[i] = saa9051_init_array[i];
116 vfc_i2c_sendbuf(dev,VFC_SAA9051_ADDR,
117 dev->saa9051_state_array, VFC_SAA9051_NR);
118 return 0;
121 int init_vfc_hw(struct vfc_dev *dev)
123 vfc_lock_device(dev);
124 vfc_csr_init(dev);
126 vfc_pcf8584_init(dev);
127 vfc_init_i2c_bus(dev); /* hopefully this doesn't undo the magic
128 sun code above*/
129 vfc_saa9051_init(dev);
130 vfc_unlock_device(dev);
131 return 0;
134 int init_vfc_devstruct(struct vfc_dev *dev, int instance)
136 dev->instance=instance;
137 mutex_init(&dev->device_lock_mtx);
138 dev->control_reg=0;
139 dev->busy=0;
140 return 0;
143 int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev, int instance)
145 if(dev == NULL) {
146 printk(KERN_ERR "VFC: Bogus pointer passed\n");
147 return -ENOMEM;
149 printk("Initializing vfc%d\n",instance);
150 dev->regs = NULL;
151 dev->regs = (volatile struct vfc_regs __iomem *)
152 sbus_ioremap(&sdev->resource[0], 0,
153 sizeof(struct vfc_regs), vfcstr);
154 dev->which_io = sdev->reg_addrs[0].which_io;
155 dev->phys_regs = (struct vfc_regs *) sdev->reg_addrs[0].phys_addr;
156 if (dev->regs == NULL)
157 return -EIO;
159 printk("vfc%d: registers mapped at phys_addr: 0x%lx\n virt_addr: 0x%lx\n",
160 instance,(unsigned long)sdev->reg_addrs[0].phys_addr,(unsigned long)dev->regs);
162 if (init_vfc_devstruct(dev, instance))
163 return -EINVAL;
164 if (init_vfc_hw(dev))
165 return -EIO;
166 return 0;
170 struct vfc_dev *vfc_get_dev_ptr(int instance)
172 return vfc_dev_lst[instance];
175 static DEFINE_SPINLOCK(vfc_dev_lock);
177 static int vfc_open(struct inode *inode, struct file *file)
179 struct vfc_dev *dev;
181 spin_lock(&vfc_dev_lock);
182 dev = vfc_get_dev_ptr(iminor(inode));
183 if (dev == NULL) {
184 spin_unlock(&vfc_dev_lock);
185 return -ENODEV;
187 if (dev->busy) {
188 spin_unlock(&vfc_dev_lock);
189 return -EBUSY;
192 dev->busy = 1;
193 spin_unlock(&vfc_dev_lock);
195 vfc_lock_device(dev);
197 vfc_csr_init(dev);
198 vfc_pcf8584_init(dev);
199 vfc_init_i2c_bus(dev);
200 vfc_saa9051_init(dev);
201 vfc_memptr_reset(dev);
202 vfc_captstat_reset(dev);
204 vfc_unlock_device(dev);
205 return 0;
208 static int vfc_release(struct inode *inode,struct file *file)
210 struct vfc_dev *dev;
212 spin_lock(&vfc_dev_lock);
213 dev = vfc_get_dev_ptr(iminor(inode));
214 if (!dev || !dev->busy) {
215 spin_unlock(&vfc_dev_lock);
216 return -EINVAL;
218 dev->busy = 0;
219 spin_unlock(&vfc_dev_lock);
220 return 0;
223 static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp)
225 struct vfc_debug_inout inout;
226 unsigned char *buffer;
228 if (!capable(CAP_SYS_ADMIN))
229 return -EPERM;
231 switch(cmd) {
232 case VFC_I2C_SEND:
233 if(copy_from_user(&inout, argp, sizeof(inout)))
234 return -EFAULT;
236 buffer = kmalloc(inout.len, GFP_KERNEL);
237 if (buffer == NULL)
238 return -ENOMEM;
240 if(copy_from_user(buffer, inout.buffer, inout.len)) {
241 kfree(buffer);
242 return -EFAULT;
246 vfc_lock_device(dev);
247 inout.ret=
248 vfc_i2c_sendbuf(dev,inout.addr & 0xff,
249 buffer,inout.len);
251 if (copy_to_user(argp,&inout,sizeof(inout))) {
252 vfc_unlock_device(dev);
253 kfree(buffer);
254 return -EFAULT;
256 vfc_unlock_device(dev);
258 break;
259 case VFC_I2C_RECV:
260 if (copy_from_user(&inout, argp, sizeof(inout)))
261 return -EFAULT;
263 buffer = kzalloc(inout.len, GFP_KERNEL);
264 if (buffer == NULL)
265 return -ENOMEM;
267 vfc_lock_device(dev);
268 inout.ret=
269 vfc_i2c_recvbuf(dev,inout.addr & 0xff
270 ,buffer,inout.len);
271 vfc_unlock_device(dev);
273 if (copy_to_user(inout.buffer, buffer, inout.len)) {
274 kfree(buffer);
275 return -EFAULT;
277 if (copy_to_user(argp,&inout,sizeof(inout))) {
278 kfree(buffer);
279 return -EFAULT;
281 kfree(buffer);
282 break;
283 default:
284 return -EINVAL;
287 return 0;
290 int vfc_capture_start(struct vfc_dev *dev)
292 vfc_captstat_reset(dev);
293 dev->control_reg = sbus_readl(&dev->regs->control);
294 if((dev->control_reg & VFC_STATUS_CAPTURE)) {
295 printk(KERN_ERR "vfc%d: vfc capture status not reset\n",
296 dev->instance);
297 return -EIO;
300 vfc_lock_device(dev);
301 dev->control_reg &= ~VFC_CONTROL_CAPTURE;
302 sbus_writel(dev->control_reg, &dev->regs->control);
303 dev->control_reg |= VFC_CONTROL_CAPTURE;
304 sbus_writel(dev->control_reg, &dev->regs->control);
305 dev->control_reg &= ~VFC_CONTROL_CAPTURE;
306 sbus_writel(dev->control_reg, &dev->regs->control);
307 vfc_unlock_device(dev);
309 return 0;
312 int vfc_capture_poll(struct vfc_dev *dev)
314 int timeout = 1000;
316 while (!timeout--) {
317 if (sbus_readl(&dev->regs->control) & VFC_STATUS_CAPTURE)
318 break;
319 vfc_i2c_delay_no_busy(dev, 100);
321 if(!timeout) {
322 printk(KERN_WARNING "vfc%d: capture timed out\n",
323 dev->instance);
324 return -ETIMEDOUT;
326 return 0;
331 static int vfc_set_control_ioctl(struct inode *inode, struct file *file,
332 struct vfc_dev *dev, unsigned long arg)
334 int setcmd, ret = 0;
336 if (copy_from_user(&setcmd,(void __user *)arg,sizeof(unsigned int)))
337 return -EFAULT;
339 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCSCTRL) arg=0x%x\n",
340 dev->instance,setcmd));
342 switch(setcmd) {
343 case MEMPRST:
344 vfc_lock_device(dev);
345 vfc_memptr_reset(dev);
346 vfc_unlock_device(dev);
347 ret=0;
348 break;
349 case CAPTRCMD:
350 vfc_capture_start(dev);
351 vfc_capture_poll(dev);
352 break;
353 case DIAGMODE:
354 if(capable(CAP_SYS_ADMIN)) {
355 vfc_lock_device(dev);
356 dev->control_reg |= VFC_CONTROL_DIAGMODE;
357 sbus_writel(dev->control_reg, &dev->regs->control);
358 vfc_unlock_device(dev);
359 ret = 0;
360 } else {
361 ret = -EPERM;
363 break;
364 case NORMMODE:
365 vfc_lock_device(dev);
366 dev->control_reg &= ~VFC_CONTROL_DIAGMODE;
367 sbus_writel(dev->control_reg, &dev->regs->control);
368 vfc_unlock_device(dev);
369 ret = 0;
370 break;
371 case CAPTRSTR:
372 vfc_capture_start(dev);
373 ret = 0;
374 break;
375 case CAPTRWAIT:
376 vfc_capture_poll(dev);
377 ret = 0;
378 break;
379 default:
380 ret = -EINVAL;
381 break;
384 return ret;
388 int vfc_port_change_ioctl(struct inode *inode, struct file *file,
389 struct vfc_dev *dev, unsigned long arg)
391 int ret = 0;
392 int cmd;
394 if(copy_from_user(&cmd, (void __user *)arg, sizeof(unsigned int))) {
395 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer to "
396 "vfc_port_change_ioctl\n",
397 dev->instance));
398 return -EFAULT;
401 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCPORTCHG) arg=0x%x\n",
402 dev->instance, cmd));
404 switch(cmd) {
405 case 1:
406 case 2:
407 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_START) = 0x72;
408 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_STOP) = 0x52;
409 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_START) = 0x36;
410 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_STOP) = 0x18;
411 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) = VFC_SAA9051_BP2;
412 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) = VFC_SAA9051_CT | VFC_SAA9051_SS3;
413 VFC_SAA9051_SA(dev,VFC_SAA9051_SECAM_DELAY) = 0x3e;
414 break;
415 case 3:
416 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_START) = 0x3a;
417 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_STOP) = 0x17;
418 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_START) = 0xfa;
419 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_STOP) = 0xde;
420 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) =
421 VFC_SAA9051_BY | VFC_SAA9051_PF | VFC_SAA9051_BP2;
422 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) = VFC_SAA9051_YC;
423 VFC_SAA9051_SA(dev,VFC_SAA9051_SECAM_DELAY) = 0;
424 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) &=
425 ~(VFC_SAA9051_SS0 | VFC_SAA9051_SS1);
426 break;
427 default:
428 ret = -EINVAL;
429 return ret;
430 break;
433 switch(cmd) {
434 case 1:
435 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) |=
436 (VFC_SAA9051_SS0 | VFC_SAA9051_SS1);
437 break;
438 case 2:
439 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) &=
440 ~(VFC_SAA9051_SS0 | VFC_SAA9051_SS1);
441 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) |= VFC_SAA9051_SS0;
442 break;
443 case 3:
444 break;
445 default:
446 ret = -EINVAL;
447 return ret;
448 break;
450 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) &= ~(VFC_SAA9051_SS2);
451 ret=vfc_update_saa9051(dev);
452 udelay(500);
453 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) |= (VFC_SAA9051_SS2);
454 ret=vfc_update_saa9051(dev);
455 return ret;
458 int vfc_set_video_ioctl(struct inode *inode, struct file *file,
459 struct vfc_dev *dev, unsigned long arg)
461 int ret = 0;
462 int cmd;
464 if(copy_from_user(&cmd, (void __user *)arg, sizeof(unsigned int))) {
465 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer to "
466 "vfc_set_video_ioctl\n",
467 dev->instance));
468 return ret;
471 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCSVID) arg=0x%x\n",
472 dev->instance, cmd));
473 switch(cmd) {
474 case STD_NTSC:
475 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~VFC_SAA9051_ALT;
476 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_YPN |
477 VFC_SAA9051_CCFR0 | VFC_SAA9051_CCFR1 | VFC_SAA9051_FS;
478 ret = vfc_update_saa9051(dev);
479 break;
480 case STD_PAL:
481 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~(VFC_SAA9051_YPN |
482 VFC_SAA9051_CCFR1 |
483 VFC_SAA9051_CCFR0 |
484 VFC_SAA9051_FS);
485 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_ALT;
486 ret = vfc_update_saa9051(dev);
487 break;
489 case COLOR_ON:
490 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_CO;
491 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) &=
492 ~(VFC_SAA9051_BY | VFC_SAA9051_PF);
493 ret = vfc_update_saa9051(dev);
494 break;
495 case MONO:
496 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~(VFC_SAA9051_CO);
497 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) |=
498 (VFC_SAA9051_BY | VFC_SAA9051_PF);
499 ret = vfc_update_saa9051(dev);
500 break;
501 default:
502 ret = -EINVAL;
503 break;
506 return ret;
509 int vfc_get_video_ioctl(struct inode *inode, struct file *file,
510 struct vfc_dev *dev, unsigned long arg)
512 int ret = 0;
513 unsigned int status = NO_LOCK;
514 unsigned char buf[1];
516 if(vfc_i2c_recvbuf(dev, VFC_SAA9051_ADDR, buf, 1)) {
517 printk(KERN_ERR "vfc%d: Unable to get status\n",
518 dev->instance);
519 return -EIO;
522 if(buf[0] & VFC_SAA9051_HLOCK) {
523 status = NO_LOCK;
524 } else if(buf[0] & VFC_SAA9051_FD) {
525 if(buf[0] & VFC_SAA9051_CD)
526 status = NTSC_COLOR;
527 else
528 status = NTSC_NOCOLOR;
529 } else {
530 if(buf[0] & VFC_SAA9051_CD)
531 status = PAL_COLOR;
532 else
533 status = PAL_NOCOLOR;
535 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCGVID) returning status 0x%x; "
536 "buf[0]=%x\n", dev->instance, status, buf[0]));
538 if (copy_to_user((void __user *)arg,&status,sizeof(unsigned int))) {
539 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer to "
540 "vfc_get_video_ioctl\n",
541 dev->instance));
542 return ret;
544 return ret;
547 static int vfc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
548 unsigned long arg)
550 int ret = 0;
551 unsigned int tmp;
552 struct vfc_dev *dev;
553 void __user *argp = (void __user *)arg;
555 dev = vfc_get_dev_ptr(iminor(inode));
556 if(dev == NULL)
557 return -ENODEV;
559 switch(cmd & 0x0000ffff) {
560 case VFCGCTRL:
561 #if 0
562 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCGCTRL)\n", dev->instance));
563 #endif
564 tmp = sbus_readl(&dev->regs->control);
565 if(copy_to_user(argp, &tmp, sizeof(unsigned int))) {
566 ret = -EFAULT;
567 break;
569 ret = 0;
570 break;
571 case VFCSCTRL:
572 ret = vfc_set_control_ioctl(inode, file, dev, arg);
573 break;
574 case VFCGVID:
575 ret = vfc_get_video_ioctl(inode, file, dev, arg);
576 break;
577 case VFCSVID:
578 ret = vfc_set_video_ioctl(inode, file, dev, arg);
579 break;
580 case VFCHUE:
581 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCHUE)\n", dev->instance));
582 if(copy_from_user(&tmp,argp,sizeof(unsigned int))) {
583 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer "
584 "to IOCTL(VFCHUE)", dev->instance));
585 ret = -EFAULT;
586 } else {
587 VFC_SAA9051_SA(dev,VFC_SAA9051_HUE) = tmp;
588 vfc_update_saa9051(dev);
589 ret = 0;
591 break;
592 case VFCPORTCHG:
593 ret = vfc_port_change_ioctl(inode, file, dev, arg);
594 break;
595 case VFCRDINFO:
596 ret = -EINVAL;
597 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCRDINFO)\n", dev->instance));
598 break;
599 default:
600 ret = vfc_debug(vfc_get_dev_ptr(iminor(inode)), cmd, argp);
601 break;
604 return ret;
607 static int vfc_mmap(struct file *file, struct vm_area_struct *vma)
609 unsigned int map_size, ret, map_offset;
610 struct vfc_dev *dev;
612 dev = vfc_get_dev_ptr(iminor(file->f_path.dentry->d_inode));
613 if(dev == NULL)
614 return -ENODEV;
616 map_size = vma->vm_end - vma->vm_start;
617 if(map_size > sizeof(struct vfc_regs))
618 map_size = sizeof(struct vfc_regs);
620 vma->vm_flags |=
621 (VM_MAYREAD | VM_MAYWRITE | VM_MAYSHARE);
622 map_offset = (unsigned int) (long)dev->phys_regs;
623 ret = io_remap_pfn_range(vma, vma->vm_start,
624 MK_IOSPACE_PFN(dev->which_io,
625 map_offset >> PAGE_SHIFT),
626 map_size, vma->vm_page_prot);
628 if(ret)
629 return -EAGAIN;
631 return 0;
635 static const struct file_operations vfc_fops = {
636 .owner = THIS_MODULE,
637 .llseek = no_llseek,
638 .ioctl = vfc_ioctl,
639 .mmap = vfc_mmap,
640 .open = vfc_open,
641 .release = vfc_release,
644 static int vfc_probe(void)
646 struct sbus_bus *sbus;
647 struct sbus_dev *sdev = NULL;
648 int ret;
649 int instance = 0, cards = 0;
651 for_all_sbusdev(sdev, sbus) {
652 if (strcmp(sdev->prom_name, "vfc") == 0) {
653 cards++;
654 continue;
658 if (!cards)
659 return -ENODEV;
661 vfc_dev_lst = kcalloc(cards + 1, sizeof(struct vfc_dev*), GFP_KERNEL);
662 if (vfc_dev_lst == NULL)
663 return -ENOMEM;
664 vfc_dev_lst[cards] = NULL;
666 ret = register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops);
667 if(ret) {
668 printk(KERN_ERR "Unable to get major number %d\n", VFC_MAJOR);
669 kfree(vfc_dev_lst);
670 return -EIO;
672 instance = 0;
673 for_all_sbusdev(sdev, sbus) {
674 if (strcmp(sdev->prom_name, "vfc") == 0) {
675 vfc_dev_lst[instance]=(struct vfc_dev *)
676 kmalloc(sizeof(struct vfc_dev), GFP_KERNEL);
677 if (vfc_dev_lst[instance] == NULL)
678 return -ENOMEM;
679 ret = init_vfc_device(sdev,
680 vfc_dev_lst[instance],
681 instance);
682 if(ret) {
683 printk(KERN_ERR "Unable to initialize"
684 " vfc%d device\n",
685 instance);
686 } else {
689 instance++;
690 continue;
694 return 0;
697 #ifdef MODULE
698 int init_module(void)
699 #else
700 int vfc_init(void)
701 #endif
703 return vfc_probe();
706 #ifdef MODULE
707 static void deinit_vfc_device(struct vfc_dev *dev)
709 if(dev == NULL)
710 return;
711 sbus_iounmap(dev->regs, sizeof(struct vfc_regs));
712 kfree(dev);
715 void cleanup_module(void)
717 struct vfc_dev **devp;
719 unregister_chrdev(VFC_MAJOR,vfcstr);
721 for (devp = vfc_dev_lst; *devp; devp++)
722 deinit_vfc_device(*devp);
724 kfree(vfc_dev_lst);
725 return;
727 #endif
729 MODULE_LICENSE("GPL");