drivers/base/regmap/regmap-spmi.c
Source file repositories/reference/linux-study-clean/drivers/base/regmap/regmap-spmi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/base/regmap/regmap-spmi.c- Extension
.c- Size
- 5136 bytes
- Lines
- 227
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/regmap.hlinux/spmi.hlinux/module.hlinux/init.h
Detected Declarations
function regmap_spmi_base_readfunction regmap_spmi_base_gather_writefunction regmap_spmi_base_writefunction regmap_spmi_ext_readfunction regmap_spmi_ext_gather_writefunction regmap_spmi_ext_writeexport __regmap_init_spmi_baseexport __devm_regmap_init_spmi_baseexport __regmap_init_spmi_extexport __devm_regmap_init_spmi_ext
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
//
// Register map access API - SPMI support
//
// Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
//
// Based on regmap-i2c.c:
// Copyright 2011 Wolfson Microelectronics plc
// Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
#include <linux/regmap.h>
#include <linux/spmi.h>
#include <linux/module.h>
#include <linux/init.h>
static int regmap_spmi_base_read(void *context,
const void *reg, size_t reg_size,
void *val, size_t val_size)
{
u8 addr = *(u8 *)reg;
int err = 0;
BUG_ON(reg_size != 1);
while (val_size-- && !err)
err = spmi_register_read(context, addr++, val++);
return err;
}
static int regmap_spmi_base_gather_write(void *context,
const void *reg, size_t reg_size,
const void *val, size_t val_size)
{
const u8 *data = val;
u8 addr = *(u8 *)reg;
int err = 0;
BUG_ON(reg_size != 1);
/*
* SPMI defines a more bandwidth-efficient 'Register 0 Write' sequence,
* use it when possible.
*/
if (addr == 0 && val_size) {
err = spmi_register_zero_write(context, *data);
if (err)
goto err_out;
data++;
addr++;
val_size--;
}
while (val_size) {
err = spmi_register_write(context, addr, *data);
if (err)
goto err_out;
data++;
addr++;
val_size--;
}
err_out:
return err;
}
static int regmap_spmi_base_write(void *context, const void *data,
size_t count)
{
BUG_ON(count < 1);
return regmap_spmi_base_gather_write(context, data, 1, data + 1,
count - 1);
}
static const struct regmap_bus regmap_spmi_base = {
.read = regmap_spmi_base_read,
.write = regmap_spmi_base_write,
.gather_write = regmap_spmi_base_gather_write,
.reg_format_endian_default = REGMAP_ENDIAN_NATIVE,
.val_format_endian_default = REGMAP_ENDIAN_NATIVE,
};
struct regmap *__regmap_init_spmi_base(struct spmi_device *sdev,
const struct regmap_config *config,
struct lock_class_key *lock_key,
const char *lock_name)
{
return __regmap_init(&sdev->dev, ®map_spmi_base, sdev, config,
Annotation
- Immediate include surface: `linux/regmap.h`, `linux/spmi.h`, `linux/module.h`, `linux/init.h`.
- Detected declarations: `function regmap_spmi_base_read`, `function regmap_spmi_base_gather_write`, `function regmap_spmi_base_write`, `function regmap_spmi_ext_read`, `function regmap_spmi_ext_gather_write`, `function regmap_spmi_ext_write`, `export __regmap_init_spmi_base`, `export __devm_regmap_init_spmi_base`, `export __regmap_init_spmi_ext`, `export __devm_regmap_init_spmi_ext`.
- Atlas domain: Driver Families / drivers/base.
- Implementation status: integration 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.