#include <linux/init.h>
#include <linux/config.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <asm/uaccess.h>

#include <linux/types.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/errno.h>
#include <asm/segment.h>


static int open_myzero(struct inode *zinode, struct file *zfile) {
	printk(KERN_ALERT "device myzero is open\n");
	return 0;
}

static int release_myzero(struct inode *zinode, struct file *zfile) {
	printk(KERN_ALERT "device myzero is closed\n");
	return 0;
}

static struct file_operations myzero_fops = {
  .open = open_myzero,
  .release = release_myzero,
};

int init_myzero(void)
{
  int status;
  printk(KERN_ALERT "Module Initialized: myzero\n");
  if((status = register_chrdev(66, "myzero", &myzero_fops)) < 0) {
    printk(KERN_ALERT "unable to get major for myzero device: 66 \n");
  }
  return 0;
}

void cleanup_myzero(void)
{
  int status;
  printk(KERN_ALERT "Module Cleanup called: myzero\n"); 
  if(( status = unregister_chrdev(66, "myzero")) < 0) {
    printk(KERN_ALERT "unable to get major for myzero device: %u\n",66);
  }
}

module_init(init_myzero);
module_exit(cleanup_myzero);
