/*
 * linux/kernel/drivers/char/mouse.c
 *
 * Generic mouse open routine by Johan Myreen
 *
 * Based on code from Linus
 *
 * Teemu Rantanen's Microsoft Busmouse support and Derrick Cole's
 *   changes incorporated into 0.97pl4
 *   by Peter Cervasio (pete%q106fm.uucp@wupost.wustl.edu) (08SEP92)
 *   See busmouse.c for particulars.
 *
 * Made things a lot mode modular - easy to compile in just one or two
 * of the mouse drivers, as they are now completely independent. Linus.
 *
 * Amiga mouse support by Michael Rausch
 *
 */

#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/mouse.h>
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/major.h>

/*
 * note that you can remove any or all of the drivers by undefining
 * the minor values in <linux/mouse.h>
 */
extern struct file_operations amiga_mouse_fops;

extern unsigned long amiga_mouse_init(unsigned long);

static int mouse_open(struct inode * inode, struct file * file)
{
	int minor = MINOR(inode->i_rdev);

	switch (minor) {
#ifdef CONFIG_AMIGAMOUSE
		case AMIGAMOUSE_MINOR:
	                file->f_op = &amiga_mouse_fops;
	                break;
#endif
		default:
			return -ENODEV;
	}
        return file->f_op->open(inode,file);
}

static struct file_operations mouse_fops = {
        NULL,		/* seek */
	NULL,		/* read */
	NULL,		/* write */
	NULL,		/* readdir */
	NULL,		/* select */
	NULL,		/* ioctl */
	NULL,		/* mmap */
        mouse_open,
        NULL		/* release */
};

unsigned long mouse_init(unsigned long kmem_start)
{
#ifdef CONFIG_AMIGAMOUSE
	kmem_start = amiga_mouse_init(kmem_start);
#endif
	if (register_chrdev(MOUSE_MAJOR,"mouse",&mouse_fops))
		printk("unable to get major %d for mouse devices\n",
		       MOUSE_MAJOR);
	return kmem_start;
}
