-1

Following is the definition of the probe function in the standard GPIO based MDIO bitbang driver

static int __devinit mdio_ofgpio_probe(struct of_device *ofdev,const struct of_device_id* match)

I can't figure out the purpose of __devinit in the above code.
Secondly when is the probe function called by the driver? May be when the driver is loaded itself. But it's not the part of driver init functions. Correct me if I am wrong?

mdsingh
  • 973
  • 2
  • 13
  • 20
  • Google results: `Probe function -`http://stackoverflow.com/questions/9168885/when-does-the-probe-function-for-a-linux-kernel-driver-gets-called, `how is different from init()` - http://stackoverflow.com/questions/5059501/probe-method-device-drivers, `pupose of _devinit -` http://www.spinics.net/lists/newbies/msg29197.html – brokenfoot Mar 12 '14 at 08:10
  • the pupose of `_devinit` is pretty clear form the article. So it prevents the block from going to the regular `__init` code which is essentially removed when the module is loaded for it is required at the initialization time only... but in case of the probe functions which might be called later on due to a hotplug even this behavior is not the required one... good one really !!! thnx @brokenfoot – mdsingh Mar 13 '14 at 04:11
  • In the link http://stackoverflow.com/questions/5059501/probe-method-device-drivers it says
    **The driver's init function calls pci_register_driver() which gives the kernel a list of devices it is able to service, along with a pointer to the probe() function. The kernel then calls the driver's probe() function once for each device.** That can be the case for the normal devices like USB and PCI. They are inherently discoverable, meaning they can signal the kernel like "hey i am here". What is the flow for the platform devices say on an i2c or mdc/mdio bus.
    – mdsingh Mar 13 '14 at 04:12
  • i guess I got the answer to my question in your first link http://stackoverflow.com/questions/9168885/when-does-the-probe-function-for-a-linux-kernel-driver-gets-called. Thnx a ton @brokenfoot :) You are a savior. – mdsingh Mar 13 '14 at 04:20
  • You could have added it as an answer rather than a comment – mdsingh Mar 13 '14 at 04:20
  • I could have if they were my own ans, these were only links to some URLs. Upvote the comments if you found them useful so that if somebody is looking for the same ans, would know where to find it. – brokenfoot Mar 13 '14 at 04:45

1 Answers1

0

There are lists maintained at the bus driver structure for the available devices on the bus and also the available drivers in the system which can support the devices on that bus.

Now when insert the module in the kernel. Only init_module will be called to do basic initialization w.r.t your driver, but when you insert your device, a match function which is part of the bus structure is called to check if the list of drivers has any driver which supports your device. Upon successful match the probe of your driver is called.

sandeep
  • 141
  • 1
  • 1
  • 11