drivers/iio/adc/max11205.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/max11205.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/max11205.c- Extension
.c- Size
- 4336 bytes
- Lines
- 181
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/module.hlinux/regulator/consumer.hlinux/spi/spi.hlinux/iio/iio.hlinux/iio/adc/ad_sigma_delta.h
Detected Declarations
struct max11205_chip_infostruct max11205_stateenum max11205_chip_typefunction max11205_read_rawfunction max11205_reg_disablefunction max11205_probe
Annotated Snippet
struct max11205_chip_info {
unsigned int out_data_rate;
const char *name;
};
struct max11205_state {
const struct max11205_chip_info *chip_info;
struct regulator *vref;
struct ad_sigma_delta sd;
};
static const struct ad_sigma_delta_info max11205_sigma_delta_info = {
.has_registers = false,
};
static int max11205_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
struct max11205_state *st = iio_priv(indio_dev);
int reg_mv;
switch (mask) {
case IIO_CHAN_INFO_RAW:
return ad_sigma_delta_single_conversion(indio_dev, chan, val);
case IIO_CHAN_INFO_SCALE:
reg_mv = regulator_get_voltage(st->vref);
if (reg_mv < 0)
return reg_mv;
reg_mv /= 1000;
*val = reg_mv;
*val2 = MAX11205_BIT_SCALE;
return IIO_VAL_FRACTIONAL_LOG2;
case IIO_CHAN_INFO_SAMP_FREQ:
*val = st->chip_info->out_data_rate;
return IIO_VAL_INT;
default:
return -EINVAL;
}
}
static const struct iio_info max11205_iio_info = {
.read_raw = max11205_read_raw,
.validate_trigger = ad_sd_validate_trigger,
};
static const struct iio_chan_spec max11205_channels[] = {
{
.type = IIO_VOLTAGE,
.indexed = 1,
.scan_type = {
.sign = 's',
.realbits = 16,
.storagebits = 16,
.endianness = IIO_BE,
},
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_SAMP_FREQ) |
BIT(IIO_CHAN_INFO_SCALE),
},
};
static const struct max11205_chip_info max11205_chip_info[] = {
[TYPE_MAX11205A] = {
.out_data_rate = MAX11205A_OUT_DATA_RATE,
.name = "max11205a",
},
[TYPE_MAX11205B] = {
.out_data_rate = MAX11205B_OUT_DATA_RATE,
.name = "max11205b",
},
};
static void max11205_reg_disable(void *reg)
{
regulator_disable(reg);
}
static int max11205_probe(struct spi_device *spi)
{
struct max11205_state *st;
struct iio_dev *indio_dev;
int ret;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
st = iio_priv(indio_dev);
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/regulator/consumer.h`, `linux/spi/spi.h`, `linux/iio/iio.h`, `linux/iio/adc/ad_sigma_delta.h`.
- Detected declarations: `struct max11205_chip_info`, `struct max11205_state`, `enum max11205_chip_type`, `function max11205_read_raw`, `function max11205_reg_disable`, `function max11205_probe`.
- Atlas domain: Driver Families / drivers/iio.
- 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.