drivers/iio/adc/ad_sigma_delta.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad_sigma_delta.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad_sigma_delta.c- Extension
.c- Size
- 25230 bytes
- Lines
- 922
- 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/align.hlinux/bitmap.hlinux/bitops.hlinux/cleanup.hlinux/completion.hlinux/device.hlinux/err.hlinux/export.hlinux/find.hlinux/gpio/consumer.hlinux/interrupt.hlinux/module.hlinux/property.hlinux/slab.hlinux/spi/offload/consumer.hlinux/spi/spi.hlinux/spinlock.hlinux/string.hlinux/types.hlinux/unaligned.hlinux/iio/adc/ad_sigma_delta.hlinux/iio/buffer-dmaengine.hlinux/iio/buffer.hlinux/iio/iio.hlinux/iio/trigger_consumer.hlinux/iio/trigger.hlinux/iio/triggered_buffer.h
Detected Declarations
function ad_sd_set_commfunction ad_sd_write_regfunction ad_sd_set_read_reg_addrfunction ad_sd_read_reg_rawfunction ad_sd_read_regfunction ad_sd_resetfunction ad_sd_disable_irqfunction ad_sd_enable_irqfunction ad_sigma_delta_clear_pending_eventfunction ad_sd_calibratefunction ad_sd_calibrate_allfunction ad_sigma_delta_single_conversionfunction ad_sd_buffer_postenablefunction iio_for_each_active_channelfunction ad_sd_buffer_predisablefunction ad_sd_trigger_handlerfunction ad_sd_validate_scan_maskfunction ad_sd_data_rdy_trig_pollfunction GPIOfunction ad_sd_validate_triggerfunction devm_ad_sd_probe_triggerfunction devm_ad_sd_setup_buffer_and_triggerfunction ad_sd_init
Annotated Snippet
iio_for_each_active_channel(indio_dev, i) {
sigma_delta->slots[slot] = indio_dev->channels[i].address;
slot++;
}
}
sigma_delta->active_slots = slot;
sigma_delta->current_slot = 0;
if (ad_sigma_delta_has_spi_offload(sigma_delta)) {
xfer[1].offload_flags = SPI_OFFLOAD_XFER_RX_STREAM;
xfer[1].bits_per_word = scan_type->realbits;
xfer[1].len = spi_bpw_to_bytes(scan_type->realbits);
} else {
unsigned int samples_buf_size, scan_size;
if (sigma_delta->active_slots > 1) {
ret = ad_sigma_delta_append_status(sigma_delta, true);
if (ret)
return ret;
}
samples_buf_size =
ALIGN(slot * BITS_TO_BYTES(scan_type->storagebits),
sizeof(s64));
samples_buf_size += sizeof(s64);
samples_buf = devm_krealloc(&sigma_delta->spi->dev,
sigma_delta->samples_buf,
samples_buf_size, GFP_KERNEL);
if (!samples_buf)
return -ENOMEM;
sigma_delta->samples_buf = samples_buf;
scan_size = BITS_TO_BYTES(scan_type->realbits + scan_type->shift);
/* For 24-bit data, there is an extra byte of padding. */
xfer[1].rx_buf = &sigma_delta->rx_buf[scan_size == 3 ? 1 : 0];
xfer[1].len = scan_size + (sigma_delta->status_appended ? 1 : 0);
}
xfer[1].cs_change = 1;
if (sigma_delta->info->has_registers) {
xfer[0].tx_buf = &sigma_delta->sample_addr;
xfer[0].len = 1;
ad_sd_set_read_reg_addr(sigma_delta,
sigma_delta->info->data_reg ?: AD_SD_REG_DATA,
&sigma_delta->sample_addr);
spi_message_init_with_transfers(&sigma_delta->sample_msg, xfer, 2);
} else {
spi_message_init_with_transfers(&sigma_delta->sample_msg,
&xfer[1], 1);
}
sigma_delta->sample_msg.offload = sigma_delta->offload;
ret = spi_optimize_message(sigma_delta->spi, &sigma_delta->sample_msg);
if (ret)
return ret;
spi_bus_lock(sigma_delta->spi->controller);
sigma_delta->bus_locked = true;
sigma_delta->keep_cs_asserted = true;
ret = ad_sigma_delta_clear_pending_event(sigma_delta);
if (ret)
goto err_unlock;
ret = ad_sigma_delta_set_mode(sigma_delta, AD_SD_MODE_CONTINUOUS);
if (ret)
goto err_unlock;
if (ad_sigma_delta_has_spi_offload(sigma_delta)) {
struct spi_offload_trigger_config config = {
.type = SPI_OFFLOAD_TRIGGER_DATA_READY,
};
ret = spi_offload_trigger_enable(sigma_delta->offload,
sigma_delta->offload_trigger,
&config);
if (ret)
goto err_unlock;
} else {
ad_sd_enable_irq(sigma_delta);
}
return 0;
err_unlock:
spi_bus_unlock(sigma_delta->spi->controller);
spi_unoptimize_message(&sigma_delta->sample_msg);
Annotation
- Immediate include surface: `linux/align.h`, `linux/bitmap.h`, `linux/bitops.h`, `linux/cleanup.h`, `linux/completion.h`, `linux/device.h`, `linux/err.h`, `linux/export.h`.
- Detected declarations: `function ad_sd_set_comm`, `function ad_sd_write_reg`, `function ad_sd_set_read_reg_addr`, `function ad_sd_read_reg_raw`, `function ad_sd_read_reg`, `function ad_sd_reset`, `function ad_sd_disable_irq`, `function ad_sd_enable_irq`, `function ad_sigma_delta_clear_pending_event`, `function ad_sd_calibrate`.
- 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.