When does the probe function for a Linux kernel driver gets called?

最后都变了- 提交于 2020-01-12 06:49:23

问题


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


回答1:


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 :\




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/9168885/when-does-the-probe-function-for-a-linux-kernel-driver-gets-called

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!