admin管理员组

文章数量:1123508

I'm facing a compilation issue with the pci_reset_bus function.

  • In kernel versions 4.19-rc1 and later, the function signature is:

    int pci_reset_bus(struct pci_dev *dev);
    
  • In kernel versions prior to 4.19-rc1, the signature was:

    int pci_reset_bus(struct pci_bus *bus);
    

The problem is that I have a character device driver that uses this function and needs to compile across various Linux distributions. for example:

  • SLES 15.1 with kernel 4.12.14-195-default uses the new signature (int pci_reset_bus(struct pci_dev *dev)).
  • Fedora 27 with kernel 4.13.9 also uses the new signature.

Here is the current code I have:

int nnt_pci_reset_bus(struct pci_dev *pci_device)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) || (defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= 2048)
    return pci_reset_bus(pci_device);
#else
    return pci_reset_bus(pci_device->bus);
#endif
}

This doesn't work because the function signature cannot be determined even for older kernel versions below 4.19 as we see in SLES 15.1.

My questions:

  1. What is the best way to determine the correct signature of pci_reset_bus?
  2. What is the most reliable solution to handle this situation for different kernel versions and distributions?

Looking for a robust method to make this code work universally across different kernels.

本文标签: linuxHow to identify the signature of pciresetbus funtcionStack Overflow