drivers/iio/accel/adxl367.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/adxl367.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/adxl367.c- Extension
.c- Size
- 36759 bytes
- Lines
- 1497
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/bitops.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/kfifo_buf.hlinux/iio/sysfs.hlinux/interrupt.hlinux/irq.hlinux/mod_devicetable.hlinux/regmap.hlinux/regulator/consumer.hlinux/unaligned.hadxl367.h
Detected Declarations
struct adxl367_stateenum adxl367_rangeenum adxl367_fifo_modeenum adxl367_fifo_formatenum adxl367_op_modeenum adxl367_act_proc_modeenum adxl367_act_en_modeenum adxl367_activity_typeenum adxl367_odrfunction adxl367_set_measure_enfunction adxl367_scale_act_thresholdsfunction _adxl367_set_act_thresholdfunction adxl367_set_act_thresholdfunction adxl367_set_act_proc_modefunction adxl367_set_act_interrupt_enfunction adxl367_get_act_interrupt_enfunction adxl367_set_act_enfunction adxl367_set_fifo_watermark_interrupt_enfunction adxl367_get_fifo_modefunction adxl367_set_fifo_modefunction adxl367_set_fifo_formatfunction adxl367_set_fifo_watermarkfunction adxl367_set_rangefunction adxl367_time_ms_to_samplesfunction _adxl367_set_act_time_msfunction _adxl367_set_inact_time_msfunction adxl367_set_act_time_msfunction _adxl367_set_odrfunction adxl367_set_odrfunction adxl367_set_temp_adc_enfunction adxl367_set_temp_adc_reg_enfunction adxl367_set_temp_adc_mask_enfunction adxl367_find_odrfunction adxl367_find_rangefunction adxl367_read_samplefunction adxl367_get_statusfunction adxl367_push_eventfunction adxl367_push_fifo_datafunction adxl367_irq_handlerfunction adxl367_reg_accessfunction adxl367_read_rawfunction adxl367_write_rawfunction adxl367_write_raw_get_fmtfunction adxl367_read_availfunction adxl367_read_event_valuefunction adxl367_write_event_valuefunction adxl367_read_event_configfunction __adxl367_write_event_config
Annotated Snippet
struct adxl367_state {
const struct adxl367_ops *ops;
void *context;
struct device *dev;
struct regmap *regmap;
/*
* Synchronize access to members of driver state, and ensure atomicity
* of consecutive regmap operations.
*/
struct mutex lock;
enum adxl367_odr odr;
enum adxl367_range range;
unsigned int act_threshold;
unsigned int act_time_ms;
unsigned int inact_threshold;
unsigned int inact_time_ms;
unsigned int fifo_set_size;
unsigned int fifo_watermark;
__be16 fifo_buf[ADXL367_FIFO_SIZE] __aligned(IIO_DMA_MINALIGN);
__be16 sample_buf;
u8 act_threshold_buf[2];
u8 inact_time_buf[2];
u8 status_buf[3];
};
static const unsigned int adxl367_threshold_h_reg_tbl[] = {
[ADXL367_ACTIVITY] = ADXL367_REG_THRESH_ACT_H,
[ADXL367_INACTIVITY] = ADXL367_REG_THRESH_INACT_H,
};
static const unsigned int adxl367_act_en_shift_tbl[] = {
[ADXL367_ACTIVITY] = 0,
[ADXL367_INACTIVITY] = 2,
};
static const unsigned int adxl367_act_int_mask_tbl[] = {
[ADXL367_ACTIVITY] = ADXL367_INT_ACT_MASK,
[ADXL367_INACTIVITY] = ADXL367_INT_INACT_MASK,
};
static const int adxl367_samp_freq_tbl[][2] = {
[ADXL367_ODR_12P5HZ] = {12, 500000},
[ADXL367_ODR_25HZ] = {25, 0},
[ADXL367_ODR_50HZ] = {50, 0},
[ADXL367_ODR_100HZ] = {100, 0},
[ADXL367_ODR_200HZ] = {200, 0},
[ADXL367_ODR_400HZ] = {400, 0},
};
/* (g * 2) * 9.80665 * 1000000 / (2^14 - 1) */
static const int adxl367_range_scale_tbl[][2] = {
[ADXL367_2G_RANGE] = {0, 2394347},
[ADXL367_4G_RANGE] = {0, 4788695},
[ADXL367_8G_RANGE] = {0, 9577391},
};
static const int adxl367_range_scale_factor_tbl[] = {
[ADXL367_2G_RANGE] = 1,
[ADXL367_4G_RANGE] = 2,
[ADXL367_8G_RANGE] = 4,
};
enum {
ADXL367_X_CHANNEL_INDEX,
ADXL367_Y_CHANNEL_INDEX,
ADXL367_Z_CHANNEL_INDEX,
ADXL367_TEMP_CHANNEL_INDEX,
ADXL367_EX_ADC_CHANNEL_INDEX
};
#define ADXL367_X_CHANNEL_MASK BIT(ADXL367_X_CHANNEL_INDEX)
#define ADXL367_Y_CHANNEL_MASK BIT(ADXL367_Y_CHANNEL_INDEX)
#define ADXL367_Z_CHANNEL_MASK BIT(ADXL367_Z_CHANNEL_INDEX)
#define ADXL367_TEMP_CHANNEL_MASK BIT(ADXL367_TEMP_CHANNEL_INDEX)
#define ADXL367_EX_ADC_CHANNEL_MASK BIT(ADXL367_EX_ADC_CHANNEL_INDEX)
static const enum adxl367_fifo_format adxl367_fifo_formats[] = {
ADXL367_FIFO_FORMAT_X,
ADXL367_FIFO_FORMAT_Y,
ADXL367_FIFO_FORMAT_Z,
ADXL367_FIFO_FORMAT_XT,
ADXL367_FIFO_FORMAT_YT,
ADXL367_FIFO_FORMAT_ZT,
ADXL367_FIFO_FORMAT_XA,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/iio/buffer.h`, `linux/iio/events.h`, `linux/iio/iio.h`, `linux/iio/kfifo_buf.h`, `linux/iio/sysfs.h`, `linux/interrupt.h`.
- Detected declarations: `struct adxl367_state`, `enum adxl367_range`, `enum adxl367_fifo_mode`, `enum adxl367_fifo_format`, `enum adxl367_op_mode`, `enum adxl367_act_proc_mode`, `enum adxl367_act_en_mode`, `enum adxl367_activity_type`, `enum adxl367_odr`, `function adxl367_set_measure_en`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration 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.