drivers/iio/potentiometer/mcp4131.c
Source file repositories/reference/linux-study-clean/drivers/iio/potentiometer/mcp4131.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/potentiometer/mcp4131.c- Extension
.c- Size
- 15149 bytes
- Lines
- 492
- Domain
- Driver Families
- Bucket
- drivers/iio
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/cache.hlinux/err.hlinux/iio/iio.hlinux/iio/types.hlinux/module.hlinux/mod_devicetable.hlinux/mutex.hlinux/property.hlinux/spi/spi.h
Detected Declarations
struct mcp4131_cfgstruct mcp4131_dataenum mcp4131_typefunction mcp4131_readfunction mcp4131_read_rawfunction mcp4131_write_rawfunction mcp4131_probe
Annotated Snippet
struct mcp4131_cfg {
int wipers;
int max_pos;
int kohms;
};
enum mcp4131_type {
MCP413x_502 = 0,
MCP413x_103,
MCP413x_503,
MCP413x_104,
MCP414x_502,
MCP414x_103,
MCP414x_503,
MCP414x_104,
MCP415x_502,
MCP415x_103,
MCP415x_503,
MCP415x_104,
MCP416x_502,
MCP416x_103,
MCP416x_503,
MCP416x_104,
MCP423x_502,
MCP423x_103,
MCP423x_503,
MCP423x_104,
MCP424x_502,
MCP424x_103,
MCP424x_503,
MCP424x_104,
MCP425x_502,
MCP425x_103,
MCP425x_503,
MCP425x_104,
MCP426x_502,
MCP426x_103,
MCP426x_503,
MCP426x_104,
};
static const struct mcp4131_cfg mcp4131_cfg[] = {
[MCP413x_502] = { .wipers = 1, .max_pos = 128, .kohms = 5, },
[MCP413x_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, },
[MCP413x_503] = { .wipers = 1, .max_pos = 128, .kohms = 50, },
[MCP413x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, },
[MCP414x_502] = { .wipers = 1, .max_pos = 128, .kohms = 5, },
[MCP414x_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, },
[MCP414x_503] = { .wipers = 1, .max_pos = 128, .kohms = 50, },
[MCP414x_104] = { .wipers = 1, .max_pos = 128, .kohms = 100, },
[MCP415x_502] = { .wipers = 1, .max_pos = 256, .kohms = 5, },
[MCP415x_103] = { .wipers = 1, .max_pos = 256, .kohms = 10, },
[MCP415x_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, },
[MCP415x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, },
[MCP416x_502] = { .wipers = 1, .max_pos = 256, .kohms = 5, },
[MCP416x_103] = { .wipers = 1, .max_pos = 256, .kohms = 10, },
[MCP416x_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, },
[MCP416x_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, },
[MCP423x_502] = { .wipers = 2, .max_pos = 128, .kohms = 5, },
[MCP423x_103] = { .wipers = 2, .max_pos = 128, .kohms = 10, },
[MCP423x_503] = { .wipers = 2, .max_pos = 128, .kohms = 50, },
[MCP423x_104] = { .wipers = 2, .max_pos = 128, .kohms = 100, },
[MCP424x_502] = { .wipers = 2, .max_pos = 128, .kohms = 5, },
[MCP424x_103] = { .wipers = 2, .max_pos = 128, .kohms = 10, },
[MCP424x_503] = { .wipers = 2, .max_pos = 128, .kohms = 50, },
[MCP424x_104] = { .wipers = 2, .max_pos = 128, .kohms = 100, },
[MCP425x_502] = { .wipers = 2, .max_pos = 256, .kohms = 5, },
[MCP425x_103] = { .wipers = 2, .max_pos = 256, .kohms = 10, },
[MCP425x_503] = { .wipers = 2, .max_pos = 256, .kohms = 50, },
[MCP425x_104] = { .wipers = 2, .max_pos = 256, .kohms = 100, },
[MCP426x_502] = { .wipers = 2, .max_pos = 256, .kohms = 5, },
[MCP426x_103] = { .wipers = 2, .max_pos = 256, .kohms = 10, },
[MCP426x_503] = { .wipers = 2, .max_pos = 256, .kohms = 50, },
[MCP426x_104] = { .wipers = 2, .max_pos = 256, .kohms = 100, },
};
struct mcp4131_data {
struct spi_device *spi;
const struct mcp4131_cfg *cfg;
struct mutex lock;
u8 buf[2] __aligned(IIO_DMA_MINALIGN);
};
#define MCP4131_CHANNEL(ch) { \
.type = IIO_RESISTANCE, \
.indexed = 1, \
.output = 1, \
.channel = (ch), \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
Annotation
- Immediate include surface: `linux/cache.h`, `linux/err.h`, `linux/iio/iio.h`, `linux/iio/types.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/mutex.h`, `linux/property.h`.
- Detected declarations: `struct mcp4131_cfg`, `struct mcp4131_data`, `enum mcp4131_type`, `function mcp4131_read`, `function mcp4131_read_raw`, `function mcp4131_write_raw`, `function mcp4131_probe`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.