drivers/iio/accel/adxl355_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/adxl355_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/adxl355_core.c- Extension
.c- Size
- 21338 bytes
- Lines
- 842
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bits.hlinux/bitfield.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.hlinux/limits.hlinux/math64.hlinux/module.hlinux/mod_devicetable.hlinux/property.hlinux/regmap.hlinux/units.hlinux/unaligned.hadxl355.h
Detected Declarations
struct adxl355_chan_infostruct adxl355_dataenum adxl355_op_modeenum adxl355_odrenum adxl355_hpf_3dbenum adxl355_chansfunction adxl355_set_op_modefunction adxl355_data_rdy_trigger_set_statefunction adxl355_fill_3db_frequency_tablefunction adxl355_setupfunction adxl355_get_temp_datafunction adxl355_read_axisfunction adxl355_find_matchfunction adxl355_set_odrfunction adxl355_set_hpf_3dbfunction adxl355_set_calibbiasfunction adxl355_read_rawfunction adxl355_write_rawfunction adxl355_read_availfunction adxl355_trigger_handlerfunction adxl355_probe_triggerfunction adxl355_core_probe
Annotated Snippet
struct adxl355_chan_info {
u8 data_reg;
u8 offset_reg;
};
static const struct adxl355_chan_info adxl355_chans[] = {
[chan_x] = {
.data_reg = ADXL355_XDATA3_REG,
.offset_reg = ADXL355_OFFSET_X_H_REG
},
[chan_y] = {
.data_reg = ADXL355_YDATA3_REG,
.offset_reg = ADXL355_OFFSET_Y_H_REG
},
[chan_z] = {
.data_reg = ADXL355_ZDATA3_REG,
.offset_reg = ADXL355_OFFSET_Z_H_REG
},
};
struct adxl355_data {
const struct adxl355_chip_info *chip_info;
struct regmap *regmap;
struct device *dev;
struct mutex lock; /* lock to protect op_mode */
enum adxl355_op_mode op_mode;
enum adxl355_odr odr;
enum adxl355_hpf_3db hpf_3db;
int calibbias[3];
int adxl355_hpf_3db_table[7][2];
struct iio_trigger *dready_trig;
union {
u8 transf_buf[3];
struct {
u8 buf[14];
aligned_s64 ts;
} buffer;
} __aligned(IIO_DMA_MINALIGN);
};
static int adxl355_set_op_mode(struct adxl355_data *data,
enum adxl355_op_mode op_mode)
{
int ret;
if (data->op_mode == op_mode)
return 0;
ret = regmap_update_bits(data->regmap, ADXL355_POWER_CTL_REG,
ADXL355_POWER_CTL_MODE_MSK, op_mode);
if (ret)
return ret;
data->op_mode = op_mode;
return ret;
}
static int adxl355_data_rdy_trigger_set_state(struct iio_trigger *trig,
bool state)
{
struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
struct adxl355_data *data = iio_priv(indio_dev);
int ret;
mutex_lock(&data->lock);
ret = regmap_update_bits(data->regmap, ADXL355_POWER_CTL_REG,
ADXL355_POWER_CTL_DRDY_MSK,
FIELD_PREP(ADXL355_POWER_CTL_DRDY_MSK,
state ? 0 : 1));
mutex_unlock(&data->lock);
return ret;
}
static void adxl355_fill_3db_frequency_table(struct adxl355_data *data)
{
u32 multiplier;
u64 div, rem;
u64 odr;
int i;
odr = mul_u64_u32_shr(adxl355_odr_table[data->odr][0], MEGA, 0) +
adxl355_odr_table[data->odr][1];
for (i = 0; i < ARRAY_SIZE(adxl355_hpf_3db_multipliers); i++) {
multiplier = adxl355_hpf_3db_multipliers[i];
div = div64_u64_rem(mul_u64_u32_shr(odr, multiplier, 0),
TERA * 100, &rem);
Annotation
- Immediate include surface: `linux/bits.h`, `linux/bitfield.h`, `linux/iio/buffer.h`, `linux/iio/iio.h`, `linux/iio/trigger.h`, `linux/iio/triggered_buffer.h`, `linux/iio/trigger_consumer.h`, `linux/limits.h`.
- Detected declarations: `struct adxl355_chan_info`, `struct adxl355_data`, `enum adxl355_op_mode`, `enum adxl355_odr`, `enum adxl355_hpf_3db`, `enum adxl355_chans`, `function adxl355_set_op_mode`, `function adxl355_data_rdy_trigger_set_state`, `function adxl355_fill_3db_frequency_table`, `function adxl355_setup`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.