Linux 内核驱动程序的探测函数何时被调用?

发布于 2025-01-03 06:07:24 字数 329 浏览 3 评论 0原文

我正在尝试更新Android的内核驱动程序,我添加了一些printk来调试它,调用了_init函数,但没有调用probe函数。 我缺少什么?何时/如何调用探测函数?

代码位于:https://github.com/lamegopinto/kernel-2.6.32.27-M722HC/blob/master/drivers/power/rk2918_battery.c

I am trying to update a kernel driver for Android, I have added some printk's to debug it, the _init function is invoked, but the probe function is not.
What I am missing ? When/how is the probe function invoked ?

The code is available at: https://github.com/lamegopinto/kernel-2.6.32.27-M722HC/blob/master/drivers/power/rk2918_battery.c

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

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

发布评论

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

评论(3

网名女生简单气质 2025-01-10 06:07:24

经过一番研究后找到了答案,对于“平台”设备,当注册平台设备并且其设备名称与设备驱动程序上指定的名称匹配时,将调用探测函数。

更多详细信息请参见此处:
http://comments.gmane.org/gmane.linux.kernel.kernelnewbies/37050

现在我只需要弄清楚为什么设备没有被注册:\

Found the answer after some research, For a "platform" device the probe function is invoked when a platform device is registered and it's device name matchs the name specified on the device driver.

More details here:
http://comments.gmane.org/gmane.linux.kernel.kernelnewbies/37050

Now I just need to figure why the device is not being registered :\

我的黑色迷你裙 2025-01-10 06:07:24

当调用 module_init(在动态加载的情况下为 insmod)时,驱动程序注册完成,并且存在与驱动程序相关的各种回调探针、恢复、挂起。

现在要了解的主要内容是探针函数中发生的所有事情。如果您注意到在探测中大多数与设备相关的初始化已完成(例如与设备相关的设置),那么显然这应该在设备存在时执行。

当设备和驱动程序名称/ID 匹配时,即验证它们将被耦合/链接时,将调用探测器。现在我们确信 Driver ABC 将与 Device ABC 相关联;驱动程序 ABC 的探测中设备 ABC 的初始化设置也是如此。

When a module_init is called (insmod in case of dynamic loading) then the driver registration is done, and the various callbacks probe, resume, suspend related to the driver are present.

Now the main thing to understand this is what all happens in probe function. If you notice then in probe most the initialisation related to device is done (eg. settings associated with DEVICE), so obviously this should execute when device is present.

Probe is called when the device and driver name/id are matched i.e. verified that these will be coupled/linked. So now we are sure that say Driver ABC will be associated with Device ABC; so do the initialization settings for Device ABC in probe of Driver ABC.

燃情 2025-01-10 06:07:24

只要看到设备,就会调用probe函数。这可能发生在设备启动时,也可能发生在设备连接时。请查看这篇文章了解更多信息。

The probe function is called whenever the device is seen. This can happen on device boot, or it can occur when the device is connected. Check out this article for more info.

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