VirtualBox

Ignore:
Timestamp:
Aug 11, 2020 5:05:29 PM (4 years ago)
Author:
vboxsync
Message:

IPRT,lnx-kmods: Use new linux kernel version checking macros. Moved them to separate wrapper header.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c

    r83471 r85698  
    4848# include <linux/intel-iommu.h>
    4949# include <linux/pci.h>
    50 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 1, 0) && \
    51      (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 41) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0))
     50# if RTLNX_VER_MAX(3,1,0) && \
     51     (RTLNX_VER_MAX(2,6,41) || RTLNX_VER_MIN(3,0,0))
    5252#  include <asm/amd_iommu.h>
    5353# else
    5454#  include <linux/amd-iommu.h>
    5555# endif
    56 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
     56# if RTLNX_VER_MAX(3,2,0)
    5757#  define IOMMU_PRESENT()      iommu_found()
    5858#  define IOMMU_DOMAIN_ALLOC() iommu_domain_alloc()
     
    8787
    8888
    89 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     89#if RTLNX_VER_MIN(2,6,20)
    9090# define PCI_DEV_GET(v,d,p)            pci_get_device(v,d,p)
    9191# define PCI_DEV_PUT(x)                pci_dev_put(x)
    92 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)
     92#if RTLNX_VER_MIN(4,17,0)
    9393/* assume the domain number to be zero - exactly the same assumption of
    9494 * pci_get_bus_and_slot()
     
    165165    if (request_module(PCI_STUB_MODULE) == 0)
    166166    {
    167 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
     167# if RTLNX_VER_MIN(2,6,30)
    168168        /* find_module() is static before Linux 2.6.30 */
    169169        mutex_lock(&module_mutex);
     
    320320    if (RT_LIKELY(pIns->pPciDev))
    321321    {
    322 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
     322#if RTLNX_VER_MIN(2,6,28)
    323323        if (pci_reset_function(pIns->pPciDev))
    324324        {
     
    374374    fs_save = get_fs();
    375375    set_fs(KERNEL_DS);
    376 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
     376#if RTLNX_VER_MIN(4,14,0)
    377377    ret = kernel_write(file, data, size, &offset);
    378378#else
     
    448448        int                iCmdLen;
    449449        const int          cMaxBuf = 128;
    450 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     450#if RTLNX_VER_MIN(2,6,29)
    451451        const struct cred *pOldCreds;
    452452        struct cred       *pNewCreds;
     
    469469
    470470        /* Somewhat ugly hack - override current credentials */
    471 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     471#if RTLNX_VER_MIN(2,6,29)
    472472        pNewCreds = prepare_creds();
    473473        if (!pNewCreds)
    474474                goto done;
    475475
    476 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     476# if RTLNX_VER_MIN(3,5,0)
    477477        pNewCreds->fsuid = GLOBAL_ROOT_UID;
    478478# else
     
    533533            printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf);
    534534
    535 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     535#if RTLNX_VER_MIN(2,6,29)
    536536        revert_creds(pOldCreds);
    537537        put_cred(pNewCreds);
     
    560560        int                iCmdLen;
    561561        const int          cMaxBuf = 128;
    562 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     562#if RTLNX_VER_MIN(2,6,29)
    563563        const struct cred *pOldCreds;
    564564        struct cred       *pNewCreds;
     
    586586
    587587        /* Somewhat ugly hack - override current credentials */
    588 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     588#if RTLNX_VER_MIN(2,6,29)
    589589        pNewCreds = prepare_creds();
    590590        if (!pNewCreds)
    591591            goto done;
    592592
    593 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
     593# if RTLNX_VER_MIN(3,5,0)
    594594        pNewCreds->fsuid = GLOBAL_ROOT_UID;
    595595# else
     
    627627            printk(KERN_DEBUG "vboxpci: cannot open %s\n", szFileBuf);
    628628
    629 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
     629#if RTLNX_VER_MIN(2,6,29)
    630630        revert_creds(pOldCreds);
    631631        put_cred(pNewCreds);
     
    670670                vbpci_printk(KERN_DEBUG, pPciDev, "%s\n", __func__);
    671671
    672 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     672#if RTLNX_VER_MIN(2,6,1)
    673673                if (pci_enable_msi(pPciDev) == 0)
    674674                    pIns->fMsiUsed = true;
     
    717717        vboxPciLinuxDevUnregisterWithIommu(pIns);
    718718
    719 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 1)
     719#if RTLNX_VER_MIN(2,6,1)
    720720        if (pIns->fMsiUsed)
    721721            pci_disable_msi(pPciDev);
     
    843843        if (!rcLnx)
    844844        {
    845 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     845#if RTLNX_VER_MIN(2,6,25)
    846846            /*
    847847             * ioremap() defaults to no caching since the 2.6 kernels.
     
    859859            else
    860860            {
    861 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
     861#if RTLNX_VER_MIN(2,6,25)
    862862                vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n");
    863863#else
     
    956956 * @param   pRegs           Register set. Removed in 2.6.19.
    957957 */
    958 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 19) && !defined(DOXYGEN_RUNNING)
     958#if RTLNX_VER_MIN(2,6,19) && !defined(DOXYGEN_RUNNING)
    959959static irqreturn_t vboxPciOsIrqHandler(int iIrq, void *pvDevId)
    960960#else
     
    992992#ifdef VBOX_WITH_SHARED_PCI_INTERRUPTS
    993993                     /* Allow interrupts sharing. */
    994 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
     994# if RTLNX_VER_MIN(2,6,20)
    995995                     IRQF_SHARED,
    996996# else
     
    10021002                     /* We don't allow interrupts sharing */
    10031003                     /* XXX overhaul */
    1004 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20) && LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
     1004# if RTLNX_VER_MIN(2,6,20) && RTLNX_VER_MAX(4,1,0)
    10051005                     IRQF_DISABLED, /* keep irqs disabled when calling the action handler */
    10061006# else
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette