<div dir="ltr"><br>&gt;I am completely new to this PCI device driver so I just wanted to know that<br>&gt;how kernel build pci_dev structure during pci initialization time. what are<br>&gt;the pci function are being called <br><br><br>The sequence of routines that lead to pci device initialization.<br><br>pci_legacy_init() -&gt; pcibios_scan_root() -&gt; pci_scan_child_bus()-&gt; pci_scan_slot()-&gt; pci_scan_single_device()<br>-&gt;pci_device_add()-&gt; device_add(&amp;dev-&gt;dev) -&gt; bus_probe_device() -&gt; device_attach()<br><br><br><br><br>struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn)<br>{<br>        struct pci_dev *dev;<br><br>        dev = pci_get_slot(bus, devfn);<br>        if (dev) {<br>                pci_dev_put(dev);<br>                return dev;<br>        }<br><br>        dev = pci_scan_device(bus, devfn);<br>        if (!dev)<br>                return NULL;<br><br>        pci_device_add(dev, bus);<br><br>        return dev;<br>}<br><br><br><br>/*<br> * Read the config data for a PCI device, sanity-check it<br> * and fill in the dev structure...<br> */<br>static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn)<br>{<br>        struct pci_dev *dev;<br>        u32 l;<br><br>        if (!pci_bus_read_dev_vendor_id(bus, devfn, &amp;l, 60*1000))<br>                return NULL;<br><br>        dev = pci_alloc_dev(bus);<br>        if (!dev)<br>                return NULL;<br><br>        dev-&gt;devfn = devfn;<br>        dev-&gt;vendor = l &amp; 0xffff;<br>        dev-&gt;device = (l &gt;&gt; 16) &amp; 0xffff;<br><br>        pci_set_of_node(dev);<br><br>        if (pci_setup_device(dev)) {<br>                pci_bus_put(dev-&gt;bus);<br>                kfree(dev);<br>                return NULL;<br>        }<br><br>        return dev;<br>}<br><br></div>