mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 08:02:27 +02:00
wifi: iwlwifi: add a kunit test for PCI table duplicates
We shouldn't have entries in the table that match the same device; it's possible to have a specific entry followed by a less specific entry (i.e. NNNN followed by ANY), but not entries that are dead, where an earlier entry matches the same as a later one. Add a test similar to the existing devinfo test to catch this situation. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://msgid.link/20240319100755.826b859abd62.I8140d7e9ae52ac50c6830818f8f95ccd0d94b3d3@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
1758f979b2
commit
8b251253a2
|
|
@ -11,6 +11,7 @@
|
|||
#include <linux/netdevice.h>
|
||||
#include <linux/ieee80211.h>
|
||||
#include <linux/nl80211.h>
|
||||
#include <linux/mod_devicetable.h>
|
||||
#include "iwl-csr.h"
|
||||
#include "iwl-drv.h"
|
||||
|
||||
|
|
@ -484,6 +485,7 @@ 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 jacket, u8 rf_id, u8 no_160, u8 cores, u8 rf_step);
|
||||
extern const struct pci_device_id iwl_hw_card_ids[];
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ extern int _invalid_type;
|
|||
.driver_data = _ASSIGN_CFG(cfg)
|
||||
|
||||
/* Hardware specific file defines the PCI IDs table for that hardware module */
|
||||
static const struct pci_device_id iwl_hw_card_ids[] = {
|
||||
VISIBLE_IF_IWLWIFI_KUNIT const struct pci_device_id iwl_hw_card_ids[] = {
|
||||
#if IS_ENABLED(CONFIG_IWLDVM)
|
||||
{IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */
|
||||
{IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */
|
||||
|
|
@ -516,6 +516,7 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
|
|||
{0}
|
||||
};
|
||||
MODULE_DEVICE_TABLE(pci, iwl_hw_card_ids);
|
||||
EXPORT_SYMBOL_IF_IWLWIFI_KUNIT(iwl_hw_card_ids);
|
||||
|
||||
#define _IWL_DEV_INFO(_device, _subdevice, _mac_type, _mac_step, _rf_type, \
|
||||
_rf_id, _rf_step, _no_160, _cores, _cdb, _cfg, _name) \
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
/*
|
||||
* KUnit tests for the iwlwifi device info table
|
||||
*
|
||||
* Copyright (C) 2023 Intel Corporation
|
||||
* Copyright (C) 2023-2024 Intel Corporation
|
||||
*/
|
||||
#include <kunit/test.h>
|
||||
#include <linux/pci.h>
|
||||
#include "iwl-drv.h"
|
||||
#include "iwl-config.h"
|
||||
|
||||
|
|
@ -41,8 +42,31 @@ static void devinfo_table_order(struct kunit *test)
|
|||
}
|
||||
}
|
||||
|
||||
static void devinfo_pci_ids(struct kunit *test)
|
||||
{
|
||||
struct pci_dev *dev;
|
||||
|
||||
dev = kunit_kmalloc(test, sizeof(*dev), GFP_KERNEL);
|
||||
KUNIT_ASSERT_NOT_NULL(test, dev);
|
||||
|
||||
for (int i = 0; iwl_hw_card_ids[i].vendor; i++) {
|
||||
const struct pci_device_id *s, *t;
|
||||
|
||||
s = &iwl_hw_card_ids[i];
|
||||
dev->vendor = s->vendor;
|
||||
dev->device = s->device;
|
||||
dev->subsystem_vendor = s->subvendor;
|
||||
dev->subsystem_device = s->subdevice;
|
||||
dev->class = s->class;
|
||||
|
||||
t = pci_match_id(iwl_hw_card_ids, dev);
|
||||
KUNIT_EXPECT_PTR_EQ(test, t, s);
|
||||
}
|
||||
}
|
||||
|
||||
static struct kunit_case devinfo_test_cases[] = {
|
||||
KUNIT_CASE(devinfo_table_order),
|
||||
KUNIT_CASE(devinfo_pci_ids),
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user