diff --git a/mod_hello.c b/mod_hello.c index ff5f356..a4dc60e 100644 --- a/mod_hello.c +++ b/mod_hello.c @@ -25,13 +25,29 @@ hello_control_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return 0; } +static int +hello_control_open (struct inode *inode, struct file *filp) +{ + return 0; +} + +static ssize_t +hello_control_read (struct file *filp, char __user *buf, size_t size, loff_t *offp) +{ + int ret = 0; + return ret; +} + static const struct file_operations hello_ctl_fops = { .unlocked_ioctl = hello_control_ioctl, .compat_ioctl = hello_control_ioctl, .owner = THIS_MODULE, .llseek = noop_llseek, + .open = hello_control_open, + .read = hello_control_read, }; + static struct miscdevice hello_misc = { .minor = MISC_DYNAMIC_MINOR, .name = "helloctl", @@ -114,9 +130,7 @@ static int __init hello_init(void) static void __exit hello_cleanup(void) { - if (misc_deregister(&hello_misc) < 0) { - printk(KERN_INFO "[%s] misc_deregister failed for control device.\n", __this_module.name); - } + misc_deregister(&hello_misc); printk(KERN_INFO "[%s] module unloaded.\n", __this_module.name); }