drivers/iio/dac/ad5446-spi.c
Source file repositories/reference/linux-study-clean/drivers/iio/dac/ad5446-spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/dac/ad5446-spi.c- Extension
.c- Size
- 8667 bytes
- Lines
- 253
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/err.hlinux/module.hlinux/mod_devicetable.hlinux/spi/spi.hlinux/unaligned.hasm/byteorder.had5446.h
Detected Declarations
function ad5446_writefunction ad5660_writefunction ad5446_spi_probe
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* AD5446 SPI DAC driver
*
* Copyright 2025 Analog Devices Inc.
*/
#include <linux/err.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/spi/spi.h>
#include <linux/unaligned.h>
#include <asm/byteorder.h>
#include "ad5446.h"
static int ad5446_write(struct ad5446_state *st, unsigned int val)
{
struct spi_device *spi = to_spi_device(st->dev);
st->d16 = cpu_to_be16(val);
return spi_write(spi, &st->d16, sizeof(st->d16));
}
static int ad5660_write(struct ad5446_state *st, unsigned int val)
{
struct spi_device *spi = to_spi_device(st->dev);
put_unaligned_be24(val, st->d24);
return spi_write(spi, st->d24, sizeof(st->d24));
}
static int ad5446_spi_probe(struct spi_device *spi)
{
const struct spi_device_id *id = spi_get_device_id(spi);
const struct ad5446_chip_info *chip_info;
chip_info = spi_get_device_match_data(spi);
if (!chip_info)
return -ENODEV;
return ad5446_probe(&spi->dev, id->name, chip_info);
}
/*
* ad5446_supported_spi_device_ids:
* The AD5620/40/60 parts are available in different fixed internal reference
* voltage options. The actual part numbers may look differently
* (and a bit cryptic), however this style is used to make clear which
* parts are supported here.
*/
static const struct ad5446_chip_info ad5300_chip_info = {
.channel = AD5446_CHANNEL_POWERDOWN(8, 16, 4),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5310_chip_info = {
.channel = AD5446_CHANNEL_POWERDOWN(10, 16, 2),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5320_chip_info = {
.channel = AD5446_CHANNEL_POWERDOWN(12, 16, 0),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5444_chip_info = {
.channel = AD5446_CHANNEL(12, 16, 2),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5446_chip_info = {
.channel = AD5446_CHANNEL(14, 16, 0),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5450_chip_info = {
.channel = AD5446_CHANNEL(8, 16, 6),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5451_chip_info = {
.channel = AD5446_CHANNEL(10, 16, 4),
.write = ad5446_write,
};
static const struct ad5446_chip_info ad5541a_chip_info = {
Annotation
- Immediate include surface: `linux/err.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/spi/spi.h`, `linux/unaligned.h`, `asm/byteorder.h`, `ad5446.h`.
- Detected declarations: `function ad5446_write`, `function ad5660_write`, `function ad5446_spi_probe`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: source 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.