drivers/base/regmap/regmap.c
Source file repositories/reference/linux-study-clean/drivers/base/regmap/regmap.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/regmap/regmap.c- Extension
.c- Size
- 88082 bytes
- Lines
- 3552
- Domain
- Driver Families
- Bucket
- drivers/base
- 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.
- 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/device.hlinux/slab.hlinux/export.hlinux/mutex.hlinux/err.hlinux/property.hlinux/rbtree.hlinux/sched.hlinux/delay.hlinux/log2.hlinux/hwspinlock.hlinux/unaligned.htrace.hinternal.h
Detected Declarations
function regmap_should_logfunction regmap_should_logfunction regmap_reg_in_rangesfunction regmap_check_range_tablefunction regmap_writeablefunction regmap_cachedfunction regmap_readablefunction regmap_volatilefunction regmap_preciousfunction regmap_writeable_noincfunction regmap_readable_noincfunction regmap_volatile_rangefunction regmap_format_12_20_writefunction regmap_format_2_6_writefunction regmap_format_4_12_writefunction regmap_format_7_9_writefunction regmap_format_7_17_writefunction regmap_format_10_14_writefunction regmap_format_8function regmap_format_16_befunction regmap_format_16_lefunction regmap_format_16_nativefunction regmap_format_24_befunction regmap_format_32_befunction regmap_format_32_lefunction regmap_format_32_nativefunction regmap_parse_inplace_noopfunction regmap_parse_16_befunction regmap_parse_16_lefunction regmap_parse_16_be_inplacefunction regmap_parse_16_le_inplacefunction regmap_parse_16_nativefunction regmap_parse_24_befunction regmap_parse_32_befunction regmap_parse_32_lefunction regmap_parse_32_be_inplacefunction regmap_parse_32_le_inplacefunction regmap_parse_32_nativefunction regmap_lock_hwlockfunction regmap_lock_hwlock_irqfunction regmap_lock_hwlock_irqsavefunction regmap_unlock_hwlockfunction regmap_unlock_hwlock_irqfunction regmap_unlock_hwlock_irqrestorefunction regmap_lock_unlock_nonefunction regmap_unlock_mutexfunction regmap_lock_spinlockfunction regmap_unlock_spinlock
Annotated Snippet
static inline bool regmap_should_log(struct regmap *map) { return false; }
#endif
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
unsigned int mask, unsigned int val,
bool *change, bool force_write);
static int _regmap_bus_reg_read(void *context, unsigned int reg,
unsigned int *val);
static int _regmap_bus_read(void *context, unsigned int reg,
unsigned int *val);
static int _regmap_bus_formatted_write(void *context, unsigned int reg,
unsigned int val);
static int _regmap_bus_reg_write(void *context, unsigned int reg,
unsigned int val);
static int _regmap_bus_raw_write(void *context, unsigned int reg,
unsigned int val);
bool regmap_reg_in_ranges(unsigned int reg,
const struct regmap_range *ranges,
unsigned int nranges)
{
const struct regmap_range *r;
int i;
for (i = 0, r = ranges; i < nranges; i++, r++)
if (regmap_reg_in_range(reg, r))
return true;
return false;
}
EXPORT_SYMBOL_GPL(regmap_reg_in_ranges);
bool regmap_check_range_table(struct regmap *map, unsigned int reg,
const struct regmap_access_table *table)
{
/* Check "no ranges" first */
if (regmap_reg_in_ranges(reg, table->no_ranges, table->n_no_ranges))
return false;
/* In case zero "yes ranges" are supplied, any reg is OK */
if (!table->n_yes_ranges)
return true;
return regmap_reg_in_ranges(reg, table->yes_ranges,
table->n_yes_ranges);
}
EXPORT_SYMBOL_GPL(regmap_check_range_table);
bool regmap_writeable(struct regmap *map, unsigned int reg)
{
if (map->max_register_is_set && reg > map->max_register)
return false;
if (map->writeable_reg)
return map->writeable_reg(map->dev, reg);
if (map->wr_table)
return regmap_check_range_table(map, reg, map->wr_table);
return true;
}
bool regmap_cached(struct regmap *map, unsigned int reg)
{
int ret;
unsigned int val;
if (map->cache_type == REGCACHE_NONE)
return false;
if (!map->cache_ops)
return false;
if (map->max_register_is_set && reg > map->max_register)
return false;
map->lock(map->lock_arg);
ret = regcache_read(map, reg, &val);
map->unlock(map->lock_arg);
if (ret)
return false;
return true;
}
bool regmap_readable(struct regmap *map, unsigned int reg)
{
if (!map->reg_read)
return false;
Annotation
- Immediate include surface: `linux/device.h`, `linux/slab.h`, `linux/export.h`, `linux/mutex.h`, `linux/err.h`, `linux/property.h`, `linux/rbtree.h`, `linux/sched.h`.
- Detected declarations: `function regmap_should_log`, `function regmap_should_log`, `function regmap_reg_in_ranges`, `function regmap_check_range_table`, `function regmap_writeable`, `function regmap_cached`, `function regmap_readable`, `function regmap_volatile`, `function regmap_precious`, `function regmap_writeable_noinc`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.