linux USB 驱动程序:探测已插入的设备
我正在编写 USB 驱动程序,但遇到问题。 当我用预先插入的设备插入驱动程序时,不会调用探测函数。仅在我断开设备并再次插入后才会调用它。 我想让它在我启动电脑且设备已插入时正常工作。
有人可以帮助我吗?
I am writing an Usb driver and I have an issue.
When I insmod the driver with the device already plugged in before hand, the probe function is not called. It is only called after I disconnect the device and plug it again.
I want to make it so that it works when I start my pc with the device already plugged in.
Could someone please help me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
来自 Documentation/driver-model/binding.txt:
来自同一来源:
因此,看起来您在 ID 匹配方面存在问题,即您的情况特定于 USB 总线,请参阅 drivers/usb/core/driver.c 中的 usb_device_match 函数。
或者可能是您的设备已经绑定到拔出设备时卸载的设备(您可以通过控制相应的 /sys/bus/usb/xxxxx 目录中是否存在指向驱动程序的符号链接来检查)
From Documentation/driver-model/binding.txt:
From the same source:
So it looks like you have a problem in the ID matching, that is in your case specific to the USB bus, see the usb_device_match function in drivers/usb/core/driver.c.
Or it may be that your device already is bound to a device that is unloaded when the device is unplugged (you can check that by controlling if there is a symlink to a driver in the corresponding /sys/bus/usb/xxxxx directory)
“或者可能是您的设备已经绑定到拔出设备时卸载的设备(您可以通过控制相应的 /sys/bus/usb/xxxxx 目录中是否存在指向驱动程序的符号链接来检查) “
如果有符号链接呢?
"Or it may be that your device already is bound to a device that is unloaded when the device is unplugged (you can check that by controlling if there is a symlink to a driver in the corresponding /sys/bus/usb/xxxxx directory)"
And if there is a symlink?
这可以通过为您的设备编写正确的 udev 规则来解决。在 /etc/udev/rules.d/ 中查找示例
This can be solved by writing a proper udev rule for your device. Look for examples at /etc/udev/rules.d/