how kernel detect device and make proble() called?

Stefan Richter stefanr at s5r6.in-berlin.de
Thu Nov 13 17:02:56 UTC 2008


Greg KH wrote:
> On Thu, Nov 13, 2008 at 08:10:11AM -0800, Greg KH wrote:
>> On Thu, Nov 13, 2008 at 07:34:58AM -0800, hong zhang wrote:
>> > List,
>> > 
>> > Does anyone know how kernel detects a device and make probe() called for its driver?
>> 
>> Yes.

Usually there is a subsystem which --- from the Linux driver Model's
point of view --- implements a "bus".  The subsystem has its specific
means to detect presence of hardware.  It creates one or more device
representations of detected hardware and these data structures typically
encapsulate a struct device.  The subsystem registers this struct device
instance with Linux' driver core.  The driver core calls the subsystem's
driver match method for this device and binds the first matching driver
to it.  Then the core calls this driver's probe method for the device.

> (hint, you are going to have to be a lot more specific about your
> question in order to get a good answer...)

...notably, whether you are dealing with an entirely new bus or with one
for which Linux already has support (PCI, USB...).

In the latter case, the task of the driver author is to properly
register its driver with the respective subsystem and to expose the
appropriate match flags for the subsystem's driver match routine, for
example a PCI ID table in case of a PCI device driver.

In the former case, somebody had to implement the subsystem
infrastructure first.
-- 
Stefan Richter
-=====-==--- =-== -==-=
http://arcgraph.de/sr/



More information about the devel mailing list