drivers/iio/imu/adis_buffer.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/adis_buffer.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/adis_buffer.c- Extension
.c- Size
- 5736 bytes
- Lines
- 223
- 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.
- 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/export.hlinux/interrupt.hlinux/mutex.hlinux/kernel.hlinux/spi/spi.hlinux/slab.hlinux/iio/iio.hlinux/iio/buffer.hlinux/iio/trigger_consumer.hlinux/iio/triggered_buffer.hlinux/iio/imu/adis.h
Detected Declarations
function adis_update_scan_mode_burstfunction adis_update_scan_modefunction adis_paging_trigger_handlerfunction adis_trigger_handlerfunction adis_buffer_cleanupfunction devm_adis_setup_buffer_and_trigger_with_attrs
Annotated Snippet
if (ret) {
dev_err(&adis->spi->dev, "Failed to change device page: %d\n", ret);
return ret;
}
adis->current_page = 0;
}
return spi_sync(adis->spi, &adis->msg);
}
static irqreturn_t adis_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
struct iio_dev *indio_dev = pf->indio_dev;
struct adis *adis = iio_device_get_drvdata(indio_dev);
int ret;
if (adis->data->has_paging)
ret = adis_paging_trigger_handler(adis);
else
ret = spi_sync(adis->spi, &adis->msg);
if (ret) {
dev_err(&adis->spi->dev, "Failed to read data: %d", ret);
goto irq_done;
}
iio_push_to_buffers_with_timestamp(indio_dev, adis->buffer,
pf->timestamp);
irq_done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
static void adis_buffer_cleanup(void *arg)
{
struct adis *adis = arg;
kfree(adis->buffer);
kfree(adis->xfer);
}
/**
* devm_adis_setup_buffer_and_trigger_with_attrs() - Sets up buffer and trigger
* for the managed adis device with buffer attributes.
* @adis: The adis device
* @indio_dev: The IIO device
* @trigger_handler: Trigger handler: should handle the buffer readings.
* @ops: Optional buffer setup functions, may be NULL.
* @buffer_attrs: Extra buffer attributes.
*
* Returns 0 on success, a negative error code otherwise.
*
* This function sets up the buffer (with buffer setup functions and extra
* buffer attributes) and trigger for a adis devices with buffer attributes.
*/
int
devm_adis_setup_buffer_and_trigger_with_attrs(struct adis *adis, struct iio_dev *indio_dev,
irq_handler_t trigger_handler,
const struct iio_buffer_setup_ops *ops,
const struct iio_dev_attr **buffer_attrs)
{
int ret;
if (!trigger_handler)
trigger_handler = adis_trigger_handler;
ret = devm_iio_triggered_buffer_setup_ext(&adis->spi->dev, indio_dev,
&iio_pollfunc_store_time,
trigger_handler,
IIO_BUFFER_DIRECTION_IN,
ops,
buffer_attrs);
if (ret)
return ret;
if (adis->spi->irq) {
ret = devm_adis_probe_trigger(adis, indio_dev);
if (ret)
return ret;
}
return devm_add_action_or_reset(&adis->spi->dev, adis_buffer_cleanup,
adis);
}
EXPORT_SYMBOL_NS_GPL(devm_adis_setup_buffer_and_trigger_with_attrs, "IIO_ADISLIB");
Annotation
- Immediate include surface: `linux/export.h`, `linux/interrupt.h`, `linux/mutex.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/slab.h`, `linux/iio/iio.h`, `linux/iio/buffer.h`.
- Detected declarations: `function adis_update_scan_mode_burst`, `function adis_update_scan_mode`, `function adis_paging_trigger_handler`, `function adis_trigger_handler`, `function adis_buffer_cleanup`, `function devm_adis_setup_buffer_and_trigger_with_attrs`.
- 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.