Search code examples
linuxlinux-kernellinux-device-driverpcipci-e

Where is the funcion 'pci_bus_write_config_dword' defined in linux source code? (linux-5.15.68)


In linux-5.15.68 source tree, I tried to search for the definition of function 'pci_write_config_dword' and this was calling 'pci_bus_write_config_dword'. So using grep, I searched for the defintio of 'pci_bus_write_config_dword' but only found prototype declaration and many places it is called from. Where is that function defined??
Of course I expect it is dependent on the PCIe RC controller and it envolves writing PCIe controller's registers.


Solution

  • See https://elixir.bootlin.com/linux/latest/source/drivers/pci/access.c#L53

    As you see, there is a template to create the function at different sizes, very useful to have type checking, but without repeating all code (which it is mostly similar). The @define just after the template will construct the function for different sizes.

    It is not the only place you see such construct. In general: if you see few functions with very similar signature and just a different suffix, and you cannot grep it, check if there is a template.