drivers/of/of_test.c

Source file repositories/reference/linux-study-clean/drivers/of/of_test.c

File Facts

System
Linux kernel
Corpus path
drivers/of/of_test.c
Extension
.c
Size
3922 bytes
Lines
179
Domain
Driver Families
Bucket
drivers/of
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

struct of_address_resource_bounds_case {
	u64 start;
	u64 size;
	int ret;

	u64 res_start;
	u64 res_end;
};

static void of_address_resource_bounds_case_desc(const struct of_address_resource_bounds_case *p,
						 char *name)
{
	snprintf(name, KUNIT_PARAM_DESC_SIZE, "start=0x%016llx,size=0x%016llx", p->start, p->size);
}

static const struct of_address_resource_bounds_case of_address_resource_bounds_cases[] = {
	{
		.start = 0,
		.size = 0,
		.ret = 0,
		.res_start = 0,
		.res_end = -1,
	},
	{
		.start = 0,
		.size = 0x1000,
		.ret = 0,
		.res_start = 0,
		.res_end = 0xfff,
	},
	{
		.start = 0x1000,
		.size = 0,
		.ret = 0,
		.res_start = 0x1000,
		.res_end = 0xfff,
	},
	{
		.start = 0x1000,
		.size = 0x1000,
		.ret = 0,
		.res_start = 0x1000,
		.res_end = 0x1fff,
	},
	{
		.start = 1,
		.size = RESOURCE_SIZE_MAX,
		.ret = 0,
		.res_start = 1,
		.res_end = RESOURCE_SIZE_MAX,
	},
	{
		.start = RESOURCE_SIZE_MAX,
		.size = 1,
		.ret = 0,
		.res_start = RESOURCE_SIZE_MAX,
		.res_end = RESOURCE_SIZE_MAX,
	},
	{
		.start = 2,
		.size = RESOURCE_SIZE_MAX,
		.ret = -EOVERFLOW,
	},
	{
		.start = RESOURCE_SIZE_MAX,
		.size = 2,
		.ret = -EOVERFLOW,
	},
	{
		.start = ULL(0x100000000),
		.size = 1,
		.ret = sizeof(resource_size_t) > sizeof(u32) ? 0 : -EOVERFLOW,
		.res_start = ULL(0x100000000),
		.res_end = ULL(0x100000000),
	},
	{
		.start = 0x1000,
		.size = 0xffffffff,
		.ret = sizeof(resource_size_t) > sizeof(u32) ? 0 : -EOVERFLOW,
		.res_start = 0x1000,
		.res_end = ULL(0x100000ffe),
	},
};

KUNIT_ARRAY_PARAM(of_address_resource_bounds,
		  of_address_resource_bounds_cases, of_address_resource_bounds_case_desc);

static void of_address_resource_bounds(struct kunit *test)
{
	const struct of_address_resource_bounds_case *param = test->param_value;

Annotation

Implementation Notes