cdev_del — remove a cdev from the system Synopsis void fsfunc cdev_del( struct cdev * p); Arguments p : the cdev structure to be removed Description cdev_del removes p from the system, possibly freeing the structure itself. void cdev_del(struct cdev *p) { cdev_unmap(p->dev, p->co...
cdev_init(&cdev,&hello_ops); error = cdev_add(&cdev,devno,1); if(error <0) { printk("cdev_add fail \n"); unregister_chrdev_region(devno,1); returnerror; } return0; } staticvoidhello_exit(void) { printk("hello_exit \n"); cdev_del(cdev); unregister_chrdev_region(devno,1);...
* cdev_init() - initialize a cdev structure * @cdev: the structure to initialize * @fops: the file_operations for this device * * Initializes @cdev, remembering @fops, making it ready to add to the * system with cdev_add(). */voidcdev_init(structcdev *cdev,conststructfile_operations...
}cdev_init(&bpamem_cdev, &bpamem_devops); bpamem_cdev.owner = THIS_MODULE; bpamem_cdev.ops = &bpamem_devops;if(cdev_add(&bpamem_cdev, MKDEV(BPAMEM_MAJOR,0), MAX_BPA_ALLOCS) <0) { printk("BPAMem couldn't register '%s' driver\n", DEVICE_NAME);return-1; } bpamem_class =...
("register_chrdev_region fail \n");returnresult;}cdev_init(&cdev,&hello_ops);error = cdev_add(&cdev,devno,1);if(error < 0){printk("cdev_add fail \n");unregister_chrdev_region(devno,1);returnerror;}return0;}staticvoid hello_exit(void){printk("hello_exit \n");cdev_del(cdev);...
void cdev_del(struct cdev *p) { cdev_unmap(p->dev, p->count); kobject_put(&p->kobj); } 其中cdev_unmap() 调用 kobj_unmap() 来释放 cdev_map 散列表中的对象。kobject_put() 释放 cdev 结构本身。 --- struct cdev *cdev_alloc(void) { struct...
void cdev_del(struct cdev *p) { cdev_unmap(p->dev, p->count); kobject_put(&p->kobj); } 其中cdev_unmap() 调用 kobj_unmap() 来释放 cdev_map 散列表中的对象。kobject_put() 释放 cdev 结构本身。
5.当一个字符设备驱动不再需要的时候(比如模块卸载),就可以用cdev_del()函数来释放cdev占用的内存 void cdev_del(struct cdev *p) { cdev_unmap(p->dev, p->count); kobject_put(&p->kobj); } 其中cdev_unmap()调用kobj_unmap()来释放cdev_map散列表中的对象。kobject_put()释放cdev结构本身。
cdev = cdev_alloc(); if (!cdev) goto out2; cdev->owner = fops->owner; cdev->ops = fops; kobject_set_name(&cdev->kobj, "%s", name); err = cdev_add(cdev, MKDEV(cd->major, baseminor), count); if (err) goto out;
free_cdev: - cdev_del(&port->cdev); + cdev_del(port->cdev); free_port: kfree(port); fail: @@ -1197,7 +1203,7 @@ static void remove_port(struct port *port) } sysfs_remove_group(&port->dev->kobj, &port_attribute_group); ...