当前位置:网站首页>Under the platform driven platform, the "dev- > dev.of_node" of the formal parameter dev in the probe function Understanding of
Under the platform driven platform, the "dev- > dev.of_node" of the formal parameter dev in the probe function Understanding of
2022-07-28 11:07:00 【Egg Prince】
Drive function through int platform_driver_register (struct platform_driver *driver) Driver of function registration ,
183 static int __init miscbeep_init(void)
184 {
185 return platform_driver_register(&beep_driver);
186 }
198 module_init(miscbeep_init);When platform After the bus detects that the device tree has device nodes matching the driver , Is executed probe function ( int (*probe) (struct device *dev); ), here probe The formal parameter of the function dev The variable pointed to by the pointer is platform_device type ,platform_device The structure preserves platform Device information under the platform .
22 struct platform_device {
23 const char *name;
24 int id;
25 bool id_auto;
26 struct device dev;
27 u32 num_resources;
28 struct resource *resource;
29
30 const struct platform_device_id *id_entry;
31 char *driver_override; /* Driver name to force a match */
32
33 /* MFD cell pointer */
34 struct mfd_cell *mfd_cell;
35
36 /* arch specific additions */
37 struct pdev_archdata archdata;
38 };Its 26 Yes “struct device dev” member ( Be similar to C++ Parent class of ,platform_device Inherited struct device ) The node information in the device tree has been obtained , You can get node information through this member , namely “ miscbeep.nd = dev->dev.of_node;”
static int miscbeep_probe(struct platform_device *dev)
{
int ret = 0;
printk("beep driver and device was matched!\r\n");
/* Set up BEEP What is used GPIO */
/* 1、 Get device node :beep */
//miscbeep.nd = of_find_node_by_path("/beep");
miscbeep.nd = dev->dev.of_node;// Replace the previous line in this way “miscbeep.nd = of_find_node_by_path("/beep");” To get device nodes device Structure : One of the infrastructure in the device driven model . The structure is defined as follows :
struct device {
/* The parent device to which the device is attached , Most of the time , Such a device is some kind of bus or master controller , If the value of this member variable is NULL, Indicates that the current device is the top device , Usually, such equipment is not the one you want */
struct device *parent;
struct device_private *p;
struct kobject kobj;
const char *init_name; /* initial name of the device */
const 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 this device */
void *platform_data; /* Platform specific data, device core doesn't touch it */
struct dev_pm_info power;
struct dev_pm_domain *pm_domain;
#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_head dma_pools; /* dma pools (if dma'ble) */
struct dma_coherent_mem *dma_mem; /* internal for coherent mem override */
/* arch specific additions */
struct dev_archdata archdata;
struct device_node *of_node; /* associated device tree node */
dev_t devt; /* dev_t, creates the sysfs "dev" */
u32 id; /* device instance */
spinlock_t devres_lock;
struct list_head devres_head;
struct klist_node knode_class;
struct class *class;
const struct attribute_group **groups; /* optional groups */
void (*release)(struct device *dev);
};边栏推荐
- 剑指 Offer 35. 复杂链表的复制
- Product side data analysis thinking
- Inventory: 144 free learning websites, the most complete collection of resources in the whole network
- 使用statement对象执行DDL语句创建表
- CRM+零代码:轻松实现企业信息化
- Blue Bridge Cup embedded Hal library LCD
- I use the applet container to improve the efficiency of mobile R & D by 5 times!
- Installation points and precautions of split angle probe
- 10_ UE4 advanced_ Add fall and cast actions
- PHP发送移动MAS短信乱码的解决方法
猜你喜欢

什么是WordPress

Ten questions about low code: tell everything about low code!

Product side data analysis thinking

读懂这6本书,学习MySQL更轻松

Software designers ask 20 questions before the exam, pay attention!!

Bc35 NB module at instruction development summary

盘点:6本书教会你职场晋升必备技能

Relevant knowledge points of hash table

蓝桥杯嵌入式-HAL库-SYSTICK

剑指 Offer 35. 复杂链表的复制
随机推荐
数组相关的知识点
Redis-day01 common sense supplement and redis introduction
Reading these six books makes learning MySQL easier
JS - 修改数组中对象的键名
零代码 | 轻松实现数据仓库建模,搭建BI看板
读懂这6本书,学习MySQL更轻松
Do data analysis, do you still not understand RFM analysis method (model)?
理解Oracle的几个概念
Two years of crud, two graduates, two months of preparation for the interview with ALI, and fortunately won the offer grading p6
Three ways for Cortex-M kernel to manage global interrupts
c语言实现float型数据转成BCD数据
clo*******e:项目管理随记
网络文件系统服务(NFS)
蓝桥杯嵌入式-HAL库-USART_RX
盘点:6本书教会你职场晋升必备技能
nodemcu之开发环境配置
Causes and solutions of invalid ROM table
Arduino Basics
Sword finger offer 06. print linked list from end to end
Pyqt5 rapid development and practice 4.11 drag and clipboard