1
0
mirror of https://github.com/ioacademy-jikim/device_driver synced 2025-06-07 07:56:08 +00:00
ioacademy-jikim e92d98c6d0 first sample
2015-08-19 19:26:23 +09:00

37 lines
555 B
C

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
int my_open (struct inode *inode, struct file *filp)
{
printk("my_open()\n");
return 0;
}
int my_close(struct inode *inode, struct file *filp)
{
printk("my_close()\n");
return 0;
}
static struct file_operations fops =
{
.open = my_open,
.release = my_close,
};
int my_init(void)
{
register_chrdev(200, "mydev", &fops );
return 0;
}
void my_exit(void)
{
unregister_chrdev( 200, "mydev" );
}
MODULE_LICENSE("GPL");
module_init( my_init );
module_exit( my_exit );