【问题标题】:what's the difference between struct cdev and struct devicestruct cdev 和 struct device 有什么区别 【发布时间】:2013-07-11 14:55:32 【问题描述】: 谁能给我一些关于struct cdev和struct device之间区别的解释? 【问题讨论】: 标签: linux linux-kernel linux-device-driver 【解决方案1】: 在最低级别,Linux 系统中的每个设备都由struct device 的实例表示。设备结构包含设备模型核心对系统建模所需的信息。但是,大多数子系统会跟踪有关它们所托管设备的附加信息。因此,设备很少用裸设备结构来表示;相反,该结构,如 kobject 结构,通常嵌入在设备的更高级别表示中。 more 然而,struct cdev 是内核用来在内部表示字符设备的结构。 more 【讨论】: 谢谢~还有一个问题,struct device嵌入struct cdev是否更好? struct device 和 struct cdev 是内核的内部结构,将一个嵌入另一个意味着您正在修改内核代码,这将产生严重后果。相反,您可以将struct device 和struct cdev 都嵌入到设备的主结构中。例如link 另见LDD3 Page:383中的设备结构嵌入