drivers/platform/wmi/tests/string_kunit.c

Source file repositories/reference/linux-study-clean/drivers/platform/wmi/tests/string_kunit.c

File Facts

System
Linux kernel
Corpus path
drivers/platform/wmi/tests/string_kunit.c
Extension
.c
Size
8209 bytes
Lines
297
Domain
Driver Families
Bucket
drivers/platform
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 wmi_string_param {
	const char *name;
	const struct wmi_string *wmi_string;
	/*
	 * Remember that using sizeof() on a struct wmi_string will
	 * always return a size of two bytes due to the flexible
	 * array member!
	 */
	size_t wmi_string_length;
	const u8 *utf8_string;
	size_t utf8_string_length;
};

#define TEST_WMI_STRING_LENGTH 12

static const struct wmi_string test_wmi_string = {
	.length = cpu_to_le16(10),
	.chars = {
		cpu_to_le16(u'T'),
		cpu_to_le16(u'E'),
		cpu_to_le16(u'S'),
		cpu_to_le16(u'T'),
		cpu_to_le16(u'\0'),
	},
};

static const u8 test_utf8_string[] = "TEST";

#define SPECIAL_WMI_STRING_LENGTH 14

static const struct wmi_string special_wmi_string = {
	.length = cpu_to_le16(12),
	.chars = {
		cpu_to_le16(u'Ä'),
		cpu_to_le16(u'Ö'),
		cpu_to_le16(u'Ü'),
		cpu_to_le16(u'ß'),
		cpu_to_le16(u'€'),
		cpu_to_le16(u'\0'),
	},
};

static const u8 special_utf8_string[] = "ÄÖÜ߀";

#define MULTI_POINT_WMI_STRING_LENGTH 12

static const struct wmi_string multi_point_wmi_string = {
	.length = cpu_to_le16(10),
	.chars = {
		cpu_to_le16(u'K'),
		/* 🐧 */
		cpu_to_le16(0xD83D),
		cpu_to_le16(0xDC27),
		cpu_to_le16(u'!'),
		cpu_to_le16(u'\0'),
	},
};

static const u8 multi_point_utf8_string[] = "K🐧!";

#define PADDED_TEST_WMI_STRING_LENGTH 14

static const struct wmi_string padded_test_wmi_string = {
	.length = cpu_to_le16(12),
	.chars = {
		cpu_to_le16(u'T'),
		cpu_to_le16(u'E'),
		cpu_to_le16(u'S'),
		cpu_to_le16(u'T'),
		cpu_to_le16(u'\0'),
		cpu_to_le16(u'\0'),
	},
};

static const u8 padded_test_utf8_string[] = "TEST\0";

#define OVERSIZED_TEST_WMI_STRING_LENGTH 14

static const struct wmi_string oversized_test_wmi_string = {
	.length = cpu_to_le16(8),
	.chars = {
		cpu_to_le16(u'T'),
		cpu_to_le16(u'E'),
		cpu_to_le16(u'S'),
		cpu_to_le16(u'T'),
		cpu_to_le16(u'!'),
		cpu_to_le16(u'\0'),
	},
};

Annotation

Implementation Notes