linux USB 驱动程序:探测已插入的设备

发布于 2024-09-05 16:08:38 字数 116 浏览 7 评论 0原文

我正在编写 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 技术交流群。

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

发布评论

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

评论(3

被你宠の有点坏 2024-09-12 16:08:38

来自 Documentation/driver-model/binding.txt:

添加新设备时,会迭代总线的驱动程序列表
找到一个支持它的人。为了确定这一点,该设备
设备的 ID 必须与驱动程序所识别的设备 ID 之一相匹配
支持。比较 ID 的格式和语义是特定于总线的。

来自同一来源:

添加新驱动程序时的过程几乎相同。
迭代总线的设备列表以查找匹配项。设备
已经有驱动程序的将被跳过。所有设备均已迭代
结束,将尽可能多的设备绑定到驱动程序。

因此,看起来您在 ID 匹配方面存在问题,即您的情况特定于 USB 总线,请参阅 drivers/usb/core/driver.c 中的 usb_device_match 函数。

或者可能是您的设备已经绑定到拔出设备时卸载的设备(您可以通过控制相应的 /sys/bus/usb/xxxxx 目录中是否存在指向驱动程序的符号链接来检查)

From Documentation/driver-model/binding.txt:

When a new device is added, the bus's list of drivers is iterated over
to find one that supports it. In order to determine that, the device
ID of the device must match one of the device IDs that the driver
supports. The format and semantics for comparing IDs is bus-specific.

From the same source:

The process is almost identical for when a new driver is added.
The bus's list of devices is iterated over to find a match. Devices
that already have a driver are skipped. All the devices are iterated
over, to bind as many devices as possible to the driver.

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)

鲜肉鲜肉永远不皱 2024-09-12 16:08:38

“或者可能是您的设备已经绑定到拔出设备时卸载的设备(您可以通过控制相应的 /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?

枕头说它不想醒 2024-09-12 16:08:38

这可以通过为您的设备编写正确的 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/

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