Linux设备驱动程序:绑定和解开

发布于 2025-01-25 14:12:24 字数 227 浏览 4 评论 0原文

我遇到了LWN文章 “手动驱动程序绑定和解开” ,它在其中说明了如何使用sysfs接口来动态绑定和解开Linux中的驱动程序。该接口确切在内核代码中的确切位置?我认为这是在整个内核中共享的。

I came across the LWN article "Manual driver binding and unbinding", where it explains how to use the sysfs interface to dynamically bind and unbind drivers in Linux. Where exactly in the kernel code is this interface implemented? I assume this is shared across the whole kernel.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

止于盛夏 2025-02-01 14:12:24

您要查找的功能已实现在此处驱动程序/base/bus.c

当您写入/sys/bus/usb/drivers/usb/bind is bind_store()时,该功能被调用的功能,该功能从用户空间传递并使用它找到合适的设备。然后检查驱动程序是否在其ID表中声明对设备的支持,如果这样,则将其绑定到设备。同样,代码> 在同一文件中,通过/sys/bus/usb/drivers/usb/unbind来处理解除限制。

您感兴趣的功能可能是:

您可以查看设备是否通过

请注意,device_driver_detach()(在drivers/base/base/cod.c中使用以实现Unbining)未导出,请使用device> device> device_release_driver()代替。

The functionality you are looking for is implemented here in drivers/base/bus.c.

The function that gets called when you write to /sys/bus/usb/drivers/usb/bind is bind_store(), which gets the string passed from userspace and uses it to find the appropriate device. Then checks if the driver declares support for the device in its id table, and if so it binds it to the device. Similarly, unbind_store() in the same file handles unbinding through /sys/bus/usb/drivers/usb/unbind.

The functions you are interested in are probably these:

You can see if a device matches a specific driver through driver->bus->match().

Note that device_driver_detach() (used in drivers/base/bus.c to implement unbinding) is not exported, use device_release_driver() instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文