Why is the probe method needed in Linux device drivers in addition to init?

后端 未结 7 1230
有刺的猬
有刺的猬 2020-12-04 09:07

In the linux kernel, what does the probe() method, that the driver provides, do? How different is it from the driver\'s init function, i.e. why can

7条回答
  •  爱一瞬间的悲伤
    2020-12-04 09:38

    Linux kernel uses a hardware device matching a software device driver process. init is called very early, and registers probe function and a hardware device name like "taiko_sound_card", to the kernel. This is to tell kernel that "I am sw driver for this device of this name". When the kernel goes through hw devices (device tree or bus enum), and finds a match, it will call your registered probe function. Now your sw device driver owns the hw device.

    If no matching device is found, your probe may never get called. This is why typically init is tiny and probe does all the init work.

提交回复
热议问题