drivers/irqchip/irq-ast2700-intc0-test.c

Source file repositories/reference/linux-study-clean/drivers/irqchip/irq-ast2700-intc0-test.c

File Facts

System
Linux kernel
Corpus path
drivers/irqchip/irq-ast2700-intc0-test.c
Extension
.c
Size
11076 bytes
Lines
474
Domain
Driver Families
Bucket
drivers/irqchip
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

// SPDX-License-Identifier: GPL-2.0-only
/*
 *  Copyright (C) 2026 Code Construct
 */
#include <kunit/test.h>

#include "irq-ast2700.h"

static void aspeed_intc0_resolve_route_bad_args(struct kunit *test)
{
	static const struct aspeed_intc_interrupt_range c1ranges[] = { 0 };
	static const u32 c1outs[] = { 0 };
	struct aspeed_intc_interrupt_range resolved;
	const struct irq_domain c0domain = { 0 };
	int rc;

	rc = aspeed_intc0_resolve_route(NULL, 0, c1outs, 0, c1ranges, NULL);
	KUNIT_EXPECT_EQ(test, rc, -EINVAL);

	rc = aspeed_intc0_resolve_route(&c0domain, 0, c1outs,
					ARRAY_SIZE(c1ranges), c1ranges,
					&resolved);
	KUNIT_EXPECT_EQ(test, rc, -ENOENT);

	rc = aspeed_intc0_resolve_route(&c0domain, ARRAY_SIZE(c1outs), c1outs,
					0, c1ranges, &resolved);
	KUNIT_EXPECT_EQ(test, rc, -ENOENT);
}

static int gicv3_fwnode_read_string_array(const struct fwnode_handle *fwnode,
					  const char *propname, const char **val, size_t nval)
{
	if (!propname)
		return -EINVAL;

	if (!val)
		return 1;

	if (WARN_ON(nval != 1))
		return -EOVERFLOW;

	*val = "arm,gic-v3";
	return 1;
}

static const struct fwnode_operations arm_gicv3_fwnode_ops = {
	.property_read_string_array = gicv3_fwnode_read_string_array,
};

static void aspeed_intc_resolve_route_invalid_c0domain(struct kunit *test)
{
	struct device_node intc0_node = {
		.fwnode = { .ops = &arm_gicv3_fwnode_ops },
	};
	const struct irq_domain c0domain = { .fwnode = &intc0_node.fwnode };
	static const struct aspeed_intc_interrupt_range c1ranges[] = { 0 };
	static const u32 c1outs[] = { 0 };
	struct aspeed_intc_interrupt_range resolved;
	int rc;

	rc = aspeed_intc0_resolve_route(&c0domain, ARRAY_SIZE(c1outs), c1outs,
					ARRAY_SIZE(c1ranges), c1ranges,
					&resolved);
	KUNIT_EXPECT_NE(test, rc, 0);
}

static int
aspeed_intc0_fwnode_read_string_array(const struct fwnode_handle *fwnode_handle,
				      const char *propname, const char **val,
				      size_t nval)
{
	if (!propname)
		return -EINVAL;

	if (!val)
		return 1;

	if (WARN_ON(nval != 1))
		return -EOVERFLOW;

	*val = "aspeed,ast2700-intc0";
	return nval;
}

static const struct fwnode_operations intc0_fwnode_ops = {
	.property_read_string_array = aspeed_intc0_fwnode_read_string_array,
};

static void
aspeed_intc0_resolve_route_c1i1o1c0i1o1_connected(struct kunit *test)

Annotation

Implementation Notes