drivers/interconnect/icc-kunit.c
Source file repositories/reference/linux-study-clean/drivers/interconnect/icc-kunit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/interconnect/icc-kunit.c- Extension
.c- Size
- 8260 bytes
- Lines
- 325
- Domain
- Driver Families
- Bucket
- drivers/interconnect
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/platform_device.hkunit/test.hlinux/interconnect-provider.hlinux/interconnect.hlinux/list.hlinux/module.hlinux/overflow.hlinux/platform_device.hlinux/slab.hinternal.h
Detected Declarations
struct test_node_datastruct icc_test_privfunction icc_test_setfunction icc_test_aggregatefunction icc_test_get_bwfunction icc_test_initfunction icc_test_exitfunction icc_getfunction icc_test_destroy_pathfunction icc_test_topology_integrityfunction icc_test_set_bwfunction icc_test_aggregationfunction icc_test_bulk_ops
Annotated Snippet
struct test_node_data {
int id;
const char *name;
int num_links;
int links[2];
};
/*
* Static Topology:
* CPU -\
* -> BUS -> DDR
* GPU -/
*/
static const struct test_node_data test_topology[] = {
{ NODE_CPU, "cpu", 1, { NODE_BUS } },
{ NODE_GPU, "gpu", 1, { NODE_BUS } },
{ NODE_BUS, "bus", 1, { NODE_DDR } },
{ NODE_DDR, "ddr", 0, { } },
};
struct icc_test_priv {
struct icc_provider provider;
struct platform_device *pdev;
struct icc_node *nodes[NODE_MAX];
};
static struct icc_node *get_node(struct icc_test_priv *priv, int id)
{
int idx = id - NODE_CPU;
if (idx < 0 || idx >= ARRAY_SIZE(test_topology))
return NULL;
return priv->nodes[idx];
}
static int icc_test_set(struct icc_node *src, struct icc_node *dst)
{
return 0;
}
static int icc_test_aggregate(struct icc_node *node, u32 tag, u32 avg_bw,
u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
{
return icc_std_aggregate(node, tag, avg_bw, peak_bw, agg_avg, agg_peak);
}
static struct icc_node *icc_test_xlate(const struct of_phandle_args *spec, void *data)
{
return NULL;
}
static int icc_test_get_bw(struct icc_node *node, u32 *avg, u32 *peak)
{
*avg = 0;
*peak = 0;
return 0;
}
static int icc_test_init(struct kunit *test)
{
struct icc_test_priv *priv;
struct icc_node *node;
int i, j, ret;
priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv);
test->priv = priv;
priv->pdev = kunit_platform_device_alloc(test, "icc-test-dev", -1);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->pdev);
KUNIT_ASSERT_EQ(test, kunit_platform_device_add(test, priv->pdev), 0);
priv->provider.set = icc_test_set;
priv->provider.aggregate = icc_test_aggregate;
priv->provider.xlate = icc_test_xlate;
priv->provider.get_bw = icc_test_get_bw;
priv->provider.dev = &priv->pdev->dev;
priv->provider.data = priv;
INIT_LIST_HEAD(&priv->provider.nodes);
ret = icc_provider_register(&priv->provider);
KUNIT_ASSERT_EQ(test, ret, 0);
for (i = 0; i < ARRAY_SIZE(test_topology); i++) {
const struct test_node_data *data = &test_topology[i];
node = icc_node_create(data->id);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, node);
Annotation
- Immediate include surface: `kunit/platform_device.h`, `kunit/test.h`, `linux/interconnect-provider.h`, `linux/interconnect.h`, `linux/list.h`, `linux/module.h`, `linux/overflow.h`, `linux/platform_device.h`.
- Detected declarations: `struct test_node_data`, `struct icc_test_priv`, `function icc_test_set`, `function icc_test_aggregate`, `function icc_test_get_bw`, `function icc_test_init`, `function icc_test_exit`, `function icc_get`, `function icc_test_destroy_path`, `function icc_test_topology_integrity`.
- Atlas domain: Driver Families / drivers/interconnect.
- 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.