标题 | 阅读 | 评论 | 转发 | 发布日期 | |
---|---|---|---|---|---|
android Vold Usb | 1277 | 0 | 0 | 2012-11-28 | |
内核循环缓冲区数据结构在用户态的使用 | 1633 | 0 | 1 | 2012-11-27 | |
巧夺天工的kfifo | 1818 | 0 | 1 | 2012-11-27 | |
串口驱动程序分析 | 1579 | 0 | 1 | 2012-11-27 | |
Linux设备模型之tty驱动架构分析 | 1693 | 0 | 2 | 2012-11-27 | |
Git错误non-fast-forward后的冲突解决 | 1101 | 0 | 0 | 2012-11-23 | |
解决 Agent admitted failure to sign using the key 问题 with ssh | 1044 | 0 | 0 | 2012-11-23 | |
__attribute__((packed))详解 | 1147 | 0 | 0 | 2012-11-16 | |
re-enumerating the device | 803 | 0 | 0 | 2012-11-07 | |
Ubuntu 系统 Motorola Defy 刷机教程 | 1051 | 0 | 0 | 2012-11-06 |
chen_chuang2012-10-11 16:33
高手,有本书上写cdev初始化和注册是这样写的
static void VirtualDisk_setup_cdev(struct VirtualDisk *dev, int minor)
{
int err;
devno = MDDEV(VirtualDisk_major, minor);
cdev_init(&dev->cdev, &VirtualDisk_fops);
dev->cdev.owner = THIS_MOUDULE;
dev->cdev.ops = &VirtualDisk_fops;
err = cdev_add(&dev->cdev, debno, 1);
if (err)
printk(KERN_NOTICE "Error in cdev_add()\n");
}
而cdev_init里
void cdev_init(struct cdev *cdev, const struct file_operations *fops)
{
memset(cdev, 0, sizeof *cdev);
INIT_LIST_HEAD(&cdev->list);
kobject_init(&cdev->kobj, &ktype_cdev_default);
cdev->ops = fops;
}
已经有cdev->ops = fops了
那上面的代码cdev_init之后又有dev->cdev.ops ,这两个函数不一样吗,自我感觉有点多次一举,,,不太明白