drivers/iio/adc/sd_adc_modulator.c
Source file repositories/reference/linux-study-clean/drivers/iio/adc/sd_adc_modulator.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/adc/sd_adc_modulator.c- Extension
.c- Size
- 3873 bytes
- Lines
- 164
- 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.
- 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/iio/backend.hlinux/iio/iio.hlinux/iio/triggered_buffer.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/property.hlinux/regulator/consumer.h
Detected Declarations
struct iio_sd_backend_privfunction iio_sd_mod_enablefunction iio_sd_mod_disablefunction iio_sd_mod_readfunction iio_sd_mod_registerfunction iio_sd_mod_probe
Annotated Snippet
struct iio_sd_backend_priv {
struct regulator *vref;
int vref_mv;
};
static int iio_sd_mod_enable(struct iio_backend *backend)
{
struct iio_sd_backend_priv *priv = iio_backend_get_priv(backend);
if (priv->vref)
return regulator_enable(priv->vref);
return 0;
};
static void iio_sd_mod_disable(struct iio_backend *backend)
{
struct iio_sd_backend_priv *priv = iio_backend_get_priv(backend);
if (priv->vref)
regulator_disable(priv->vref);
};
static int iio_sd_mod_read(struct iio_backend *backend, struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
{
struct iio_sd_backend_priv *priv = iio_backend_get_priv(backend);
switch (mask) {
case IIO_CHAN_INFO_SCALE:
*val = priv->vref_mv;
return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET:
*val = 0;
return IIO_VAL_INT;
}
return -EOPNOTSUPP;
};
static const struct iio_backend_ops sd_backend_ops = {
.enable = iio_sd_mod_enable,
.disable = iio_sd_mod_disable,
.read_raw = iio_sd_mod_read,
};
static const struct iio_backend_info sd_backend_info = {
.name = "sd-modulator",
.ops = &sd_backend_ops,
.caps = IIO_BACKEND_CAP_ENABLE,
};
static int iio_sd_mod_register(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct iio_dev *iio;
iio = devm_iio_device_alloc(dev, 0);
if (!iio)
return -ENOMEM;
iio->name = dev_name(dev);
iio->info = &iio_sd_mod_iio_info;
iio->modes = INDIO_BUFFER_HARDWARE;
iio->num_channels = 1;
iio->channels = &iio_sd_mod_ch;
platform_set_drvdata(pdev, iio);
return devm_iio_device_register(&pdev->dev, iio);
}
static int iio_sd_mod_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct regulator *vref;
struct iio_sd_backend_priv *priv;
int ret;
/* If sd modulator is not defined as an IIO backend device, fallback to legacy */
if (!device_property_present(dev, "#io-backend-cells"))
return iio_sd_mod_register(pdev);
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
/*
Annotation
- Immediate include surface: `linux/iio/backend.h`, `linux/iio/iio.h`, `linux/iio/triggered_buffer.h`, `linux/module.h`, `linux/mod_devicetable.h`, `linux/platform_device.h`, `linux/property.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct iio_sd_backend_priv`, `function iio_sd_mod_enable`, `function iio_sd_mod_disable`, `function iio_sd_mod_read`, `function iio_sd_mod_register`, `function iio_sd_mod_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.