- Q:
In the linux kernel, what does theprobe()
method, that the driver provides, do? How different is it from the driver'sinit
function, i.e. why can't theprobe()
functions actions be performed in the driver'sinit
function ? - A1:
Different device types can have probe() functions. For example, PCI and USB devices both have probe() functions.
If you're talking about PCI devices, I would recommend you read chapter 12 of Linux Device Drivers, which covers this part of driver initialization. USB is covered in chapter 13.
Shorter answer, assuming PCI: The driver's init function callspci_register_driver()
which gives the kernel a list of devices it is able to service, along with a pointer to theprobe()
function. The kernel then calls the driver'sprobe()
function once for each device.This probe function starts the per-device initialization: initializing hardware, allocating resources, and registering the device with the kernel as a block or network device or whatever it is.This makes is easier for device drivers, because they never need to search for devices or worry about finding a device that was hot-plugged. The kernel handles that part and notifies the right driver when it has a device for you to handle. - A2:Init(void) // runs once when the driver/module is invoked and sets things up for the kernel driver machine.Probe(*pdev) // is used by the kernel driver machine as needed to detect and install actual devices
2012年10月25日 星期四
probe function
路過看到先記錄一下…
標籤:
Linux Driver
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言