drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c- Extension
.c- Size
- 68731 bytes
- Lines
- 3020
- 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/kernel.hlinux/module.hlinux/acpi.hlinux/delay.hlinux/iio/events.hlinux/iio/iio.hlinux/iio/sysfs.hlinux/iio/triggered_buffer.hlinux/iio/trigger_consumer.hlinux/interrupt.hlinux/irq.hlinux/minmax.hlinux/pm.hlinux/property.hlinux/regmap.hlinux/bitfield.hlinux/platform_data/st_sensors_pdata.hst_lsm6dsx.h
Detected Declarations
function st_lsm6dsx_set_pagefunction st_lsm6dsx_check_whoamifunction st_lsm6dsx_set_full_scalefunction st_lsm6dsx_check_odrfunction st_lsm6dsx_check_odr_dependencyfunction st_lsm6dsx_set_odrfunction __st_lsm6dsx_sensor_set_enablefunction st_lsm6dsx_check_eventsfunction st_lsm6dsx_sensor_set_enablefunction st_lsm6dsx_read_oneshotfunction st_lsm6dsx_read_rawfunction st_lsm6dsx_write_rawfunction st_lsm6dsx_event_setupfunction st_lsm6dsx_get_event_idfunction st_lsm6dsx_get_event_regfunction st_lsm6dsx_read_eventfunction st_lsm6dsx_write_eventfunction st_lsm6dsx_read_event_configfunction st_lsm6dsx_check_other_eventsfunction st_lsm6dsx_events_enablefunction st_lsm6dsx_write_event_configfunction st_lsm6dsx_set_watermarkfunction st_lsm6dsx_sysfs_sampling_frequency_availfunction st_lsm6dsx_sysfs_scale_availfunction st_lsm6dsx_write_raw_get_fmtfunction st_lsm6dsx_get_drdy_regfunction st_lsm6dsx_init_shubfunction st_lsm6dsx_init_hw_timerfunction st_lsm6dsx_reset_devicefunction st_lsm6dsx_init_devicefunction st_lsm6dsx_report_eventsfunction st_lsm6dsx_report_motion_eventfunction st_lsm6dsx_handler_threadfunction st_lsm6dsx_sw_trigger_handler_threadfunction st_lsm6dsx_irq_setupfunction st_lsm6dsx_sw_buffer_preenablefunction st_lsm6dsx_sw_buffer_postdisablefunction st_lsm6dsx_sw_buffers_setupfunction st_lsm6dsx_init_regulatorsfunction st_lsm6dsx_probefunction st_lsm6dsx_suspendfunction st_lsm6dsx_resume
Annotated Snippet
if (val < 0) {
err = val;
} else {
sensor->odr = val;
sensor->hwfifo_odr_mHz = val;
}
break;
}
default:
err = -EINVAL;
break;
}
iio_device_release_direct(iio_dev);
return err;
}
static int st_lsm6dsx_event_setup(struct st_lsm6dsx_hw *hw,
enum st_lsm6dsx_event_id event, int axis,
bool state)
{
const struct st_lsm6dsx_event_src *src;
unsigned int data;
int err;
u8 old_enable, new_enable;
if (!hw->irq_routing)
return -ENOTSUPP;
/* Enable/disable event interrupt */
src = &hw->settings->event_settings.sources[event];
if (src->enable_axis_reg) {
u8 enable_mask;
switch (axis) {
case IIO_MOD_X:
enable_mask = src->enable_x_mask;
break;
case IIO_MOD_Y:
enable_mask = src->enable_y_mask;
break;
case IIO_MOD_Z:
enable_mask = src->enable_z_mask;
break;
default:
enable_mask = 0;
}
if (enable_mask) {
data = ST_LSM6DSX_SHIFT_VAL(state, enable_mask);
err = st_lsm6dsx_update_bits_locked(hw,
src->enable_axis_reg,
enable_mask, data);
if (err < 0)
return err;
}
}
/*
* If the set of axes for which the event source is enabled does not
* change from empty to non-empty or vice versa, there is nothing else
* to do.
*/
old_enable = hw->enable_event[event];
new_enable = state ? (old_enable | BIT(axis)) :
(old_enable & ~BIT(axis));
if (!old_enable == !new_enable)
return 0;
data = ST_LSM6DSX_SHIFT_VAL(state, src->enable_mask);
return st_lsm6dsx_update_bits_locked(hw, hw->irq_routing,
src->enable_mask, data);
}
static enum st_lsm6dsx_event_id
st_lsm6dsx_get_event_id(enum iio_event_type type)
{
switch (type) {
case IIO_EV_TYPE_THRESH:
return ST_LSM6DSX_EVENT_WAKEUP;
case IIO_EV_TYPE_GESTURE:
return ST_LSM6DSX_EVENT_TAP;
default:
return ST_LSM6DSX_EVENT_MAX;
}
}
static const struct st_lsm6dsx_reg *
st_lsm6dsx_get_event_reg(struct st_lsm6dsx_hw *hw,
enum st_lsm6dsx_event_id event,
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/acpi.h`, `linux/delay.h`, `linux/iio/events.h`, `linux/iio/iio.h`, `linux/iio/sysfs.h`, `linux/iio/triggered_buffer.h`.
- Detected declarations: `function st_lsm6dsx_set_page`, `function st_lsm6dsx_check_whoami`, `function st_lsm6dsx_set_full_scale`, `function st_lsm6dsx_check_odr`, `function st_lsm6dsx_check_odr_dependency`, `function st_lsm6dsx_set_odr`, `function __st_lsm6dsx_sensor_set_enable`, `function st_lsm6dsx_check_events`, `function st_lsm6dsx_sensor_set_enable`, `function st_lsm6dsx_read_oneshot`.
- 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.