drivers/iio/imu/adis16400.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/adis16400.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/adis16400.c- Extension
.c- Size
- 38548 bytes
- Lines
- 1224
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/irq.hlinux/device.hlinux/kernel.hlinux/spi/spi.hlinux/module.hlinux/debugfs.hlinux/bitops.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/trigger_consumer.hlinux/iio/imu/adis.h
Detected Declarations
struct adis16400_statestruct adis16400_chip_infostruct adis16400_statefunction adis16400_show_serial_numberfunction adis16400_show_product_idfunction adis16400_show_flash_countfunction adis16400_debugfs_initfunction adis16334_get_freqfunction adis16334_set_freqfunction adis16400_get_freqfunction adis16400_set_freqfunction __adis16400_set_filterfunction adis16400_stop_devicefunction adis16400_initial_setupfunction adis16400_write_rawfunction adis_dev_auto_scoped_lockfunction adis16400_read_rawfunction adis_dev_auto_scoped_lockfunction adis_dev_auto_scoped_lockfunction adis16400_trigger_handlerfunction BITfunction adis16400_setup_chan_maskfunction adis16400_stopfunction adis16400_probe
Annotated Snippet
static const struct file_operations adis16400_serial_number_fops = {
.open = simple_open,
.read = adis16400_show_serial_number,
.llseek = default_llseek,
.owner = THIS_MODULE,
};
static int adis16400_show_product_id(void *arg, u64 *val)
{
struct adis16400_state *st = arg;
uint16_t prod_id;
int ret;
ret = adis_read_reg_16(&st->adis, ADIS16400_PRODUCT_ID, &prod_id);
if (ret)
return ret;
*val = prod_id;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(adis16400_product_id_fops,
adis16400_show_product_id, NULL, "%lld\n");
static int adis16400_show_flash_count(void *arg, u64 *val)
{
struct adis16400_state *st = arg;
uint16_t flash_count;
int ret;
ret = adis_read_reg_16(&st->adis, ADIS16400_FLASH_CNT, &flash_count);
if (ret)
return ret;
*val = flash_count;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(adis16400_flash_count_fops,
adis16400_show_flash_count, NULL, "%lld\n");
static void adis16400_debugfs_init(struct iio_dev *indio_dev)
{
struct adis16400_state *st = iio_priv(indio_dev);
struct dentry *d = iio_get_debugfs_dentry(indio_dev);
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return;
if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER)
debugfs_create_file_unsafe("serial_number", 0400,
d, st, &adis16400_serial_number_fops);
if (st->variant->flags & ADIS16400_HAS_PROD_ID)
debugfs_create_file_unsafe("product_id", 0400,
d, st, &adis16400_product_id_fops);
debugfs_create_file_unsafe("flash_count", 0400,
d, st, &adis16400_flash_count_fops);
}
static int adis16334_get_freq(struct adis16400_state *st)
{
int ret;
uint16_t t;
ret = __adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
if (ret)
return ret;
t >>= ADIS16334_RATE_DIV_SHIFT;
return 819200 >> t;
}
static int adis16334_set_freq(struct adis16400_state *st, unsigned int freq)
{
unsigned int t;
if (freq < 819200)
t = ilog2(819200 / freq);
else
t = 0;
if (t > 0x31)
t = 0x31;
t <<= ADIS16334_RATE_DIV_SHIFT;
t |= ADIS16334_RATE_INT_CLK;
return __adis_write_reg_16(&st->adis, ADIS16400_SMPL_PRD, t);
}
Annotation
- Immediate include surface: `linux/irq.h`, `linux/device.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/module.h`, `linux/debugfs.h`, `linux/bitops.h`, `linux/iio/iio.h`.
- Detected declarations: `struct adis16400_state`, `struct adis16400_chip_info`, `struct adis16400_state`, `function adis16400_show_serial_number`, `function adis16400_show_product_id`, `function adis16400_show_flash_count`, `function adis16400_debugfs_init`, `function adis16334_get_freq`, `function adis16334_set_freq`, `function adis16400_get_freq`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: pattern implementation candidate.
- 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.