drivers/iio/gyro/adxrs290.c
Source file repositories/reference/linux-study-clean/drivers/iio/gyro/adxrs290.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/gyro/adxrs290.c- Extension
.c- Size
- 17750 bytes
- Lines
- 707
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/bitops.hlinux/delay.hlinux/device.hlinux/kernel.hlinux/module.hlinux/spi/spi.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.h
Detected Declarations
struct adxrs290_stateenum adxrs290_modeenum adxrs290_scan_indexfunction adxrs290_get_rate_datafunction adxrs290_get_temp_datafunction adxrs290_get_3db_freqfunction adxrs290_spi_write_regfunction adxrs290_find_matchfunction adxrs290_set_filter_freqfunction adxrs290_set_modefunction adxrs290_chip_off_actionfunction adxrs290_initial_setupfunction adxrs290_read_rawfunction adxrs290_write_rawfunction adxrs290_read_availfunction adxrs290_reg_access_rwfunction adxrs290_reg_accessfunction adxrs290_data_rdy_trigger_set_statefunction adxrs290_reset_trigfunction adxrs290_trigger_handlerfunction adxrs290_probe_triggerfunction adxrs290_probe
Annotated Snippet
struct adxrs290_state {
struct spi_device *spi;
/* Serialize reads and their subsequent processing */
struct mutex lock;
enum adxrs290_mode mode;
unsigned int lpf_3db_freq_idx;
unsigned int hpf_3db_freq_idx;
struct iio_trigger *dready_trig;
/* Ensure correct alignment of timestamp when present */
struct {
s16 channels[3];
aligned_s64 ts;
} buffer;
};
/*
* Available cut-off frequencies of the low pass filter in Hz.
* The integer part and fractional part are represented separately.
*/
static const int adxrs290_lpf_3db_freq_hz_table[][2] = {
[0] = {480, 0},
[1] = {320, 0},
[2] = {160, 0},
[3] = {80, 0},
[4] = {56, 600000},
[5] = {40, 0},
[6] = {28, 300000},
[7] = {20, 0},
};
/*
* Available cut-off frequencies of the high pass filter in Hz.
* The integer part and fractional part are represented separately.
*/
static const int adxrs290_hpf_3db_freq_hz_table[][2] = {
[0] = {0, 0},
[1] = {0, 11000},
[2] = {0, 22000},
[3] = {0, 44000},
[4] = {0, 87000},
[5] = {0, 175000},
[6] = {0, 350000},
[7] = {0, 700000},
[8] = {1, 400000},
[9] = {2, 800000},
[10] = {11, 300000},
};
static int adxrs290_get_rate_data(struct iio_dev *indio_dev, const u8 cmd, int *val)
{
struct adxrs290_state *st = iio_priv(indio_dev);
int ret = 0;
int temp;
mutex_lock(&st->lock);
temp = spi_w8r16(st->spi, cmd);
if (temp < 0) {
ret = temp;
goto err_unlock;
}
*val = sign_extend32(temp, 15);
err_unlock:
mutex_unlock(&st->lock);
return ret;
}
static int adxrs290_get_temp_data(struct iio_dev *indio_dev, int *val)
{
const u8 cmd = ADXRS290_READ_REG(ADXRS290_REG_TEMP0);
struct adxrs290_state *st = iio_priv(indio_dev);
int ret = 0;
int temp;
mutex_lock(&st->lock);
temp = spi_w8r16(st->spi, cmd);
if (temp < 0) {
ret = temp;
goto err_unlock;
}
/* extract lower 12 bits temperature reading */
*val = sign_extend32(temp, 11);
err_unlock:
mutex_unlock(&st->lock);
return ret;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/delay.h`, `linux/device.h`, `linux/kernel.h`, `linux/module.h`, `linux/spi/spi.h`, `linux/iio/buffer.h`.
- Detected declarations: `struct adxrs290_state`, `enum adxrs290_mode`, `enum adxrs290_scan_index`, `function adxrs290_get_rate_data`, `function adxrs290_get_temp_data`, `function adxrs290_get_3db_freq`, `function adxrs290_spi_write_reg`, `function adxrs290_find_match`, `function adxrs290_set_filter_freq`, `function adxrs290_set_mode`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.