drivers/iio/imu/adis_trigger.c
Source file repositories/reference/linux-study-clean/drivers/iio/imu/adis_trigger.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/imu/adis_trigger.c- Extension
.c- Size
- 3044 bytes
- Lines
- 107
- 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/interrupt.hlinux/kernel.hlinux/spi/spi.hlinux/export.hlinux/iio/iio.hlinux/iio/trigger.hlinux/iio/imu/adis.h
Detected Declarations
function adis_data_rdy_trigger_set_statefunction adis_validate_irq_flagfunction devm_adis_probe_trigger
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Common library for ADIS16XXX devices
*
* Copyright 2012 Analog Devices Inc.
* Author: Lars-Peter Clausen <lars@metafoo.de>
*/
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/spi/spi.h>
#include <linux/export.h>
#include <linux/iio/iio.h>
#include <linux/iio/trigger.h>
#include <linux/iio/imu/adis.h>
static int adis_data_rdy_trigger_set_state(struct iio_trigger *trig, bool state)
{
struct adis *adis = iio_trigger_get_drvdata(trig);
return adis_enable_irq(adis, state);
}
static const struct iio_trigger_ops adis_trigger_ops = {
.set_trigger_state = &adis_data_rdy_trigger_set_state,
};
static int adis_validate_irq_flag(struct adis *adis)
{
unsigned long direction = adis->irq_flag & IRQF_TRIGGER_MASK;
/* We cannot mask the interrupt so ensure it's not enabled at request */
if (adis->data->unmasked_drdy)
adis->irq_flag |= IRQF_NO_AUTOEN;
/*
* Typically adis devices without FIFO have data ready either on the
* rising edge or on the falling edge of the data ready pin.
* IMU devices with FIFO support have the watermark pin level driven
* either high or low when the FIFO is filled with the desired number
* of samples.
* It defaults to IRQF_TRIGGER_RISING for backward compatibility with
* devices that don't support changing the pin polarity.
*/
if (direction == IRQF_TRIGGER_NONE) {
adis->irq_flag |= IRQF_TRIGGER_RISING;
return 0;
} else if (direction != IRQF_TRIGGER_RISING &&
direction != IRQF_TRIGGER_FALLING && !adis->data->has_fifo) {
dev_err(&adis->spi->dev, "Invalid IRQ mask: %08lx\n",
adis->irq_flag);
return -EINVAL;
} else if (direction != IRQF_TRIGGER_HIGH &&
direction != IRQF_TRIGGER_LOW && adis->data->has_fifo) {
dev_err(&adis->spi->dev, "Invalid IRQ mask: %08lx\n",
adis->irq_flag);
return -EINVAL;
}
return 0;
}
/**
* devm_adis_probe_trigger() - Sets up trigger for a managed adis device
* @adis: The adis device
* @indio_dev: The IIO device
*
* Returns 0 on success or a negative error code
*/
int devm_adis_probe_trigger(struct adis *adis, struct iio_dev *indio_dev)
{
int ret;
adis->trig = devm_iio_trigger_alloc(&adis->spi->dev, "%s-dev%d",
indio_dev->name,
iio_device_id(indio_dev));
if (!adis->trig)
return -ENOMEM;
adis->trig->ops = &adis_trigger_ops;
iio_trigger_set_drvdata(adis->trig, adis);
ret = adis_validate_irq_flag(adis);
if (ret)
return ret;
if (adis->data->has_fifo)
ret = devm_request_threaded_irq(&adis->spi->dev, adis->spi->irq,
NULL,
&iio_trigger_generic_data_rdy_poll,
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/kernel.h`, `linux/spi/spi.h`, `linux/export.h`, `linux/iio/iio.h`, `linux/iio/trigger.h`, `linux/iio/imu/adis.h`.
- Detected declarations: `function adis_data_rdy_trigger_set_state`, `function adis_validate_irq_flag`, `function devm_adis_probe_trigger`.
- 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.