drivers/mfd/si476x-prop.c

Source file repositories/reference/linux-study-clean/drivers/mfd/si476x-prop.c

File Facts

System
Linux kernel
Corpus path
drivers/mfd/si476x-prop.c
Extension
.c
Size
5496 bytes
Lines
234
Domain
Driver Families
Bucket
drivers/mfd
Inferred role
Driver Families: exported/initcall integration point
Status
integration 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 si476x_property_range {
	u16 low, high;
};

static bool si476x_core_element_is_in_array(u16 element,
					    const u16 array[],
					    size_t size)
{
	int i;

	for (i = 0; i < size; i++)
		if (element == array[i])
			return true;

	return false;
}

static bool si476x_core_element_is_in_range(u16 element,
					    const struct si476x_property_range range[],
					    size_t size)
{
	int i;

	for (i = 0; i < size; i++)
		if (element <= range[i].high && element >= range[i].low)
			return true;

	return false;
}

static bool si476x_core_is_valid_property_a10(struct si476x_core *core,
					      u16 property)
{
	static const u16 valid_properties[] = {
		0x0000,
		0x0500, 0x0501,
		0x0600,
		0x0709, 0x070C, 0x070D, 0x70E, 0x710,
		0x0718,
		0x1207, 0x1208,
		0x2007,
		0x2300,
	};

	static const struct si476x_property_range valid_ranges[] = {
		{ 0x0200, 0x0203 },
		{ 0x0300, 0x0303 },
		{ 0x0400, 0x0404 },
		{ 0x0700, 0x0707 },
		{ 0x1100, 0x1102 },
		{ 0x1200, 0x1204 },
		{ 0x1300, 0x1306 },
		{ 0x2000, 0x2005 },
		{ 0x2100, 0x2104 },
		{ 0x2106, 0x2106 },
		{ 0x2200, 0x220E },
		{ 0x3100, 0x3104 },
		{ 0x3207, 0x320F },
		{ 0x3300, 0x3304 },
		{ 0x3500, 0x3517 },
		{ 0x3600, 0x3617 },
		{ 0x3700, 0x3717 },
		{ 0x4000, 0x4003 },
	};

	return	si476x_core_element_is_in_range(property, valid_ranges,
						ARRAY_SIZE(valid_ranges)) ||
		si476x_core_element_is_in_array(property, valid_properties,
						ARRAY_SIZE(valid_properties));
}

static bool si476x_core_is_valid_property_a20(struct si476x_core *core,
					      u16 property)
{
	static const u16 valid_properties[] = {
		0x071B,
		0x1006,
		0x2210,
		0x3401,
	};

	static const struct si476x_property_range valid_ranges[] = {
		{ 0x2215, 0x2219 },
	};

	return	si476x_core_is_valid_property_a10(core, property) ||
		si476x_core_element_is_in_range(property, valid_ranges,
						ARRAY_SIZE(valid_ranges))  ||
		si476x_core_element_is_in_array(property, valid_properties,
						ARRAY_SIZE(valid_properties));

Annotation

Implementation Notes