[WATCHDOG] mpc83xx_wdt: convert to the OF platform driver
[linux-2.6/linux-2.6-openrd.git] / drivers / sbus / char / vfc_dev.c
blob25181bb7d627752de1d4f6932f96d8d4ec2bbb8e
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>
27 #include <linux/smp_lock.h>
29 #include <asm/openprom.h>
30 #include <asm/oplib.h>
31 #include <asm/io.h>
32 #include <asm/system.h>
33 #include <asm/sbus.h>
34 #include <asm/page.h>
35 #include <asm/pgtable.h>
36 #include <asm/uaccess.h>
38 #define VFC_MAJOR (60)
40 #if 0
41 #define VFC_IOCTL_DEBUG
42 #endif
44 #include "vfc.h"
45 #include <asm/vfc_ioctls.h>
47 static const struct file_operations vfc_fops;
48 static struct vfc_dev **vfc_dev_lst;
49 static char vfcstr[]="vfc";
50 static unsigned char saa9051_init_array[VFC_SAA9051_NR] = {
51 0x00, 0x64, 0x72, 0x52,
52 0x36, 0x18, 0xff, 0x20,
53 0xfc, 0x77, 0xe3, 0x50,
54 0x3e
57 static void vfc_lock_device(struct vfc_dev *dev)
59 mutex_lock(&dev->device_lock_mtx);
62 static void vfc_unlock_device(struct vfc_dev *dev)
64 mutex_unlock(&dev->device_lock_mtx);
68 static void vfc_captstat_reset(struct vfc_dev *dev)
70 dev->control_reg |= VFC_CONTROL_CAPTRESET;
71 sbus_writel(dev->control_reg, &dev->regs->control);
72 dev->control_reg &= ~VFC_CONTROL_CAPTRESET;
73 sbus_writel(dev->control_reg, &dev->regs->control);
74 dev->control_reg |= VFC_CONTROL_CAPTRESET;
75 sbus_writel(dev->control_reg, &dev->regs->control);
78 static void vfc_memptr_reset(struct vfc_dev *dev)
80 dev->control_reg |= VFC_CONTROL_MEMPTR;
81 sbus_writel(dev->control_reg, &dev->regs->control);
82 dev->control_reg &= ~VFC_CONTROL_MEMPTR;
83 sbus_writel(dev->control_reg, &dev->regs->control);
84 dev->control_reg |= VFC_CONTROL_MEMPTR;
85 sbus_writel(dev->control_reg, &dev->regs->control);
88 static int vfc_csr_init(struct vfc_dev *dev)
90 dev->control_reg = 0x80000000;
91 sbus_writel(dev->control_reg, &dev->regs->control);
92 udelay(200);
93 dev->control_reg &= ~0x80000000;
94 sbus_writel(dev->control_reg, &dev->regs->control);
95 udelay(100);
96 sbus_writel(0x0f000000, &dev->regs->i2c_magic2);
98 vfc_memptr_reset(dev);
100 dev->control_reg &= ~VFC_CONTROL_DIAGMODE;
101 dev->control_reg &= ~VFC_CONTROL_CAPTURE;
102 dev->control_reg |= 0x40000000;
103 sbus_writel(dev->control_reg, &dev->regs->control);
105 vfc_captstat_reset(dev);
107 return 0;
110 static int vfc_saa9051_init(struct vfc_dev *dev)
112 int i;
114 for (i = 0; i < VFC_SAA9051_NR; i++)
115 dev->saa9051_state_array[i] = saa9051_init_array[i];
117 vfc_i2c_sendbuf(dev,VFC_SAA9051_ADDR,
118 dev->saa9051_state_array, VFC_SAA9051_NR);
119 return 0;
122 static int init_vfc_hw(struct vfc_dev *dev)
124 vfc_lock_device(dev);
125 vfc_csr_init(dev);
127 vfc_pcf8584_init(dev);
128 vfc_init_i2c_bus(dev); /* hopefully this doesn't undo the magic
129 sun code above*/
130 vfc_saa9051_init(dev);
131 vfc_unlock_device(dev);
132 return 0;
135 static int init_vfc_devstruct(struct vfc_dev *dev, int instance)
137 dev->instance=instance;
138 mutex_init(&dev->device_lock_mtx);
139 dev->control_reg=0;
140 dev->busy=0;
141 return 0;
144 static int init_vfc_device(struct sbus_dev *sdev,struct vfc_dev *dev,
145 int instance)
147 if(dev == NULL) {
148 printk(KERN_ERR "VFC: Bogus pointer passed\n");
149 return -ENOMEM;
151 printk("Initializing vfc%d\n",instance);
152 dev->regs = NULL;
153 dev->regs = (volatile struct vfc_regs __iomem *)
154 sbus_ioremap(&sdev->resource[0], 0,
155 sizeof(struct vfc_regs), vfcstr);
156 dev->which_io = sdev->reg_addrs[0].which_io;
157 dev->phys_regs = (struct vfc_regs *) sdev->reg_addrs[0].phys_addr;
158 if (dev->regs == NULL)
159 return -EIO;
161 printk("vfc%d: registers mapped at phys_addr: 0x%lx\n virt_addr: 0x%lx\n",
162 instance,(unsigned long)sdev->reg_addrs[0].phys_addr,(unsigned long)dev->regs);
164 if (init_vfc_devstruct(dev, instance))
165 return -EINVAL;
166 if (init_vfc_hw(dev))
167 return -EIO;
168 return 0;
172 static struct vfc_dev *vfc_get_dev_ptr(int instance)
174 return vfc_dev_lst[instance];
177 static DEFINE_SPINLOCK(vfc_dev_lock);
179 static int vfc_open(struct inode *inode, struct file *file)
181 struct vfc_dev *dev;
183 lock_kernel();
184 spin_lock(&vfc_dev_lock);
185 dev = vfc_get_dev_ptr(iminor(inode));
186 if (dev == NULL) {
187 spin_unlock(&vfc_dev_lock);
188 unlock_kernel();
189 return -ENODEV;
191 if (dev->busy) {
192 spin_unlock(&vfc_dev_lock);
193 unlock_kernel();
194 return -EBUSY;
197 dev->busy = 1;
198 spin_unlock(&vfc_dev_lock);
200 vfc_lock_device(dev);
202 vfc_csr_init(dev);
203 vfc_pcf8584_init(dev);
204 vfc_init_i2c_bus(dev);
205 vfc_saa9051_init(dev);
206 vfc_memptr_reset(dev);
207 vfc_captstat_reset(dev);
209 vfc_unlock_device(dev);
210 unlock_kernel();
211 return 0;
214 static int vfc_release(struct inode *inode,struct file *file)
216 struct vfc_dev *dev;
218 spin_lock(&vfc_dev_lock);
219 dev = vfc_get_dev_ptr(iminor(inode));
220 if (!dev || !dev->busy) {
221 spin_unlock(&vfc_dev_lock);
222 return -EINVAL;
224 dev->busy = 0;
225 spin_unlock(&vfc_dev_lock);
226 return 0;
229 static int vfc_debug(struct vfc_dev *dev, int cmd, void __user *argp)
231 struct vfc_debug_inout inout;
232 unsigned char *buffer;
234 if (!capable(CAP_SYS_ADMIN))
235 return -EPERM;
237 switch(cmd) {
238 case VFC_I2C_SEND:
239 if(copy_from_user(&inout, argp, sizeof(inout)))
240 return -EFAULT;
242 buffer = kmalloc(inout.len, GFP_KERNEL);
243 if (buffer == NULL)
244 return -ENOMEM;
246 if(copy_from_user(buffer, inout.buffer, inout.len)) {
247 kfree(buffer);
248 return -EFAULT;
252 vfc_lock_device(dev);
253 inout.ret=
254 vfc_i2c_sendbuf(dev,inout.addr & 0xff,
255 buffer,inout.len);
257 if (copy_to_user(argp,&inout,sizeof(inout))) {
258 vfc_unlock_device(dev);
259 kfree(buffer);
260 return -EFAULT;
262 vfc_unlock_device(dev);
264 break;
265 case VFC_I2C_RECV:
266 if (copy_from_user(&inout, argp, sizeof(inout)))
267 return -EFAULT;
269 buffer = kzalloc(inout.len, GFP_KERNEL);
270 if (buffer == NULL)
271 return -ENOMEM;
273 vfc_lock_device(dev);
274 inout.ret=
275 vfc_i2c_recvbuf(dev,inout.addr & 0xff
276 ,buffer,inout.len);
277 vfc_unlock_device(dev);
279 if (copy_to_user(inout.buffer, buffer, inout.len)) {
280 kfree(buffer);
281 return -EFAULT;
283 if (copy_to_user(argp,&inout,sizeof(inout))) {
284 kfree(buffer);
285 return -EFAULT;
287 kfree(buffer);
288 break;
289 default:
290 return -EINVAL;
293 return 0;
296 static int vfc_capture_start(struct vfc_dev *dev)
298 vfc_captstat_reset(dev);
299 dev->control_reg = sbus_readl(&dev->regs->control);
300 if((dev->control_reg & VFC_STATUS_CAPTURE)) {
301 printk(KERN_ERR "vfc%d: vfc capture status not reset\n",
302 dev->instance);
303 return -EIO;
306 vfc_lock_device(dev);
307 dev->control_reg &= ~VFC_CONTROL_CAPTURE;
308 sbus_writel(dev->control_reg, &dev->regs->control);
309 dev->control_reg |= VFC_CONTROL_CAPTURE;
310 sbus_writel(dev->control_reg, &dev->regs->control);
311 dev->control_reg &= ~VFC_CONTROL_CAPTURE;
312 sbus_writel(dev->control_reg, &dev->regs->control);
313 vfc_unlock_device(dev);
315 return 0;
318 static int vfc_capture_poll(struct vfc_dev *dev)
320 int timeout = 1000;
322 while (!timeout--) {
323 if (sbus_readl(&dev->regs->control) & VFC_STATUS_CAPTURE)
324 break;
325 vfc_i2c_delay_no_busy(dev, 100);
327 if(!timeout) {
328 printk(KERN_WARNING "vfc%d: capture timed out\n",
329 dev->instance);
330 return -ETIMEDOUT;
332 return 0;
337 static int vfc_set_control_ioctl(struct inode *inode, struct file *file,
338 struct vfc_dev *dev, unsigned long arg)
340 int setcmd, ret = 0;
342 if (copy_from_user(&setcmd,(void __user *)arg,sizeof(unsigned int)))
343 return -EFAULT;
345 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCSCTRL) arg=0x%x\n",
346 dev->instance,setcmd));
348 switch(setcmd) {
349 case MEMPRST:
350 vfc_lock_device(dev);
351 vfc_memptr_reset(dev);
352 vfc_unlock_device(dev);
353 ret=0;
354 break;
355 case CAPTRCMD:
356 vfc_capture_start(dev);
357 vfc_capture_poll(dev);
358 break;
359 case DIAGMODE:
360 if(capable(CAP_SYS_ADMIN)) {
361 vfc_lock_device(dev);
362 dev->control_reg |= VFC_CONTROL_DIAGMODE;
363 sbus_writel(dev->control_reg, &dev->regs->control);
364 vfc_unlock_device(dev);
365 ret = 0;
366 } else {
367 ret = -EPERM;
369 break;
370 case NORMMODE:
371 vfc_lock_device(dev);
372 dev->control_reg &= ~VFC_CONTROL_DIAGMODE;
373 sbus_writel(dev->control_reg, &dev->regs->control);
374 vfc_unlock_device(dev);
375 ret = 0;
376 break;
377 case CAPTRSTR:
378 vfc_capture_start(dev);
379 ret = 0;
380 break;
381 case CAPTRWAIT:
382 vfc_capture_poll(dev);
383 ret = 0;
384 break;
385 default:
386 ret = -EINVAL;
387 break;
390 return ret;
394 static int vfc_port_change_ioctl(struct inode *inode, struct file *file,
395 struct vfc_dev *dev, unsigned long arg)
397 int ret = 0;
398 int cmd;
400 if(copy_from_user(&cmd, (void __user *)arg, sizeof(unsigned int))) {
401 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer to "
402 "vfc_port_change_ioctl\n",
403 dev->instance));
404 return -EFAULT;
407 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCPORTCHG) arg=0x%x\n",
408 dev->instance, cmd));
410 switch(cmd) {
411 case 1:
412 case 2:
413 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_START) = 0x72;
414 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_STOP) = 0x52;
415 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_START) = 0x36;
416 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_STOP) = 0x18;
417 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) = VFC_SAA9051_BP2;
418 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) = VFC_SAA9051_CT | VFC_SAA9051_SS3;
419 VFC_SAA9051_SA(dev,VFC_SAA9051_SECAM_DELAY) = 0x3e;
420 break;
421 case 3:
422 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_START) = 0x3a;
423 VFC_SAA9051_SA(dev,VFC_SAA9051_HSY_STOP) = 0x17;
424 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_START) = 0xfa;
425 VFC_SAA9051_SA(dev,VFC_SAA9051_HC_STOP) = 0xde;
426 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) =
427 VFC_SAA9051_BY | VFC_SAA9051_PF | VFC_SAA9051_BP2;
428 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) = VFC_SAA9051_YC;
429 VFC_SAA9051_SA(dev,VFC_SAA9051_SECAM_DELAY) = 0;
430 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) &=
431 ~(VFC_SAA9051_SS0 | VFC_SAA9051_SS1);
432 break;
433 default:
434 ret = -EINVAL;
435 return ret;
436 break;
439 switch(cmd) {
440 case 1:
441 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) |=
442 (VFC_SAA9051_SS0 | VFC_SAA9051_SS1);
443 break;
444 case 2:
445 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) &=
446 ~(VFC_SAA9051_SS0 | VFC_SAA9051_SS1);
447 VFC_SAA9051_SA(dev,VFC_SAA9051_C2) |= VFC_SAA9051_SS0;
448 break;
449 case 3:
450 break;
451 default:
452 ret = -EINVAL;
453 return ret;
454 break;
456 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) &= ~(VFC_SAA9051_SS2);
457 ret=vfc_update_saa9051(dev);
458 udelay(500);
459 VFC_SAA9051_SA(dev,VFC_SAA9051_C3) |= (VFC_SAA9051_SS2);
460 ret=vfc_update_saa9051(dev);
461 return ret;
464 static int vfc_set_video_ioctl(struct inode *inode, struct file *file,
465 struct vfc_dev *dev, unsigned long arg)
467 int ret = 0;
468 int cmd;
470 if(copy_from_user(&cmd, (void __user *)arg, sizeof(unsigned int))) {
471 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer to "
472 "vfc_set_video_ioctl\n",
473 dev->instance));
474 return ret;
477 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCSVID) arg=0x%x\n",
478 dev->instance, cmd));
479 switch(cmd) {
480 case STD_NTSC:
481 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~VFC_SAA9051_ALT;
482 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_YPN |
483 VFC_SAA9051_CCFR0 | VFC_SAA9051_CCFR1 | VFC_SAA9051_FS;
484 ret = vfc_update_saa9051(dev);
485 break;
486 case STD_PAL:
487 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~(VFC_SAA9051_YPN |
488 VFC_SAA9051_CCFR1 |
489 VFC_SAA9051_CCFR0 |
490 VFC_SAA9051_FS);
491 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) |= VFC_SAA9051_ALT;
492 ret = vfc_update_saa9051(dev);
493 break;
495 case COLOR_ON:
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 case MONO:
502 VFC_SAA9051_SA(dev,VFC_SAA9051_C1) &= ~(VFC_SAA9051_CO);
503 VFC_SAA9051_SA(dev,VFC_SAA9051_HORIZ_PEAK) |=
504 (VFC_SAA9051_BY | VFC_SAA9051_PF);
505 ret = vfc_update_saa9051(dev);
506 break;
507 default:
508 ret = -EINVAL;
509 break;
512 return ret;
515 static int vfc_get_video_ioctl(struct inode *inode, struct file *file,
516 struct vfc_dev *dev, unsigned long arg)
518 int ret = 0;
519 unsigned int status = NO_LOCK;
520 unsigned char buf[1];
522 if(vfc_i2c_recvbuf(dev, VFC_SAA9051_ADDR, buf, 1)) {
523 printk(KERN_ERR "vfc%d: Unable to get status\n",
524 dev->instance);
525 return -EIO;
528 if(buf[0] & VFC_SAA9051_HLOCK) {
529 status = NO_LOCK;
530 } else if(buf[0] & VFC_SAA9051_FD) {
531 if(buf[0] & VFC_SAA9051_CD)
532 status = NTSC_COLOR;
533 else
534 status = NTSC_NOCOLOR;
535 } else {
536 if(buf[0] & VFC_SAA9051_CD)
537 status = PAL_COLOR;
538 else
539 status = PAL_NOCOLOR;
541 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCGVID) returning status 0x%x; "
542 "buf[0]=%x\n", dev->instance, status, buf[0]));
544 if (copy_to_user((void __user *)arg,&status,sizeof(unsigned int))) {
545 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer to "
546 "vfc_get_video_ioctl\n",
547 dev->instance));
548 return ret;
550 return ret;
553 static int vfc_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
554 unsigned long arg)
556 int ret = 0;
557 unsigned int tmp;
558 struct vfc_dev *dev;
559 void __user *argp = (void __user *)arg;
561 dev = vfc_get_dev_ptr(iminor(inode));
562 if(dev == NULL)
563 return -ENODEV;
565 switch(cmd & 0x0000ffff) {
566 case VFCGCTRL:
567 #if 0
568 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCGCTRL)\n", dev->instance));
569 #endif
570 tmp = sbus_readl(&dev->regs->control);
571 if(copy_to_user(argp, &tmp, sizeof(unsigned int))) {
572 ret = -EFAULT;
573 break;
575 ret = 0;
576 break;
577 case VFCSCTRL:
578 ret = vfc_set_control_ioctl(inode, file, dev, arg);
579 break;
580 case VFCGVID:
581 ret = vfc_get_video_ioctl(inode, file, dev, arg);
582 break;
583 case VFCSVID:
584 ret = vfc_set_video_ioctl(inode, file, dev, arg);
585 break;
586 case VFCHUE:
587 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCHUE)\n", dev->instance));
588 if(copy_from_user(&tmp,argp,sizeof(unsigned int))) {
589 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: User passed bogus pointer "
590 "to IOCTL(VFCHUE)", dev->instance));
591 ret = -EFAULT;
592 } else {
593 VFC_SAA9051_SA(dev,VFC_SAA9051_HUE) = tmp;
594 vfc_update_saa9051(dev);
595 ret = 0;
597 break;
598 case VFCPORTCHG:
599 ret = vfc_port_change_ioctl(inode, file, dev, arg);
600 break;
601 case VFCRDINFO:
602 ret = -EINVAL;
603 VFC_IOCTL_DEBUG_PRINTK(("vfc%d: IOCTL(VFCRDINFO)\n", dev->instance));
604 break;
605 default:
606 ret = vfc_debug(vfc_get_dev_ptr(iminor(inode)), cmd, argp);
607 break;
610 return ret;
613 static int vfc_mmap(struct file *file, struct vm_area_struct *vma)
615 unsigned int map_size, ret, map_offset;
616 struct vfc_dev *dev;
618 dev = vfc_get_dev_ptr(iminor(file->f_path.dentry->d_inode));
619 if(dev == NULL)
620 return -ENODEV;
622 map_size = vma->vm_end - vma->vm_start;
623 if(map_size > sizeof(struct vfc_regs))
624 map_size = sizeof(struct vfc_regs);
626 vma->vm_flags |=
627 (VM_MAYREAD | VM_MAYWRITE | VM_MAYSHARE);
628 map_offset = (unsigned int) (long)dev->phys_regs;
629 ret = io_remap_pfn_range(vma, vma->vm_start,
630 MK_IOSPACE_PFN(dev->which_io,
631 map_offset >> PAGE_SHIFT),
632 map_size, vma->vm_page_prot);
634 if(ret)
635 return -EAGAIN;
637 return 0;
641 static const struct file_operations vfc_fops = {
642 .owner = THIS_MODULE,
643 .llseek = no_llseek,
644 .ioctl = vfc_ioctl,
645 .mmap = vfc_mmap,
646 .open = vfc_open,
647 .release = vfc_release,
650 static int vfc_probe(void)
652 struct sbus_bus *sbus;
653 struct sbus_dev *sdev = NULL;
654 int ret;
655 int instance = 0, cards = 0;
657 for_all_sbusdev(sdev, sbus) {
658 if (strcmp(sdev->prom_name, "vfc") == 0) {
659 cards++;
660 continue;
664 if (!cards)
665 return -ENODEV;
667 vfc_dev_lst = kcalloc(cards + 1, sizeof(struct vfc_dev*), GFP_KERNEL);
668 if (vfc_dev_lst == NULL)
669 return -ENOMEM;
670 vfc_dev_lst[cards] = NULL;
672 ret = register_chrdev(VFC_MAJOR, vfcstr, &vfc_fops);
673 if(ret) {
674 printk(KERN_ERR "Unable to get major number %d\n", VFC_MAJOR);
675 kfree(vfc_dev_lst);
676 return -EIO;
678 instance = 0;
679 for_all_sbusdev(sdev, sbus) {
680 if (strcmp(sdev->prom_name, "vfc") == 0) {
681 vfc_dev_lst[instance]=(struct vfc_dev *)
682 kmalloc(sizeof(struct vfc_dev), GFP_KERNEL);
683 if (vfc_dev_lst[instance] == NULL)
684 return -ENOMEM;
685 ret = init_vfc_device(sdev,
686 vfc_dev_lst[instance],
687 instance);
688 if(ret) {
689 printk(KERN_ERR "Unable to initialize"
690 " vfc%d device\n",
691 instance);
692 } else {
695 instance++;
696 continue;
700 return 0;
703 #ifdef MODULE
704 int init_module(void)
705 #else
706 int vfc_init(void)
707 #endif
709 return vfc_probe();
712 #ifdef MODULE
713 static void deinit_vfc_device(struct vfc_dev *dev)
715 if(dev == NULL)
716 return;
717 sbus_iounmap(dev->regs, sizeof(struct vfc_regs));
718 kfree(dev);
721 void cleanup_module(void)
723 struct vfc_dev **devp;
725 unregister_chrdev(VFC_MAJOR,vfcstr);
727 for (devp = vfc_dev_lst; *devp; devp++)
728 deinit_vfc_device(*devp);
730 kfree(vfc_dev_lst);
731 return;
733 #endif
735 MODULE_LICENSE("GPL");