drivers/iio/adc/ad7091r-base.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/ad7091r-base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/ad7091r-base.c- Extension
.c- Size
- 9542 bytes
- Lines
- 398
- 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/bitops.hlinux/bitfield.hlinux/cleanup.hlinux/iio/events.hlinux/iio/iio.hlinux/interrupt.hlinux/module.hlinux/regmap.hlinux/regulator/consumer.had7091r-base.h
Detected Declarations
function ad7091r_set_channelfunction ad7091r_read_onefunction ad7091r_read_rawfunction ad7091r_read_event_configfunction ad7091r_write_event_configfunction ad7091r_read_event_valuefunction ad7091r_write_event_valuefunction ad7091r_event_handlerfunction ad7091r_removefunction ad7091r_probefunction ad7091r_writeable_regfunction ad7091r_volatile_reg
Annotated Snippet
if (st->vref) {
ret = regulator_get_voltage(st->vref);
if (ret < 0)
return ret;
*val = ret / 1000;
} else {
*val = st->chip_info->vref_mV;
}
*val2 = chan->scan_type.realbits;
return IIO_VAL_FRACTIONAL_LOG2;
default:
return -EINVAL;
}
}
static int ad7091r_read_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir)
{
struct ad7091r_state *st = iio_priv(indio_dev);
int val, ret;
switch (dir) {
case IIO_EV_DIR_RISING:
ret = regmap_read(st->map,
AD7091R_REG_CH_HIGH_LIMIT(chan->channel),
&val);
if (ret)
return ret;
return val != AD7091R_HIGH_LIMIT;
case IIO_EV_DIR_FALLING:
ret = regmap_read(st->map,
AD7091R_REG_CH_LOW_LIMIT(chan->channel),
&val);
if (ret)
return ret;
return val != AD7091R_LOW_LIMIT;
default:
return -EINVAL;
}
}
static int ad7091r_write_event_config(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
bool state)
{
struct ad7091r_state *st = iio_priv(indio_dev);
if (state) {
return regmap_set_bits(st->map, AD7091R_REG_CONF,
AD7091R_REG_CONF_ALERT_EN);
} else {
/*
* Set thresholds either to 0 or to 2^12 - 1 as appropriate to
* prevent alerts and thus disable event generation.
*/
switch (dir) {
case IIO_EV_DIR_RISING:
return regmap_write(st->map,
AD7091R_REG_CH_HIGH_LIMIT(chan->channel),
AD7091R_HIGH_LIMIT);
case IIO_EV_DIR_FALLING:
return regmap_write(st->map,
AD7091R_REG_CH_LOW_LIMIT(chan->channel),
AD7091R_LOW_LIMIT);
default:
return -EINVAL;
}
}
}
static int ad7091r_read_event_value(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info, int *val, int *val2)
{
struct ad7091r_state *st = iio_priv(indio_dev);
int ret;
switch (info) {
case IIO_EV_INFO_VALUE:
switch (dir) {
case IIO_EV_DIR_RISING:
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/bitfield.h`, `linux/cleanup.h`, `linux/iio/events.h`, `linux/iio/iio.h`, `linux/interrupt.h`, `linux/module.h`, `linux/regmap.h`.
- Detected declarations: `function ad7091r_set_channel`, `function ad7091r_read_one`, `function ad7091r_read_raw`, `function ad7091r_read_event_config`, `function ad7091r_write_event_config`, `function ad7091r_read_event_value`, `function ad7091r_write_event_value`, `function ad7091r_event_handler`, `function ad7091r_remove`, `function ad7091r_probe`.
- 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.