drivers/iio/gyro/fxas21002c_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/gyro/fxas21002c_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/gyro/fxas21002c_core.c- Extension
.c- Size
- 26387 bytes
- Lines
- 1063
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/interrupt.hlinux/module.hlinux/pm.hlinux/pm_runtime.hlinux/property.hlinux/regmap.hlinux/regulator/consumer.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hfxas21002c.h
Detected Declarations
struct fxas21002c_dataenum fxas21002c_mode_stateenum fxas21002c_channel_indexfunction fxas21002c_odr_hz_from_valuefunction fxas21002c_odr_value_from_hzfunction fxas21002c_lpf_bw_from_valuefunction fxas21002c_lpf_value_from_bwfunction fxas21002c_hpf_sel_from_valuefunction fxas21002c_hpf_value_from_selfunction fxas21002c_range_fs_from_valuefunction fxas21002c_range_value_from_fsfunction fxas21002c_mode_getfunction fxas21002c_mode_setfunction fxas21002c_writefunction fxas21002c_pm_getfunction fxas21002c_pm_putfunction fxas21002c_temp_getfunction fxas21002c_axis_getfunction fxas21002c_odr_getfunction fxas21002c_odr_setfunction fxas21002c_lpf_getfunction fxas21002c_lpf_setfunction fxas21002c_hpf_getfunction fxas21002c_hpf_setfunction fxas21002c_scale_getfunction fxas21002c_scale_setfunction fxas21002c_read_rawfunction fxas21002c_write_rawfunction fxas21002c_trigger_handlerfunction fxas21002c_chip_initfunction fxas21002c_data_rdy_trigger_set_statefunction fxas21002c_data_rdy_handlerfunction fxas21002c_data_rdy_threadfunction fxas21002c_trigger_probefunction fxas21002c_power_enablefunction fxas21002c_power_disablefunction fxas21002c_power_disable_actionfunction fxas21002c_regulators_getfunction fxas21002c_core_probefunction fxas21002c_core_removefunction fxas21002c_suspendfunction fxas21002c_resumefunction fxas21002c_runtime_suspendfunction fxas21002c_runtime_resume
Annotated Snippet
struct fxas21002c_data {
u8 chip_id;
enum fxas21002c_mode_state mode;
enum fxas21002c_mode_state prev_mode;
struct mutex lock; /* serialize data access */
struct regmap *regmap;
struct regmap_field *regmap_fields[F_MAX_FIELDS];
struct iio_trigger *dready_trig;
s64 timestamp;
int irq;
struct regulator *vdd;
struct regulator *vddio;
/*
* DMA (thus cache coherency maintenance) may require the
* transfer buffers live in their own cache lines.
*/
s16 buffer[8] __aligned(IIO_DMA_MINALIGN);
};
enum fxas21002c_channel_index {
CHANNEL_SCAN_INDEX_X,
CHANNEL_SCAN_INDEX_Y,
CHANNEL_SCAN_INDEX_Z,
CHANNEL_SCAN_MAX,
};
static int fxas21002c_odr_hz_from_value(struct fxas21002c_data *data, u8 value)
{
int odr_value_max = ARRAY_SIZE(fxas21002c_odr_values) - 1;
value = min_t(u8, value, odr_value_max);
return fxas21002c_odr_values[value];
}
static int fxas21002c_odr_value_from_hz(struct fxas21002c_data *data,
unsigned int hz)
{
int odr_table_size = ARRAY_SIZE(fxas21002c_odr_values);
int i;
for (i = 0; i < odr_table_size; i++)
if (fxas21002c_odr_values[i] == hz)
return i;
return -EINVAL;
}
static int fxas21002c_lpf_bw_from_value(struct fxas21002c_data *data, u8 value)
{
int lpf_value_max = ARRAY_SIZE(fxas21002c_lpf_values) - 1;
value = min_t(u8, value, lpf_value_max);
return fxas21002c_lpf_values[value];
}
static int fxas21002c_lpf_value_from_bw(struct fxas21002c_data *data,
unsigned int hz)
{
int lpf_table_size = ARRAY_SIZE(fxas21002c_lpf_values);
int i;
for (i = 0; i < lpf_table_size; i++)
if (fxas21002c_lpf_values[i] == hz)
return i;
return -EINVAL;
}
static int fxas21002c_hpf_sel_from_value(struct fxas21002c_data *data, u8 value)
{
int hpf_value_max = ARRAY_SIZE(fxas21002c_hpf_values) - 1;
value = min_t(u8, value, hpf_value_max);
return fxas21002c_hpf_values[value];
}
static int fxas21002c_hpf_value_from_sel(struct fxas21002c_data *data,
unsigned int hz)
{
int hpf_table_size = ARRAY_SIZE(fxas21002c_hpf_values);
int i;
for (i = 0; i < hpf_table_size; i++)
if (fxas21002c_hpf_values[i] == hz)
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/module.h`, `linux/pm.h`, `linux/pm_runtime.h`, `linux/property.h`, `linux/regmap.h`, `linux/regulator/consumer.h`, `linux/iio/events.h`.
- Detected declarations: `struct fxas21002c_data`, `enum fxas21002c_mode_state`, `enum fxas21002c_channel_index`, `function fxas21002c_odr_hz_from_value`, `function fxas21002c_odr_value_from_hz`, `function fxas21002c_lpf_bw_from_value`, `function fxas21002c_lpf_value_from_bw`, `function fxas21002c_hpf_sel_from_value`, `function fxas21002c_hpf_value_from_sel`, `function fxas21002c_range_fs_from_value`.
- 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.