#define IWL_DEV_INFO(_device, _subdevice, _cfg, _name) \
        _IWL_DEV_INFO(_device, _subdevice, IWL_CFG_ANY, IWL_CFG_ANY,       \
                      IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_ANY, IWL_CFG_ANY,  \
-                     IWL_CFG_NO_CDB, _cfg, _name)
+                     IWL_CFG_ANY, _cfg, _name)
 
 static const struct iwl_dev_info iwl_dev_info_table[] = {
 #if IS_ENABLED(CONFIG_IWLMVM)
 /* PCI registers */
 #define PCI_CFG_RETRY_TIMEOUT  0x041
 
+static const struct iwl_dev_info *
+iwl_pci_find_dev_info(u16 device, u16 subsystem_device,
+                     u16 mac_type, u8 mac_step,
+                     u16 rf_type, u8 cdb, u8 rf_id, u8 no_160, u8 cores)
+{
+       const struct iwl_dev_info *ret = NULL;
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
+               const struct iwl_dev_info *dev_info = &iwl_dev_info_table[i];
+
+               if (dev_info->device != (u16)IWL_CFG_ANY &&
+                   dev_info->device != device)
+                       continue;
+
+               if (dev_info->subdevice != (u16)IWL_CFG_ANY &&
+                   dev_info->subdevice != subsystem_device)
+                       continue;
+
+               if (dev_info->mac_type != (u16)IWL_CFG_ANY &&
+                   dev_info->mac_type != mac_type)
+                       continue;
+
+               if (dev_info->mac_step != (u8)IWL_CFG_ANY &&
+                   dev_info->mac_step != mac_step)
+                       continue;
+
+               if (dev_info->rf_type != (u16)IWL_CFG_ANY &&
+                   dev_info->rf_type != rf_type)
+                       continue;
+
+               if (dev_info->cdb != (u8)IWL_CFG_ANY &&
+                   dev_info->cdb != cdb)
+                       continue;
+
+               if (dev_info->rf_id != (u8)IWL_CFG_ANY &&
+                   dev_info->rf_id != rf_id)
+                       continue;
+
+               if (dev_info->no_160 != (u8)IWL_CFG_ANY &&
+                   dev_info->no_160 != no_160)
+                       continue;
+
+               if (dev_info->cores != (u8)IWL_CFG_ANY &&
+                   dev_info->cores != cores)
+                       continue;
+
+               ret = dev_info;
+       }
+
+       return ret;
+}
+
 static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
        const struct iwl_cfg_trans_params *trans;
        const struct iwl_cfg *cfg_7265d __maybe_unused = NULL;
+       const struct iwl_dev_info *dev_info;
        struct iwl_trans *iwl_trans;
        struct iwl_trans_pcie *trans_pcie;
-       int i, ret;
+       int ret;
        const struct iwl_cfg *cfg;
 
        trans = (void *)(ent->driver_data & ~TRANS_CFG_MARKER);
            !CSR_HW_RFID_TYPE(iwl_trans->hw_rf_id) && get_crf_id(iwl_trans))
                goto out_free_trans;
 
-       for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
-               const struct iwl_dev_info *dev_info = &iwl_dev_info_table[i];
-               if ((dev_info->device == (u16)IWL_CFG_ANY ||
-                    dev_info->device == pdev->device) &&
-                   (dev_info->subdevice == (u16)IWL_CFG_ANY ||
-                    dev_info->subdevice == pdev->subsystem_device) &&
-                   (dev_info->mac_type == (u16)IWL_CFG_ANY ||
-                    dev_info->mac_type ==
-                    CSR_HW_REV_TYPE(iwl_trans->hw_rev)) &&
-                   (dev_info->mac_step == (u8)IWL_CFG_ANY ||
-                    dev_info->mac_step ==
-                    CSR_HW_REV_STEP(iwl_trans->hw_rev)) &&
-                   (dev_info->rf_type == (u16)IWL_CFG_ANY ||
-                    dev_info->rf_type ==
-                    CSR_HW_RFID_TYPE(iwl_trans->hw_rf_id)) &&
-                   (dev_info->cdb == IWL_CFG_NO_CDB ||
-                    CSR_HW_RFID_IS_CDB(iwl_trans->hw_rf_id)) &&
-                   (dev_info->rf_id == (u8)IWL_CFG_ANY ||
-                    dev_info->rf_id ==
-                    IWL_SUBDEVICE_RF_ID(pdev->subsystem_device)) &&
-                   (dev_info->no_160 == (u8)IWL_CFG_ANY ||
-                    dev_info->no_160 ==
-                    IWL_SUBDEVICE_NO_160(pdev->subsystem_device)) &&
-                   (dev_info->cores == (u8)IWL_CFG_ANY ||
-                    dev_info->cores ==
-                    IWL_SUBDEVICE_CORES(pdev->subsystem_device))) {
-                       iwl_trans->cfg = dev_info->cfg;
-                       iwl_trans->name = dev_info->name;
-               }
+       dev_info = iwl_pci_find_dev_info(pdev->device, pdev->subsystem_device,
+                                        CSR_HW_REV_TYPE(iwl_trans->hw_rev),
+                                        CSR_HW_REV_STEP(iwl_trans->hw_rev),
+                                        CSR_HW_RFID_TYPE(iwl_trans->hw_rf_id),
+                                        CSR_HW_RFID_IS_CDB(iwl_trans->hw_rf_id),
+                                        IWL_SUBDEVICE_RF_ID(pdev->subsystem_device),
+                                        IWL_SUBDEVICE_NO_160(pdev->subsystem_device),
+                                        IWL_SUBDEVICE_CORES(pdev->subsystem_device));
+
+       if (dev_info) {
+               iwl_trans->cfg = dev_info->cfg;
+               iwl_trans->name = dev_info->name;
        }
 
 #if IS_ENABLED(CONFIG_IWLMVM)