drivers/iio/accel/adxl345_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/adxl345_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/adxl345_core.c- Extension
.c- Size
- 54266 bytes
- Lines
- 2043
- 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/interrupt.hlinux/module.hlinux/property.hlinux/regmap.hlinux/units.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/kfifo_buf.hadxl345.h
Detected Declarations
struct adxl345_stateenum adxl345_tap_typeenum adxl345_tap_time_typeenum adxl345_activity_typeenum adxl345_odrenum adxl345_rangeenum adxl345_chansfunction adxl345_is_volatile_regfunction adxl345_set_measure_enfunction adxl345_set_inact_thresholdfunction adxl345_set_default_timefunction adxl345_set_inactivity_timefunction adxl345_set_freefall_timefunction ratesfunction adxl345_is_act_inact_acfunction adxl345_set_act_inact_acfunction adxl345_is_act_inact_enfunction adxl345_set_act_inact_linkbitfunction adxl345_set_act_inact_enfunction _adxl345_set_tap_intfunction adxl345_is_tap_enfunction adxl345_set_singletap_enfunction adxl345_set_doubletap_enfunction _adxl345_set_tap_timefunction adxl345_set_tap_durationfunction adxl345_set_tap_windowfunction adxl345_set_tap_latentfunction adxl345_find_odrfunction adxl345_set_odrfunction adxl345_find_rangefunction adxl345_set_rangefunction adxl345_read_availfunction adxl345_read_rawfunction adxl345_write_rawfunction adxl345_read_mag_configfunction adxl345_write_mag_configfunction adxl345_read_event_configfunction adxl345_write_event_configfunction adxl345_read_mag_valuefunction adxl345_write_mag_valuefunction adxl345_read_event_valuefunction adxl345_write_event_valuefunction adxl345_reg_accessfunction adxl345_set_watermarkfunction adxl345_write_raw_get_fmtfunction adxl345_powerdownfunction adxl345_set_fifofunction adxl345_get_samples
Annotated Snippet
struct adxl345_state {
const struct adxl345_chip_info *info;
struct regmap *regmap;
bool fifo_delay; /* delay: delay is needed for SPI */
u8 watermark;
u8 fifo_mode;
u8 inact_threshold;
u32 inact_time_ms;
u32 tap_duration_us;
u32 tap_latent_us;
u32 tap_window_us;
__le16 fifo_buf[ADXL345_DIRS * ADXL345_FIFO_SIZE + 1] __aligned(IIO_DMA_MINALIGN);
};
static const struct iio_event_spec adxl345_events[] = {
{
/* activity */
.type = IIO_EV_TYPE_MAG,
.dir = IIO_EV_DIR_RISING,
.mask_shared_by_type =
BIT(IIO_EV_INFO_ENABLE) |
BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_VALUE),
},
{
/* activity, ac bit set */
.type = IIO_EV_TYPE_MAG_ADAPTIVE,
.dir = IIO_EV_DIR_RISING,
.mask_shared_by_type =
BIT(IIO_EV_INFO_ENABLE) |
BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_VALUE),
},
{
/* single tap */
.type = IIO_EV_TYPE_GESTURE,
.dir = IIO_EV_DIR_SINGLETAP,
.mask_separate = BIT(IIO_EV_INFO_ENABLE),
.mask_shared_by_type =
BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_VALUE) |
BIT(IIO_EV_INFO_TIMEOUT),
},
{
/* double tap */
.type = IIO_EV_TYPE_GESTURE,
.dir = IIO_EV_DIR_DOUBLETAP,
.mask_shared_by_type =
BIT(IIO_EV_INFO_ENABLE) |
BIT(IIO_EV_INFO_SCALE) |
BIT(IIO_EV_INFO_VALUE) |
BIT(IIO_EV_INFO_RESET_TIMEOUT) |
BIT(IIO_EV_INFO_TAP2_MIN_DELAY),
},
};
#define ADXL345_CHANNEL(index, reg, axis) { \
.type = IIO_ACCEL, \
.modified = 1, \
.channel2 = IIO_MOD_##axis, \
.address = (reg), \
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
BIT(IIO_CHAN_INFO_CALIBBIAS), \
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \
BIT(IIO_CHAN_INFO_SAMP_FREQ), \
.info_mask_shared_by_type_available = BIT(IIO_CHAN_INFO_SCALE) | \
BIT(IIO_CHAN_INFO_SAMP_FREQ), \
.scan_index = (index), \
.scan_type = { \
.sign = 's', \
.realbits = 13, \
.storagebits = 16, \
.endianness = IIO_LE, \
}, \
.event_spec = adxl345_events, \
.num_event_specs = ARRAY_SIZE(adxl345_events), \
}
enum adxl345_chans {
chan_x, chan_y, chan_z,
};
static const struct iio_event_spec adxl345_fake_chan_events[] = {
{
/* inactivity */
.type = IIO_EV_TYPE_MAG,
.dir = IIO_EV_DIR_FALLING,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/interrupt.h`, `linux/module.h`, `linux/property.h`, `linux/regmap.h`, `linux/units.h`, `linux/iio/iio.h`.
- Detected declarations: `struct adxl345_state`, `enum adxl345_tap_type`, `enum adxl345_tap_time_type`, `enum adxl345_activity_type`, `enum adxl345_odr`, `enum adxl345_range`, `enum adxl345_chans`, `function adxl345_is_volatile_reg`, `function adxl345_set_measure_en`, `function adxl345_set_inact_threshold`.
- 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.