NULL, /* readdir */
NULL, /* select */
NULL, /* ioctl */
NULL, /* mmap */
device_open,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
NULL, /* flush */
#endif
device_release /* a.k.a. close */
};
/* Initialize the module - Register the character device */
int init_module() {
/* Register the character device (atleast try) */
Major = module_register_chrdev(0, DEVICE_NAME, &Fops);
/* Negative values signify an error */
if (Major < 0) {
printk("%s device failed with %d\n", "Sorry, registering the character", Major);
return Major;
}
printk("%s The major device number is %d.\n", "Registeration is a success.", Major);
printk("If you want to talk to the device driver,\n");
printk("you'll have to create a device file. \n");
printk("We suggest you use:\n");
printk("mknod <name> c %d <minor>\n", Major);
printk("You can try different minor numbers %s", "and see what happens.\n");
return 0;
}
/* Cleanup - unregister the appropriate file from /proc */
void cleanup_module() {
int ret;