drivers/iio/dac/ad5446.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad5446.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad5446.c- Extension
.c- Size
- 5018 bytes
- Lines
- 215
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/array_size.hlinux/cleanup.hlinux/device.hlinux/err.hlinux/export.hlinux/iio/iio.hlinux/kstrtox.hlinux/module.hlinux/mutex.hlinux/regulator/consumer.hlinux/sysfs.had5446.h
Detected Declarations
function ad5446_set_powerdown_modefunction ad5446_get_powerdown_modefunction ad5446_read_dac_powerdownfunction ad5446_write_dac_powerdownfunction ad5446_read_rawfunction ad5446_write_dac_rawfunction ad5446_write_rawfunction ad5446_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* AD5446 CORE DAC driver
*
* Copyright 2010 Analog Devices Inc.
*/
#include <linux/array_size.h>
#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/export.h>
#include <linux/iio/iio.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/regulator/consumer.h>
#include <linux/sysfs.h>
#include "ad5446.h"
#define MODE_PWRDWN_1k 0x1
#define MODE_PWRDWN_100k 0x2
#define MODE_PWRDWN_TRISTATE 0x3
static const char * const ad5446_powerdown_modes[] = {
"1kohm_to_gnd", "100kohm_to_gnd", "three_state"
};
static int ad5446_set_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
unsigned int mode)
{
struct ad5446_state *st = iio_priv(indio_dev);
st->pwr_down_mode = mode + 1;
return 0;
}
static int ad5446_get_powerdown_mode(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan)
{
struct ad5446_state *st = iio_priv(indio_dev);
return st->pwr_down_mode - 1;
}
static const struct iio_enum ad5446_powerdown_mode_enum = {
.items = ad5446_powerdown_modes,
.num_items = ARRAY_SIZE(ad5446_powerdown_modes),
.get = ad5446_get_powerdown_mode,
.set = ad5446_set_powerdown_mode,
};
static ssize_t ad5446_read_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
char *buf)
{
struct ad5446_state *st = iio_priv(indio_dev);
return sysfs_emit(buf, "%d\n", st->pwr_down);
}
static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev,
uintptr_t private,
const struct iio_chan_spec *chan,
const char *buf, size_t len)
{
struct ad5446_state *st = iio_priv(indio_dev);
unsigned int shift;
unsigned int val;
bool powerdown;
int ret;
ret = kstrtobool(buf, &powerdown);
if (ret)
return ret;
guard(mutex)(&st->lock);
st->pwr_down = powerdown;
if (st->pwr_down) {
shift = chan->scan_type.realbits + chan->scan_type.shift;
val = st->pwr_down_mode << shift;
} else {
val = st->cached_val;
}
Annotation
- Immediate include surface: `linux/array_size.h`, `linux/cleanup.h`, `linux/device.h`, `linux/err.h`, `linux/export.h`, `linux/iio/iio.h`, `linux/kstrtox.h`, `linux/module.h`.
- Detected declarations: `function ad5446_set_powerdown_mode`, `function ad5446_get_powerdown_mode`, `function ad5446_read_dac_powerdown`, `function ad5446_write_dac_powerdown`, `function ad5446_read_raw`, `function ad5446_write_dac_raw`, `function ad5446_write_raw`, `function ad5446_probe`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: integration implementation candidate.
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.