drivers/net/wireless/intel/iwlwifi/tests/utils.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/intel/iwlwifi/tests/utils.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/intel/iwlwifi/tests/utils.c- Extension
.c- Size
- 2520 bytes
- Lines
- 110
- 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
../iwl-utils.hkunit/test.h
Detected Declarations
function test_average_neg_db
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* KUnit tests for utilities
*
* Copyright (C) 2024-2025 Intel Corporation
*/
#include "../iwl-utils.h"
#include <kunit/test.h>
MODULE_IMPORT_NS("IWLWIFI");
static const struct average_neg_db_case {
const char *desc;
u8 neg_dbm[22];
s8 result;
} average_neg_db_cases[] = {
{
.desc = "Smallest possible value, all filled",
.neg_dbm = {
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
128, 128
},
.result = -128,
},
{
.desc = "Biggest possible value, all filled",
.neg_dbm = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
},
.result = 0,
},
{
.desc = "Smallest possible value, partial filled",
.neg_dbm = {
128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff,
},
.result = -128,
},
{
.desc = "Biggest possible value, partial filled",
.neg_dbm = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff,
},
.result = 0,
},
{
.desc = "Adding -80dBm to -75dBm until it is still rounded to -79dBm",
.neg_dbm = {
75, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 0xff, 0xff, 0xff,
0xff, 0xff,
},
.result = -79,
},
{
.desc = "Adding -80dBm to -75dBm until it is just rounded to -80dBm",
.neg_dbm = {
75, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 80, 0xff, 0xff,
0xff, 0xff,
},
.result = -80,
},
};
KUNIT_ARRAY_PARAM_DESC(average_neg_db, average_neg_db_cases, desc)
static void test_average_neg_db(struct kunit *test)
{
const struct average_neg_db_case *params = test->param_value;
u8 reversed[ARRAY_SIZE(params->neg_dbm)];
int i;
/* Test the values in the given order */
KUNIT_ASSERT_EQ(test,
iwl_average_neg_dbm(params->neg_dbm,
ARRAY_SIZE(params->neg_dbm)),
params->result);
/* Test in reverse order */
for (i = 0; i < ARRAY_SIZE(params->neg_dbm); i++)
Annotation
- Immediate include surface: `../iwl-utils.h`, `kunit/test.h`.
- Detected declarations: `function test_average_neg_db`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.