drivers/iio/adc/ltc2309.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ltc2309.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ltc2309.c- Extension
.c- Size
- 6743 bytes
- Lines
- 255
- 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/bitfield.hlinux/i2c.hlinux/iio/iio.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/regulator/consumer.h
Detected Declarations
struct ltc2309struct ltc2309_chip_infoenum ltc2305_channelsenum ltc2309_channelsfunction ltc2309_read_raw_channelfunction ltc2309_read_rawfunction ltc2309_probe
Annotated Snippet
struct ltc2309 {
struct device *dev;
struct i2c_client *client;
struct mutex lock; /* serialize data access */
int vref_mv;
};
/* Order matches expected channel address, See datasheet Table 1. */
enum ltc2305_channels {
LTC2305_CH0_CH1 = 0x0,
LTC2305_CH1_CH0 = 0x4,
LTC2305_CH0 = 0x8,
LTC2305_CH1 = 0xc,
};
enum ltc2309_channels {
LTC2309_CH0_CH1 = 0x0,
LTC2309_CH2_CH3 = 0x1,
LTC2309_CH4_CH5 = 0x2,
LTC2309_CH6_CH7 = 0x3,
LTC2309_CH1_CH0 = 0x4,
LTC2309_CH3_CH2 = 0x5,
LTC2309_CH5_CH4 = 0x6,
LTC2309_CH7_CH6 = 0x7,
LTC2309_CH0 = 0x8,
LTC2309_CH2 = 0x9,
LTC2309_CH4 = 0xa,
LTC2309_CH6 = 0xb,
LTC2309_CH1 = 0xc,
LTC2309_CH3 = 0xd,
LTC2309_CH5 = 0xe,
LTC2309_CH7 = 0xf,
};
#define LTC2309_CHAN(_chan, _addr) { \
.type = IIO_VOLTAGE, \
.indexed = 1, \
.address = _addr, \
.channel = _chan, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
}
#define LTC2309_DIFF_CHAN(_chan, _chan2, _addr) { \
.type = IIO_VOLTAGE, \
.differential = 1, \
.indexed = 1, \
.address = _addr, \
.channel = _chan, \
.channel2 = _chan2, \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
}
static const struct iio_chan_spec ltc2305_channels[] = {
LTC2309_CHAN(0, LTC2305_CH0),
LTC2309_CHAN(1, LTC2305_CH1),
LTC2309_DIFF_CHAN(0, 1, LTC2305_CH0_CH1),
LTC2309_DIFF_CHAN(1, 0, LTC2305_CH1_CH0),
};
static const struct iio_chan_spec ltc2309_channels[] = {
LTC2309_CHAN(0, LTC2309_CH0),
LTC2309_CHAN(1, LTC2309_CH1),
LTC2309_CHAN(2, LTC2309_CH2),
LTC2309_CHAN(3, LTC2309_CH3),
LTC2309_CHAN(4, LTC2309_CH4),
LTC2309_CHAN(5, LTC2309_CH5),
LTC2309_CHAN(6, LTC2309_CH6),
LTC2309_CHAN(7, LTC2309_CH7),
LTC2309_DIFF_CHAN(0, 1, LTC2309_CH0_CH1),
LTC2309_DIFF_CHAN(2, 3, LTC2309_CH2_CH3),
LTC2309_DIFF_CHAN(4, 5, LTC2309_CH4_CH5),
LTC2309_DIFF_CHAN(6, 7, LTC2309_CH6_CH7),
LTC2309_DIFF_CHAN(1, 0, LTC2309_CH1_CH0),
LTC2309_DIFF_CHAN(3, 2, LTC2309_CH3_CH2),
LTC2309_DIFF_CHAN(5, 4, LTC2309_CH5_CH4),
LTC2309_DIFF_CHAN(7, 6, LTC2309_CH7_CH6),
};
struct ltc2309_chip_info {
const char *name;
const struct iio_chan_spec *channels;
int num_channels;
};
static const struct ltc2309_chip_info ltc2305_chip_info = {
.name = "ltc2305",
.channels = ltc2305_channels,
.num_channels = ARRAY_SIZE(ltc2305_channels),
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/i2c.h`, `linux/iio/iio.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct ltc2309`, `struct ltc2309_chip_info`, `enum ltc2305_channels`, `enum ltc2309_channels`, `function ltc2309_read_raw_channel`, `function ltc2309_read_raw`, `function ltc2309_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.