drivers/iio/accel/bma400_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/bma400_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/bma400_core.c- Extension
.c- Size
- 45872 bytes
- Lines
- 1810
- 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/bitfield.hlinux/bitops.hlinux/cleanup.hlinux/device.hlinux/kernel.hlinux/module.hlinux/mutex.hlinux/regmap.hlinux/regulator/consumer.hlinux/slab.hlinux/unaligned.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/sysfs.hlinux/iio/trigger.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hbma400.h
Detected Declarations
struct bma400_sample_freqstruct bma400_datastruct bma400_genintr_infoenum bma400_power_modeenum bma400_scanenum bma400_activityfunction get_bma400_genintr_infofunction bma400_is_writable_regfunction bma400_is_volatile_regfunction bma400_accel_get_mount_matrixfunction usec_to_tapreg_rawfunction in_accel_gesture_tap_maxtomin_time_showfunction in_accel_gesture_tap_maxtomin_time_storefunction BITfunction bma400_get_temp_regfunction bma400_get_accel_regfunction bma400_output_data_rate_from_rawfunction bma400_get_accel_output_data_ratefunction bma400_set_accel_output_data_ratefunction bma400_get_accel_oversampling_ratiofunction bma400_set_accel_oversampling_ratiofunction bma400_accel_scale_to_rawfunction bma400_get_accel_scalefunction bma400_set_accel_scalefunction bma400_get_power_modefunction bma400_set_power_modefunction bma400_enable_stepsfunction bma400_get_steps_regfunction bma400_init_tablesfunction bma400_power_disablefunction bma400_act_to_modfunction bma400_initfunction bma400_read_rawfunction bma400_read_availfunction bma400_write_rawfunction bma400_write_raw_get_fmtfunction bma400_read_event_configfunction bma400_steps_event_enablefunction bma400_generic_event_enfunction bma400_tap_event_enfunction bma400_disable_adv_interruptfunction bma400_write_event_configfunction bma400_read_event_valuefunction bma400_write_event_valuefunction bma400_data_rdy_trigger_set_statefunction bma400_trigger_handlerfunction bma400_interruptfunction bma400_probe
Annotated Snippet
struct bma400_sample_freq {
int hz;
int uhz;
};
enum bma400_activity {
BMA400_STILL,
BMA400_WALKING,
BMA400_RUNNING,
};
struct bma400_data {
struct device *dev;
struct regmap *regmap;
struct mutex mutex; /* data register lock */
struct iio_mount_matrix orientation;
enum bma400_power_mode power_mode;
struct bma400_sample_freq sample_freq;
int oversampling_ratio;
int scale;
struct iio_trigger *trig;
int steps_enabled;
bool step_event_en;
bool activity_event_en;
unsigned int generic_event_en;
unsigned int tap_event_en_bitmask;
/* Correct time stamp alignment */
struct {
__le16 buff[3];
u8 temperature;
aligned_s64 ts;
} buffer __aligned(IIO_DMA_MINALIGN);
__le16 status;
__be16 duration;
};
struct bma400_genintr_info {
enum bma400_generic_intr genintr;
unsigned int intrmask;
enum iio_event_direction dir;
enum bma400_detect_criterion detect_mode;
};
/* Lookup struct for determining GEN1/GEN2 based on dir */
static const struct bma400_genintr_info bma400_genintrs[] = {
[IIO_EV_DIR_RISING] = {
.genintr = BMA400_GEN1_INTR,
.intrmask = BMA400_INT_CONFIG0_GEN1_MASK,
.dir = IIO_EV_DIR_RISING,
.detect_mode = BMA400_DETECT_ACTIVITY,
},
[IIO_EV_DIR_FALLING] = {
.genintr = BMA400_GEN2_INTR,
.intrmask = BMA400_INT_CONFIG0_GEN2_MASK,
.dir = IIO_EV_DIR_FALLING,
.detect_mode = BMA400_DETECT_INACTIVITY,
}
};
static inline const struct bma400_genintr_info *
get_bma400_genintr_info(enum iio_event_direction dir)
{
switch (dir) {
case IIO_EV_DIR_RISING:
case IIO_EV_DIR_FALLING:
return &bma400_genintrs[dir];
default:
return NULL;
};
}
static bool bma400_is_writable_reg(struct device *dev, unsigned int reg)
{
switch (reg) {
case BMA400_CHIP_ID_REG:
case BMA400_ERR_REG:
case BMA400_STATUS_REG:
case BMA400_ACC_X_LSB_REG:
case BMA400_ACC_X_MSB_REG:
case BMA400_ACC_Y_LSB_REG:
case BMA400_ACC_Y_MSB_REG:
case BMA400_ACC_Z_LSB_REG:
case BMA400_ACC_Z_MSB_REG:
case BMA400_SENSOR_TIME0_REG:
case BMA400_SENSOR_TIME1_REG:
case BMA400_SENSOR_TIME2_REG:
case BMA400_EVENT_REG:
case BMA400_INT_STAT0_REG:
case BMA400_INT_STAT1_REG:
case BMA400_INT_STAT2_REG:
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bitops.h`, `linux/cleanup.h`, `linux/device.h`, `linux/kernel.h`, `linux/module.h`, `linux/mutex.h`, `linux/regmap.h`.
- Detected declarations: `struct bma400_sample_freq`, `struct bma400_data`, `struct bma400_genintr_info`, `enum bma400_power_mode`, `enum bma400_scan`, `enum bma400_activity`, `function get_bma400_genintr_info`, `function bma400_is_writable_reg`, `function bma400_is_volatile_reg`, `function bma400_accel_get_mount_matrix`.
- 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.