Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Who calls the probe() of driver

How does probe() call gets called? Who calls it? As per my understanding, __init() registers driver and then somehow probe() is called to register the device data and irq etc. How exactly it happens?

I am working on touchscreen driver and its __init registers itself to i2c driver. Then probe expect i2c_client data which returns null. I want to track where it gets filled.

like image 771
iSegFault Avatar asked Sep 28 '11 05:09

iSegFault


People also ask

What is probe in driver?

The probe routine specifies a physical device ID as a device node property so that the bus driver can find the appropriate device driver for this device node. Note that the device ID is bus class specific. For instance, on PCI bus, the device ID is the vendor/device IDs pair.

Why do we need a probe?

A probe is a single-stranded sequence of DNA or RNA used to search for its complementary sequence in a sample genome. The probe is placed into contact with the sample under conditions that allow the probe sequence to hybridize with its complementary sequence.

What is probe in Linux kernel?

Kernel probes are a set of tools to collect Linux kernel debugging and performance information. Developers and system administrators usually use them either to debug the kernel, or to find system performance bottlenecks. The reported data can then be used to tune the system for better performance.

How do I register a device driver in Linux?

To register a character device, we need to use the register_chrdev function: int register_chrdev (unsigned int major, const char * name, const struct file_operations * fops);


1 Answers

Long story short: the probe() function of the driver is called as a result of calling the register_driver for that specific bus. More precisely, it's called by the probe() of that bus_type structure. In your case: i2c_bus_type.

Here's the call chain in your I2C case:

  • i2c_register_driver
  • driver_register
  • bus_add_driver
  • driver_attach
  • __driver_attach (for your device)
  • driver_probe_device
  • really_probe
  • i2c_device_probe (this is what dev->bus->probe is for an i2c driver)
  • your_probe_function
like image 200
Mircea Avatar answered Oct 03 '22 14:10

Mircea