drivers/net/wireless/intel/iwlwifi/tests/devinfo.c

Source file repositories/reference/linux-study-clean/drivers/net/wireless/intel/iwlwifi/tests/devinfo.c

File Facts

System
Linux kernel
Corpus path
drivers/net/wireless/intel/iwlwifi/tests/devinfo.c
Extension
.c
Size
8703 bytes
Lines
317
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!ret) {
			iwl_pci_print_dev_info("No entry found for: ", di);
			KUNIT_FAIL(test,
				   "No entry found for entry at index %d\n", idx);
		} else if (ret != di) {
			iwl_pci_print_dev_info("searched: ", di);
			iwl_pci_print_dev_info("found:    ", ret);
			KUNIT_FAIL(test,
				   "unusable entry at index %d (found index %d instead)\n",
				   idx, (int)(ret - iwl_dev_info_table));
		}
	}
}

static void devinfo_discrete_match(struct kunit *test)
{
	/*
	 * Validate that any entries with discrete/integrated match have
	 * the same config with the value inverted (if they match at all.)
	 */

	for (int idx = 0; idx < iwl_dev_info_table_size; idx++) {
		const struct iwl_dev_info *di = &iwl_dev_info_table[idx];
		const struct iwl_dev_info *ret;

		if (!di->match_discrete)
			continue;

		ret = iwl_pci_find_dev_info(di->device, di->subdevice,
					    di->rf_type, di->cdb,
					    di->rf_id, di->bw_limit,
					    !di->discrete);
		if (!ret)
			continue;
		KUNIT_EXPECT_PTR_EQ(test, di->cfg, ret->cfg);
		/* and check the name is different, that'd be the point of it */
		KUNIT_EXPECT_NE(test, strcmp(di->name, ret->name), 0);
	}
}

static void devinfo_names(struct kunit *test)
{
	int idx;

	for (idx = 0; idx < iwl_dev_info_table_size; idx++) {
		const struct iwl_dev_info *di = &iwl_dev_info_table[idx];

		KUNIT_ASSERT_TRUE(test, di->name);
	}
}

static void devinfo_no_cfg_dups(struct kunit *test)
{
	for (int i = 0; i < iwl_dev_info_table_size; i++) {
		const struct iwl_rf_cfg *cfg_i = iwl_dev_info_table[i].cfg;

		for (int j = 0; j < i; j++) {
			const struct iwl_rf_cfg *cfg_j = iwl_dev_info_table[j].cfg;

			if (cfg_i == cfg_j)
				continue;

			KUNIT_EXPECT_NE_MSG(test, memcmp(cfg_i, cfg_j,
							 sizeof(*cfg_i)), 0,
					    "identical configs: %ps and %ps\n",
					    cfg_i, cfg_j);
		}
	}
}

static void devinfo_no_name_dups(struct kunit *test)
{
	for (int i = 0; i < iwl_dev_info_table_size; i++) {
		for (int j = 0; j < i; j++) {
			if (iwl_dev_info_table[i].name == iwl_dev_info_table[j].name)
				continue;

			KUNIT_EXPECT_NE_MSG(test,
					    strcmp(iwl_dev_info_table[i].name,
						   iwl_dev_info_table[j].name),
					    0,
					    "name dup: %ps/%ps",
					    iwl_dev_info_table[i].name,
					    iwl_dev_info_table[j].name);
		}
	}
}

static void devinfo_check_subdev_match(struct kunit *test)
{

Annotation

Implementation Notes