drivers/iio/amplifiers/ad8366.c
Source file repositories/reference/linux-study-clean/drivers/iio/amplifiers/ad8366.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/amplifiers/ad8366.c- Extension
.c- Size
- 10595 bytes
- Lines
- 404
- 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/bitrev.hlinux/bits.hlinux/dev_printk.hlinux/err.hlinux/gpio/consumer.hlinux/math.hlinux/minmax.hlinux/mod_devicetable.hlinux/module.hlinux/mutex.hlinux/regulator/consumer.hlinux/reset.hlinux/spi/spi.hlinux/types.hlinux/unaligned.hlinux/iio/iio.h
Detected Declarations
struct ad8366_infostruct ad8366_statefunction ad8366_pack_codefunction adrf5731_pack_codefunction hmc271_pack_codefunction ad8366_write_codefunction ad8366_read_rawfunction ad8366_write_rawfunction ad8366_write_raw_get_fmtfunction ad8366_probe
Annotated Snippet
struct ad8366_info {
const char *name;
int gain_min;
int gain_max;
int gain_step;
size_t num_channels;
size_t (*pack_code)(const unsigned char *code, size_t num_channels,
unsigned char *data);
};
struct ad8366_state {
struct spi_device *spi;
struct mutex lock; /* protect sensor state */
unsigned char ch[2];
const struct ad8366_info *info;
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers to live in their own cache lines.
*/
unsigned char data[2] __aligned(IIO_DMA_MINALIGN);
};
static size_t ad8366_pack_code(const unsigned char *code, size_t num_channels,
unsigned char *data)
{
u8 ch_a = bitrev8(code[0]) >> 2;
u8 ch_b = bitrev8(code[1]) >> 2;
put_unaligned_be16((ch_b << 6) | ch_a, &data[0]);
return sizeof(__be16);
}
static size_t adrf5731_pack_code(const unsigned char *code, size_t num_channels,
unsigned char *data)
{
data[0] = code[0] << 2;
return 1;
}
static size_t hmc271_pack_code(const unsigned char *code, size_t num_channels,
unsigned char *data)
{
data[0] = bitrev8(code[0]) >> 3;
return 1;
}
static const struct ad8366_info ad8366_chip_info = {
.name = "ad8366",
.gain_min = 4500,
.gain_max = 20500,
.gain_step = 253,
.num_channels = 2,
.pack_code = ad8366_pack_code,
};
static const struct ad8366_info ada4961_chip_info = {
.name = "ada4961",
.gain_min = -6000,
.gain_max = 15000,
.gain_step = -1000,
.num_channels = 1,
};
static const struct ad8366_info adl5240_chip_info = {
.name = "adl5240",
.gain_min = -11500,
.gain_max = 20000,
.gain_step = 500,
.num_channels = 1,
};
static const struct ad8366_info adrf5702_chip_info = {
.name = "adrf5702",
.gain_min = -31875,
.gain_max = 0,
.gain_step = -125,
.num_channels = 1,
};
static const struct ad8366_info adrf5703_chip_info = {
.name = "adrf5703",
.gain_min = -31750,
.gain_max = 0,
.gain_step = -250,
.num_channels = 1,
};
static const struct ad8366_info adrf5720_chip_info = {
.name = "adrf5720",
.gain_min = -31500,
Annotation
- Immediate include surface: `linux/bitrev.h`, `linux/bits.h`, `linux/dev_printk.h`, `linux/err.h`, `linux/gpio/consumer.h`, `linux/math.h`, `linux/minmax.h`, `linux/mod_devicetable.h`.
- Detected declarations: `struct ad8366_info`, `struct ad8366_state`, `function ad8366_pack_code`, `function adrf5731_pack_code`, `function hmc271_pack_code`, `function ad8366_write_code`, `function ad8366_read_raw`, `function ad8366_write_raw`, `function ad8366_write_raw_get_fmt`, `function ad8366_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.