drivers/iio/accel/adxl313_core.c
Source file repositories/reference/linux-study-clean/drivers/iio/accel/adxl313_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/accel/adxl313_core.c- Extension
.c- Size
- 35388 bytes
- Lines
- 1329
- 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.
- 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/cleanup.hlinux/interrupt.hlinux/module.hlinux/overflow.hlinux/property.hlinux/regmap.hlinux/units.hlinux/iio/buffer.hlinux/iio/events.hlinux/iio/kfifo_buf.hadxl313.h
Detected Declarations
enum adxl313_activity_typeenum adxl313_chansfunction adxl313_is_volatile_regfunction adxl313_set_measure_enfunction adxl312_check_idfunction adxl313_check_idfunction adxl313_set_odrfunction adxl313_read_axisfunction adxl313_read_freq_availfunction adxl313_set_inact_time_sfunction adxl313_is_act_inact_acfunction adxl313_set_act_inact_acfunction adxl313_is_act_inact_enfunction adxl313_set_act_inact_linkbitfunction adxl313_set_act_inact_enfunction adxl313_read_rawfunction adxl313_write_rawfunction adxl313_read_mag_configfunction adxl313_write_mag_configfunction adxl313_read_event_configfunction adxl313_write_event_configfunction adxl313_read_mag_valuefunction adxl313_write_mag_valuefunction adxl313_read_event_valuefunction adxl313_write_event_valuefunction adxl313_set_watermarkfunction adxl313_get_samplesfunction adxl313_fifo_transferfunction adxl313_fifo_resetfunction adxl313_buffer_postenablefunction adxl313_buffer_predisablefunction adxl313_fifo_pushfunction adxl313_push_eventsfunction adxl313_irq_handlerfunction adxl313_reg_accessfunction adxl313_setupfunction adxl313_get_int_typefunction adxl313_core_probe
Annotated Snippet
if (type == ADXL313_INACTIVITY || type == ADXL313_INACTIVITY_AC) {
ret = regmap_read(data->regmap,
ADXL313_REG_TIME_INACT,
&inact_time_s);
if (ret)
return ret;
if (!inact_time_s)
return 0;
}
} else {
/*
* When turning off an activity, ensure that the correct
* coupling event is specified. This step helps prevent misuse -
* for example, if an AC-coupled activity is active and the
* current call attempts to turn off a DC-coupled activity, this
* inconsistency should be detected here.
*/
if (adxl313_is_act_inact_ac(data, type) <= 0)
return 0;
}
/* Start modifying configuration registers */
ret = adxl313_set_measure_en(data, false);
if (ret)
return ret;
/* Enable axis according to the command */
switch (type) {
case ADXL313_ACTIVITY:
case ADXL313_ACTIVITY_AC:
axis_ctrl = ADXL313_ACT_XYZ_EN;
break;
case ADXL313_INACTIVITY:
case ADXL313_INACTIVITY_AC:
axis_ctrl = ADXL313_INACT_XYZ_EN;
break;
default:
return -EINVAL;
}
ret = regmap_assign_bits(data->regmap, ADXL313_REG_ACT_INACT_CTL,
axis_ctrl, cmd_en);
if (ret)
return ret;
/* Update AC/DC-coupling according to the command */
ret = adxl313_set_act_inact_ac(data, type, cmd_en);
if (ret)
return ret;
/* Enable the interrupt line, according to the command */
ret = regmap_assign_bits(data->regmap, ADXL313_REG_INT_ENABLE,
adxl313_act_int_reg[type], cmd_en);
if (ret)
return ret;
/* Set link-bit and auto-sleep only when ACT and INACT are enabled */
ret = adxl313_set_act_inact_linkbit(data, cmd_en);
if (ret)
return ret;
return adxl313_set_measure_en(data, true);
}
static int adxl313_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
{
struct adxl313_data *data = iio_priv(indio_dev);
unsigned int regval;
int ret;
switch (mask) {
case IIO_CHAN_INFO_RAW:
ret = adxl313_read_axis(data, chan);
if (ret < 0)
return ret;
*val = sign_extend32(ret, chan->scan_type.realbits - 1);
return IIO_VAL_INT;
case IIO_CHAN_INFO_SCALE:
*val = 0;
*val2 = data->chip_info->scale_factor;
return IIO_VAL_INT_PLUS_NANO;
case IIO_CHAN_INFO_CALIBBIAS:
ret = regmap_read(data->regmap,
ADXL313_REG_OFS_AXIS(chan->address), ®val);
if (ret)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/cleanup.h`, `linux/interrupt.h`, `linux/module.h`, `linux/overflow.h`, `linux/property.h`, `linux/regmap.h`, `linux/units.h`.
- Detected declarations: `enum adxl313_activity_type`, `enum adxl313_chans`, `function adxl313_is_volatile_reg`, `function adxl313_set_measure_en`, `function adxl312_check_id`, `function adxl313_check_id`, `function adxl313_set_odr`, `function adxl313_read_axis`, `function adxl313_read_freq_avail`, `function adxl313_set_inact_time_s`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration implementation candidate.
- 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.