将平台设备添加到Linux内核

发布于 2025-01-28 12:36:21 字数 625 浏览 5 评论 0原文

在浏览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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文