linux-设备驱动之device设备结构
2013-12-24 15:03
288 查看
在linux系统中每一个设备由结构体::struct device来描述
struct device {
struct device
*parent;
struct device_private*p;
struct kobject kobj;
const char*init_name; /* initial name of the device--用来描述设备的 */
struct device_type*type;//
struct mutex
mutex; /* mutex to synchronize calls to
* its driver.
*/
struct bus_type*bus;
/* type of bus device is on 设备坐在总线*/
struct device_driver *driver;/* which driver has allocated thisdevice --管理该设备的驱动*/
void*platform_data;
/* Platform specific data, devicecore doesn't touch it */
struct dev_pm_infopower;
#ifdef CONFIG_NUMA
int numa_node;/* NUMA node this device is close to */
#endif
u64 *dma_mask;/* dma mask (if dma'able device) */
u64 coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as
not all hardware supports
64 bit addresses for consistent
allocations such descriptors. */
struct device_dma_parameters *dma_parms;
struct list_headdma_pools;
/* dma pools (if dma'ble) */
struct dma_coherent_mem*dma_mem; /* internal for coherent mem
override */
/* arch specific additions */
struct dev_archdataarchdata;
#ifdef CONFIG_OF
struct device_node*of_node;
#endif
dev_t devt;/* dev_t, creates the sysfs "dev" */
spinlock_t
devres_lock;
struct list_headdevres_head;
struct klist_nodeknode_class;
struct class
*class;
const struct attribute_group **groups;/* optional groups */
void (*release)(struct device *dev);
};
注册设备使用的函数
device_register(struct device *dev);
注销设备使用的函数
device_unregister(struct device *dev);
设备属性结构体 device_attribute描述
struct device_attribute {
struct attributeattr;
ssize_t (*show)(struct device *dev, struct device_attribute *attr,
char *buf);//读取时 调用的函数
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);//写入时 调用的函数
};
创建属性函数
device_create_file(struct device *device,const struct device_attribute *entry);
删除属性文件
device_remove_file(struct device *dev,const struct device_attribute *attr);
struct device {
struct device
*parent;
struct device_private*p;
struct kobject kobj;
const char*init_name; /* initial name of the device--用来描述设备的 */
struct device_type*type;//
struct mutex
mutex; /* mutex to synchronize calls to
* its driver.
*/
struct bus_type*bus;
/* type of bus device is on 设备坐在总线*/
struct device_driver *driver;/* which driver has allocated thisdevice --管理该设备的驱动*/
void*platform_data;
/* Platform specific data, devicecore doesn't touch it */
struct dev_pm_infopower;
#ifdef CONFIG_NUMA
int numa_node;/* NUMA node this device is close to */
#endif
u64 *dma_mask;/* dma mask (if dma'able device) */
u64 coherent_dma_mask;/* Like dma_mask, but for
alloc_coherent mappings as
not all hardware supports
64 bit addresses for consistent
allocations such descriptors. */
struct device_dma_parameters *dma_parms;
struct list_headdma_pools;
/* dma pools (if dma'ble) */
struct dma_coherent_mem*dma_mem; /* internal for coherent mem
override */
/* arch specific additions */
struct dev_archdataarchdata;
#ifdef CONFIG_OF
struct device_node*of_node;
#endif
dev_t devt;/* dev_t, creates the sysfs "dev" */
spinlock_t
devres_lock;
struct list_headdevres_head;
struct klist_nodeknode_class;
struct class
*class;
const struct attribute_group **groups;/* optional groups */
void (*release)(struct device *dev);
};
注册设备使用的函数
device_register(struct device *dev);
注销设备使用的函数
device_unregister(struct device *dev);
设备属性结构体 device_attribute描述
struct device_attribute {
struct attributeattr;
ssize_t (*show)(struct device *dev, struct device_attribute *attr,
char *buf);//读取时 调用的函数
ssize_t (*store)(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count);//写入时 调用的函数
};
创建属性函数
device_create_file(struct device *device,const struct device_attribute *entry);
删除属性文件
device_remove_file(struct device *dev,const struct device_attribute *attr);
相关文章推荐
- Linux设备模型(总线、设备、驱动程序和类)之三:device_driver && 多厂家驱动自动识别
- 读书笔记《Linux Device Drivers》:第一章,设备驱动介绍
- Linux设备模型(总线、设备、驱动程序和类)之三:device_driver && 多厂家驱动自动识别
- Linux设备模型中三个很重要的概念: 总线,设备,驱动.即bus,device,driver
- linux设备驱动结构梳理
- Linux内核部件分析--设备驱动模型之device-driver
- linux下设备device_register和驱动driver_register先后注册的影响和关系
- Linux I2C设备驱动(一)——物理拓扑结构与协议
- hello_world-2.2之简单设备驱动模型(二)---device,bus,driver结构介绍
- Writing Linux LCD drivers—深入分析framebuffer设备驱动的结构
- linux字符设备驱动结构
- Linux 字符设备驱动结构(一)—— cdev 结构体、设备号相关知识解析
- Linux网络设备驱动结构概述
- 【linux驱动笔记】字符设备驱动相关数据结构与算法
- Linux 网络设备驱动开发(一) —— linux内核网络分层结构
- Linux设备驱动--块设备(二)之相关结构体
- LINUX设备驱动之设备模型五--device&driver&bus(三)
- linux网络设备驱动的结构
- linux 下千兆网卡驱动开发 网络设备驱动的层次结构 (三)
- Linux 网络设备驱动之层次结构