drivers/iio/adc/max11410.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/max11410.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/max11410.c- Extension
.c- Size
- 27104 bytes
- Lines
- 1047
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/delay.hlinux/device.hlinux/err.hlinux/interrupt.hlinux/kernel.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/unaligned.hlinux/iio/buffer.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.h
Detected Declarations
struct max11410_channel_configstruct max11410_stateenum max11410_filterfunction max11410_reg_sizefunction max11410_write_regfunction max11410_read_regfunction max11410_notch_en_showfunction max11410_notch_en_storefunction in_voltage_filter2_notch_center_showfunction max11410_set_input_muxfunction max11410_configure_channelfunction max11410_samplefunction max11410_get_scalefunction max11410_read_rawfunction __max11410_write_samp_freqfunction max11410_write_rawfunction max11410_read_availfunction max11410_trigger_handlerfunction max11410_buffer_postenablefunction max11410_buffer_predisablefunction max11410_interruptfunction max11410_parse_channelsfunction device_for_each_child_node_scopedfunction max11410_disable_regfunction max11410_init_vreffunction max11410_calibratefunction max11410_self_calibratefunction max11410_probe
Annotated Snippet
struct max11410_channel_config {
u32 settling_time_us;
u32 *scale_avail;
u8 refsel;
u8 sig_path;
u8 gain;
bool bipolar;
bool buffered_vrefp;
bool buffered_vrefn;
};
struct max11410_state {
struct spi_device *spi_dev;
struct iio_trigger *trig;
struct completion completion;
struct mutex lock; /* Prevent changing channel config during sampling */
struct regmap *regmap;
struct regulator *avdd;
struct regulator *vrefp[3];
struct regulator *vrefn[3];
struct max11410_channel_config *channels;
int irq;
struct {
u32 data __aligned(IIO_DMA_MINALIGN);
aligned_s64 ts;
} scan;
};
static const struct iio_chan_spec chanspec_template = {
.type = IIO_VOLTAGE,
.indexed = 1,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SCALE) |
BIT(IIO_CHAN_INFO_OFFSET),
.info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ),
.info_mask_shared_by_all_available = BIT(IIO_CHAN_INFO_SAMP_FREQ),
.scan_type = {
.sign = 's',
.realbits = 24,
.storagebits = 32,
.endianness = IIO_LE,
},
};
static unsigned int max11410_reg_size(unsigned int reg)
{
/* Registers from 0x00 to 0x10 are 1 byte, the rest are 3 bytes long. */
return reg <= 0x10 ? 1 : 3;
}
static int max11410_write_reg(struct max11410_state *st, unsigned int reg,
unsigned int val)
{
/* This driver only needs to write 8-bit registers */
if (max11410_reg_size(reg) != 1)
return -EINVAL;
return regmap_write(st->regmap, reg, val);
}
static int max11410_read_reg(struct max11410_state *st, unsigned int reg,
int *val)
{
int ret;
if (max11410_reg_size(reg) == 3) {
ret = regmap_bulk_read(st->regmap, reg, &st->scan.data, 3);
if (ret)
return ret;
*val = get_unaligned_be24(&st->scan.data);
return 0;
}
return regmap_read(st->regmap, reg, val);
}
static struct regulator *max11410_get_vrefp(struct max11410_state *st,
u8 refsel)
{
refsel = refsel % 4;
if (refsel == 3)
return st->avdd;
return st->vrefp[refsel];
}
static struct regulator *max11410_get_vrefn(struct max11410_state *st,
u8 refsel)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/delay.h`, `linux/device.h`, `linux/err.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/module.h`, `linux/regmap.h`.
- Detected declarations: `struct max11410_channel_config`, `struct max11410_state`, `enum max11410_filter`, `function max11410_reg_size`, `function max11410_write_reg`, `function max11410_read_reg`, `function max11410_notch_en_show`, `function max11410_notch_en_store`, `function in_voltage_filter2_notch_center_show`, `function max11410_set_input_mux`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.