drivers/iio/imu/kmx61.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/kmx61.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/kmx61.c- Extension
.c- Size
- 36192 bytes
- Lines
- 1505
- 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.
- 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/i2c.hlinux/interrupt.hlinux/mod_devicetable.hlinux/module.hlinux/pm.hlinux/pm_runtime.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/events.hlinux/iio/trigger.hlinux/iio/buffer.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.h
Detected Declarations
struct kmx61_dataenum kmx61_rangeenum kmx61_axisfunction BITfunction kmx61_set_datafunction kmx61_convert_freq_to_bitfunction kmx61_convert_wake_up_odr_to_bitfunction kmx61_set_modefunction kmx61_get_modefunction kmx61_set_wake_up_odrfunction kmx61_set_odrfunction kmx61_get_odrfunction kmx61_set_rangefunction kmx61_set_scalefunction kmx61_chip_initfunction kmx61_setup_new_data_interruptfunction kmx61_chip_update_thresholdsfunction kmx61_setup_any_motion_interruptfunction kmx61_set_power_statefunction kmx61_read_measurementfunction kmx61_read_rawfunction kmx61_write_rawfunction kmx61_read_eventfunction kmx61_write_eventfunction kmx61_read_event_configfunction kmx61_write_event_configfunction kmx61_acc_validate_triggerfunction kmx61_mag_validate_triggerfunction kmx61_data_rdy_trigger_set_statefunction kmx61_trig_reenablefunction kmx61_event_handlerfunction kmx61_data_rdy_trig_pollfunction kmx61_trigger_handlerfunction kmx61_probefunction kmx61_removefunction kmx61_suspendfunction kmx61_resumefunction kmx61_runtime_suspendfunction kmx61_runtime_resume
Annotated Snippet
struct kmx61_data {
struct i2c_client *client;
/* serialize access to non-atomic ops, e.g set_mode */
struct mutex lock;
/* standby state */
bool acc_stby;
bool mag_stby;
/* power state */
bool acc_ps;
bool mag_ps;
/* config bits */
u8 range;
u8 odr_bits;
u8 wake_thresh;
u8 wake_duration;
/* accelerometer specific data */
struct iio_dev *acc_indio_dev;
struct iio_trigger *acc_dready_trig;
struct iio_trigger *motion_trig;
bool acc_dready_trig_on;
bool motion_trig_on;
bool ev_enable_state;
/* magnetometer specific data */
struct iio_dev *mag_indio_dev;
struct iio_trigger *mag_dready_trig;
bool mag_dready_trig_on;
};
enum kmx61_range {
KMX61_RANGE_2G,
KMX61_RANGE_4G,
KMX61_RANGE_8G,
};
enum kmx61_axis {
KMX61_AXIS_X,
KMX61_AXIS_Y,
KMX61_AXIS_Z,
};
static const u16 kmx61_uscale_table[] = {9582, 19163, 38326};
static const struct {
int val;
int val2;
} kmx61_samp_freq_table[] = { {12, 500000},
{25, 0},
{50, 0},
{100, 0},
{200, 0},
{400, 0},
{800, 0},
{1600, 0},
{0, 781000},
{1, 563000},
{3, 125000},
{6, 250000} };
static const struct {
int val;
int val2;
int odr_bits;
} kmx61_wake_up_odr_table[] = { {0, 781000, 0x00},
{1, 563000, 0x01},
{3, 125000, 0x02},
{6, 250000, 0x03},
{12, 500000, 0x04},
{25, 0, 0x05},
{50, 0, 0x06},
{100, 0, 0x06},
{200, 0, 0x06},
{400, 0, 0x06},
{800, 0, 0x06},
{1600, 0, 0x06} };
static IIO_CONST_ATTR(accel_scale_available, "0.009582 0.019163 0.038326");
static IIO_CONST_ATTR(magn_scale_available, "0.001465");
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
"0.781000 1.563000 3.125000 6.250000 12.500000 25 50 100 200 400 800");
static struct attribute *kmx61_acc_attributes[] = {
&iio_const_attr_accel_scale_available.dev_attr.attr,
&iio_const_attr_sampling_frequency_available.dev_attr.attr,
NULL,
Annotation
- Immediate include surface: `linux/i2c.h`, `linux/interrupt.h`, `linux/mod_devicetable.h`, `linux/module.h`, `linux/pm.h`, `linux/pm_runtime.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`.
- Detected declarations: `struct kmx61_data`, `enum kmx61_range`, `enum kmx61_axis`, `function BIT`, `function kmx61_set_data`, `function kmx61_convert_freq_to_bit`, `function kmx61_convert_wake_up_odr_to_bit`, `function kmx61_set_mode`, `function kmx61_get_mode`, `function kmx61_set_wake_up_odr`.
- 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.