drivers/base/regmap/regmap-kunit.c
Source file repositories/reference/linux-study-clean/drivers/base/regmap/regmap-kunit.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/regmap/regmap-kunit.c- Extension
.c- Size
- 66842 bytes
- Lines
- 2223
- Domain
- Driver Families
- Bucket
- drivers/base
- 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
kunit/device.hkunit/resource.hkunit/test.hinternal.h
Detected Declarations
struct regmap_test_privstruct regmap_test_paramfunction get_changed_bytesfunction param_to_descfunction reg_5_falsefunction reg_default_expectedfunction reg_default_test_cbfunction expect_reg_default_valuefunction basic_read_writefunction bulk_writefunction bulk_readfunction multi_writefunction multi_readfunction read_bypassedfunction read_bypassed_volatilefunction write_readonlyfunction read_writeonlyfunction reg_defaultsfunction reg_default_callback_populates_flat_cachefunction reg_defaults_read_devfunction register_patchfunction stridefunction test_range_window_volatilefunction test_range_all_volatilefunction basic_rangesfunction stress_insertfunction cache_bypassfunction cache_sync_marked_dirtyfunction cache_sync_after_cache_onlyfunction cache_sync_defaults_marked_dirtyfunction cache_sync_default_after_cache_onlyfunction cache_sync_readonlyfunction cache_sync_patchfunction cache_dropfunction cache_drop_with_non_contiguous_rangesfunction cache_drop_all_and_sync_marked_dirtyfunction cache_drop_all_and_sync_no_defaultsfunction cache_drop_all_and_sync_has_defaultsfunction cache_presentfunction cache_write_zerofunction cache_range_window_regfunction raw_read_defaults_singlefunction raw_read_defaultsfunction raw_write_read_singlefunction raw_writefunction reg_zerofunction ram_reg_zerofunction raw_noinc_write
Annotated Snippet
struct regmap_test_priv {
struct device *dev;
bool *reg_default_called;
unsigned int reg_default_max;
};
struct regmap_test_param {
enum regcache_type cache;
enum regmap_endian val_endian;
unsigned int from_reg;
bool fast_io;
};
static void get_changed_bytes(void *orig, void *new, size_t size)
{
char *o = orig;
char *n = new;
int i;
get_random_bytes(new, size);
/*
* This could be nicer and more efficient but we shouldn't
* super care.
*/
for (i = 0; i < size; i++)
while (n[i] == o[i])
get_random_bytes(&n[i], 1);
}
static const struct regmap_config test_regmap_config = {
.reg_stride = 1,
.val_bits = sizeof(unsigned int) * 8,
};
static const char *regcache_type_name(enum regcache_type type)
{
switch (type) {
case REGCACHE_NONE:
return "none";
case REGCACHE_FLAT:
return "flat";
case REGCACHE_FLAT_S:
return "flat-sparse";
case REGCACHE_RBTREE:
return "rbtree";
case REGCACHE_MAPLE:
return "maple";
default:
return NULL;
}
}
static const char *regmap_endian_name(enum regmap_endian endian)
{
switch (endian) {
case REGMAP_ENDIAN_BIG:
return "big";
case REGMAP_ENDIAN_LITTLE:
return "little";
case REGMAP_ENDIAN_DEFAULT:
return "default";
case REGMAP_ENDIAN_NATIVE:
return "native";
default:
return NULL;
}
}
static void param_to_desc(const struct regmap_test_param *param, char *desc)
{
snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s-%s%s @%#x",
regcache_type_name(param->cache),
regmap_endian_name(param->val_endian),
param->fast_io ? " fast I/O" : "",
param->from_reg);
}
static const struct regmap_test_param regcache_types_list[] = {
{ .cache = REGCACHE_NONE },
{ .cache = REGCACHE_NONE, .fast_io = true },
{ .cache = REGCACHE_FLAT },
{ .cache = REGCACHE_FLAT, .fast_io = true },
{ .cache = REGCACHE_FLAT_S },
{ .cache = REGCACHE_FLAT_S, .fast_io = true },
{ .cache = REGCACHE_RBTREE },
{ .cache = REGCACHE_RBTREE, .fast_io = true },
{ .cache = REGCACHE_MAPLE },
{ .cache = REGCACHE_MAPLE, .fast_io = true },
Annotation
- Immediate include surface: `kunit/device.h`, `kunit/resource.h`, `kunit/test.h`, `internal.h`.
- Detected declarations: `struct regmap_test_priv`, `struct regmap_test_param`, `function get_changed_bytes`, `function param_to_desc`, `function reg_5_false`, `function reg_default_expected`, `function reg_default_test_cb`, `function expect_reg_default_value`, `function basic_read_write`, `function bulk_write`.
- Atlas domain: Driver Families / drivers/base.
- 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.