/*
 * skeldev.c
 *
 * Basic device driver implementation. This driver creates the
 * /dev/skeldev entry. None of the file operations is implemented (OS
 * default actions apply).
 *
 * REQUIREMENTS
 *
 * The Device File System (devfs), Linux Kernel 2.4.x.
 *
 * COMPILE/LOAD/UNLOAD
 *
 * To compile the device:
 *
 *   $ gcc -D MODULE -D __KERNEL__ -c skeldev.c
 *
 * To load the device:
 *
 *   $ sudo /sbin/insmod skeldev.o
 *
 * To unload the device:
 *
 *   $ sudo /sbin/rmmod skeldev
 *
 * AUTHOR
 *
 * Emanuele Altieri
 * ealtieri@hampshire.edu
 * June 2002
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/version.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/uaccess.h>

/* Check  if the Device File System (experimental) is installed */
#ifndef CONFIG_DEVFS_FS
# error "This module requires the Device File System (devfs)"
#endif

/* MODULE CONFIGURATION */

MODULE_AUTHOR("Emanuele Altieri");
MODULE_DESCRIPTION("Basic Device Driver");
MODULE_LICENSE("GPL");

static devfs_handle_t skel_handle;    /* handle for the device     */
static char* skel_name = "skeldev";   /* create /dev/skeldev entry */

static struct file_operations skel_fops = { /* NULL (default actions) */ };

/* Module Initialization */
static int __init skel_init(void)
{
	/* register the module */
	SET_MODULE_OWNER(&skel_fops);
	skel_handle = devfs_register
		(
		 NULL,                      /* parent dir in /dev (none)     */
		 skel_name,                 /* /dev entry name (skeldev)     */
		 DEVFS_FL_AUTO_DEVNUM |     /* automatic major/minor numbers */
		 DEVFS_FL_AUTO_OWNER,
		 0, 0,                      /* major/minor (not used)        */
		 S_IFCHR,                   /* character device              */
		 &skel_fops,                /* file ops handlers             */
		 NULL                       /* other                         */
		 );
	if (skel_handle <= 0)
		return(-EBUSY);

	return(0);
} /* skel_init() */

/* Module deconstructor */
static void __exit skel_exit(void)
{
	devfs_unregister(skel_handle);
} /* skel_exit() */

/* Specify init and exit functions */
module_init(skel_init);
module_exit(skel_exit);
