drivers/iio/gyro/adis16136.c
Source file repositories/reference/linux-study-clean/drivers/iio/gyro/adis16136.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/gyro/adis16136.c- Extension
.c- Size
- 14116 bytes
- Lines
- 587
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/kernel.hlinux/spi/spi.hlinux/sysfs.hlinux/module.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/imu/adis.hlinux/debugfs.h
Detected Declarations
struct adis16136_chip_infostruct adis16136enum adis16136_idfunction adis16136_show_serialfunction adis16136_show_product_idfunction adis16136_show_flash_countfunction adis16136_debugfs_initfunction adis16136_debugfs_initfunction adis16136_set_freqfunction __adis16136_get_freqfunction adis16136_write_frequencyfunction adis16136_read_frequencyfunction adis16136_set_filterfunction adis16136_get_filterfunction adis16136_read_rawfunction adis16136_write_rawfunction adis16136_stop_devicefunction adis16136_initial_setupfunction adis16136_stopfunction adis16136_probe
Annotated Snippet
static const struct file_operations adis16136_serial_fops = {
.open = simple_open,
.read = adis16136_show_serial,
.llseek = default_llseek,
.owner = THIS_MODULE,
};
static int adis16136_show_product_id(void *arg, u64 *val)
{
struct adis16136 *adis16136 = arg;
u16 prod_id;
int ret;
ret = adis_read_reg_16(&adis16136->adis, ADIS16136_REG_PROD_ID,
&prod_id);
if (ret)
return ret;
*val = prod_id;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(adis16136_product_id_fops,
adis16136_show_product_id, NULL, "%llu\n");
static int adis16136_show_flash_count(void *arg, u64 *val)
{
struct adis16136 *adis16136 = arg;
uint16_t flash_count;
int ret;
ret = adis_read_reg_16(&adis16136->adis, ADIS16136_REG_FLASH_CNT,
&flash_count);
if (ret)
return ret;
*val = flash_count;
return 0;
}
DEFINE_DEBUGFS_ATTRIBUTE(adis16136_flash_count_fops,
adis16136_show_flash_count, NULL, "%lld\n");
static int adis16136_debugfs_init(struct iio_dev *indio_dev)
{
struct adis16136 *adis16136 = iio_priv(indio_dev);
struct dentry *d = iio_get_debugfs_dentry(indio_dev);
debugfs_create_file_unsafe("serial_number", 0400,
d, adis16136, &adis16136_serial_fops);
debugfs_create_file_unsafe("product_id", 0400,
d, adis16136, &adis16136_product_id_fops);
debugfs_create_file_unsafe("flash_count", 0400,
d, adis16136, &adis16136_flash_count_fops);
return 0;
}
#else
static int adis16136_debugfs_init(struct iio_dev *indio_dev)
{
return 0;
}
#endif
static int adis16136_set_freq(struct adis16136 *adis16136, unsigned int freq)
{
unsigned int t;
t = 32768 / freq;
if (t < 0xf)
t = 0xf;
else if (t > 0xffff)
t = 0xffff;
else
t--;
return adis_write_reg_16(&adis16136->adis, ADIS16136_REG_SMPL_PRD, t);
}
static int __adis16136_get_freq(struct adis16136 *adis16136, unsigned int *freq)
{
uint16_t t;
int ret;
ret = __adis_read_reg_16(&adis16136->adis, ADIS16136_REG_SMPL_PRD, &t);
if (ret)
return ret;
Annotation
- Immediate include surface: `linux/device.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/sysfs.h`, `linux/module.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/iio/imu/adis.h`.
- Detected declarations: `struct adis16136_chip_info`, `struct adis16136`, `enum adis16136_id`, `function adis16136_show_serial`, `function adis16136_show_product_id`, `function adis16136_show_flash_count`, `function adis16136_debugfs_init`, `function adis16136_debugfs_init`, `function adis16136_set_freq`, `function __adis16136_get_freq`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: pattern 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.