将平台设备添加到Linux内核
在浏览Linux内核的平台驱动程序时,我遇到了平台驱动程序API,例如
int platform_add_devices(struct platform_device **devs, int num)
static void platform_device_release(struct device *dev)
struct platform_device *platform_device_alloc(const char *name, int id)
int platform_device_add_resources(struct platform_device *pdev,const struct resource *res, unsigned int num)
根据我的理解,设备节点是在设备树文件中添加的。内核 启动或UDEV执行设备树节点和平台驱动程序中兼容字符串的匹配,并且调用了probe()函数。
在Probe()中,我们将通过 struct platform_device 结构获取设备树节点的引用,我们可以用来从设备树读取设备节点的资源和其他参数。
那么,在哪些情况下使用上述平台API? 为什么我们需要使用上述API将设备添加到内核中。
对此的任何输入都会有所帮助。
While going through platform drivers for linux kernel, I came across platform driver APIs like
int platform_add_devices(struct platform_device **devs, int num)
static void platform_device_release(struct device *dev)
struct platform_device *platform_device_alloc(const char *name, int id)
int platform_device_add_resources(struct platform_device *pdev,const struct resource *res, unsigned int num)
As per my understanding the device nodes are added in the Device trees files. The kernel while
booting or the udev performs the matching of the compatible strings in Device trees node and platform driver and the probe() functions is called.
In the probe() we will get reference of the device tree node through struct platform_device structure which we can use to read the resource and other parameters of the device node from device tree.
So under what scenarios the above platform APIs are used?
Why we need to add devices to kernel using the above APIs.
Any inputs on this will be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论