proper cleanup
This commit is contained in:
parent
cf4111b64d
commit
232cd71f5d
1 changed files with 11 additions and 1 deletions
12
code/lkm.c
12
code/lkm.c
|
@ -28,8 +28,8 @@ static struct file_operations lkm_fops = {
|
||||||
static int
|
static int
|
||||||
lkm_init(void)
|
lkm_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
|
||||||
printk(KERN_INFO "lkm: init: start\n");
|
printk(KERN_INFO "lkm: init: start\n");
|
||||||
|
int ret;
|
||||||
|
|
||||||
ret = register_chrdev(0, DEVICE_NAME, &lkm_fops);
|
ret = register_chrdev(0, DEVICE_NAME, &lkm_fops);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -69,12 +69,20 @@ static void
|
||||||
lkm_exit(void)
|
lkm_exit(void)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "lkm: exit: start\n");
|
printk(KERN_INFO "lkm: exit: start\n");
|
||||||
|
|
||||||
|
device_destroy(lkm_class, MKDEV(lkm_major, 0));
|
||||||
|
class_unregister(lkm_class);
|
||||||
|
unregister_chrdev(lkm_major, DEVICE_NAME);
|
||||||
|
|
||||||
|
printk(KERN_INFO "lkm: exit: done\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
lkm_open(struct inode *inode, struct file *fp)
|
lkm_open(struct inode *inode, struct file *fp)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "lkm: open: start\n");
|
printk(KERN_INFO "lkm: open: start\n");
|
||||||
|
|
||||||
|
printk(KERN_INFO "lkm: open: done\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +90,7 @@ int
|
||||||
lkm_release(struct inode *inode, struct file *fp)
|
lkm_release(struct inode *inode, struct file *fp)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "lkm: release: start\n");
|
printk(KERN_INFO "lkm: release: start\n");
|
||||||
|
printk(KERN_INFO "lkm: release: done\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +98,7 @@ long
|
||||||
lkm_ioctl(struct file *fp, unsigned num, long unsigned int param)
|
lkm_ioctl(struct file *fp, unsigned num, long unsigned int param)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "lkm: release: start\n");
|
printk(KERN_INFO "lkm: release: start\n");
|
||||||
|
printk(KERN_INFO "lkm: release: done\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue