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.
- 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
linux/module.hlinux/slab.hlinux/string.hlinux/wmi.hkunit/resource.hkunit/test.hasm/byteorder.h
Detected Declarations
struct wmi_string_paramfunction wmi_string_param_get_descfunction wmi_string_to_utf8s_testfunction wmi_string_from_utf8s_testfunction wmi_string_to_utf8s_padded_testfunction wmi_string_from_utf8s_padded_testfunction wmi_string_to_utf8s_oversized_testfunction wmi_string_from_utf8s_oversized_testfunction wmi_string_to_utf8s_invalid_testfunction wmi_string_from_utf8s_invalid_test
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
- Immediate include surface: `linux/module.h`, `linux/slab.h`, `linux/string.h`, `linux/wmi.h`, `kunit/resource.h`, `kunit/test.h`, `asm/byteorder.h`.
- Detected declarations: `struct wmi_string_param`, `function wmi_string_param_get_desc`, `function wmi_string_to_utf8s_test`, `function wmi_string_from_utf8s_test`, `function wmi_string_to_utf8s_padded_test`, `function wmi_string_from_utf8s_padded_test`, `function wmi_string_to_utf8s_oversized_test`, `function wmi_string_from_utf8s_oversized_test`, `function wmi_string_to_utf8s_invalid_test`, `function wmi_string_from_utf8s_invalid_test`.
- Atlas domain: Driver Families / drivers/platform.
- 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.