drivers/iio/industrialio-backend.c
Source file repositories/reference/linux-study-clean/drivers/iio/industrialio-backend.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/industrialio-backend.c- Extension
.c- Size
- 32652 bytes
- Lines
- 1144
- Domain
- Driver Families
- Bucket
- drivers/iio
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/cleanup.hlinux/debugfs.hlinux/device.hlinux/err.hlinux/errno.hlinux/list.hlinux/module.hlinux/mutex.hlinux/property.hlinux/slab.hlinux/stringify.hlinux/types.hlinux/iio/backend.hlinux/iio/iio.h
Detected Declarations
struct iio_backendstruct iio_backend_buffer_pairfunction iio_backend_debugfs_read_regfunction iio_backend_debugfs_write_regfunction iio_backend_debugfs_read_namefunction iio_backend_debugfs_addfunction iio_backend_debugfs_print_chan_statusfunction iio_backend_chan_enablefunction iio_backend_chan_disablefunction __iio_backend_disablefunction iio_backend_disablefunction iio_backend_enablefunction devm_iio_backend_enablefunction iio_backend_data_format_setfunction iio_backend_data_source_setfunction iio_backend_data_source_getfunction iio_backend_set_sampling_freqfunction iio_backend_test_pattern_setfunction iio_backend_chan_statusfunction iio_backend_iodelay_setfunction datafunction iio_backend_free_bufferfunction devm_iio_backend_request_bufferfunction iio_backend_read_rawfunction callbacksfunction callbacksfunction iio_backend_interface_type_getfunction iio_backend_data_size_setfunction iio_backend_oversampling_ratio_setfunction iio_backend_extend_chan_specfunction iio_backend_has_capsfunction iio_backend_releasefunction __devm_iio_backend_getfunction iio_backend_filter_type_setfunction bitfunction iio_backend_num_lanes_setfunction iio_backend_ddr_enablefunction iio_backend_ddr_disablefunction iio_backend_data_stream_enablefunction iio_backend_data_stream_disablefunction iio_backend_data_transfer_addrfunction __devm_iio_backend_get_from_fwnode_lookupfunction iio_backend_unregisterfunction devm_iio_backend_register
Annotated Snippet
static const struct file_operations iio_backend_debugfs_reg_fops = {
.open = simple_open,
.read = iio_backend_debugfs_read_reg,
.write = iio_backend_debugfs_write_reg,
};
static ssize_t iio_backend_debugfs_read_name(struct file *file,
char __user *userbuf,
size_t count, loff_t *ppos)
{
struct iio_backend *back = file->private_data;
char name[128];
int len;
len = scnprintf(name, sizeof(name), "%s\n", back->name);
return simple_read_from_buffer(userbuf, count, ppos, name, len);
}
static const struct file_operations iio_backend_debugfs_name_fops = {
.open = simple_open,
.read = iio_backend_debugfs_read_name,
};
/**
* iio_backend_debugfs_add - Add debugfs interfaces for Backends
* @back: Backend device
* @indio_dev: IIO device
*/
void iio_backend_debugfs_add(struct iio_backend *back,
struct iio_dev *indio_dev)
{
struct dentry *d = iio_get_debugfs_dentry(indio_dev);
struct dentry *back_d;
char name[128];
if (!IS_ENABLED(CONFIG_DEBUG_FS) || !d)
return;
if (!back->ops->debugfs_reg_access && !back->name)
return;
snprintf(name, sizeof(name), "backend%d", back->idx);
back_d = debugfs_create_dir(name, d);
if (IS_ERR(back_d))
return;
if (back->ops->debugfs_reg_access)
debugfs_create_file("direct_reg_access", 0600, back_d, back,
&iio_backend_debugfs_reg_fops);
if (back->name)
debugfs_create_file("name", 0400, back_d, back,
&iio_backend_debugfs_name_fops);
}
EXPORT_SYMBOL_NS_GPL(iio_backend_debugfs_add, "IIO_BACKEND");
/**
* iio_backend_debugfs_print_chan_status - Print channel status
* @back: Backend device
* @chan: Channel number
* @buf: Buffer where to print the status
* @len: Available space
*
* One usecase where this is useful is for testing test tones in a digital
* interface and "ask" the backend to dump more details on why a test tone might
* have errors.
*
* RETURNS:
* Number of copied bytes on success, negative error code on failure.
*/
ssize_t iio_backend_debugfs_print_chan_status(struct iio_backend *back,
unsigned int chan, char *buf,
size_t len)
{
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return -ENODEV;
return iio_backend_op_call(back, debugfs_print_chan_status, chan, buf,
len);
}
EXPORT_SYMBOL_NS_GPL(iio_backend_debugfs_print_chan_status, "IIO_BACKEND");
/**
* iio_backend_chan_enable - Enable a backend channel
* @back: Backend device
* @chan: Channel number
*
* RETURNS:
* 0 on success, negative error number on failure.
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/debugfs.h`, `linux/device.h`, `linux/err.h`, `linux/errno.h`, `linux/list.h`, `linux/module.h`, `linux/mutex.h`.
- Detected declarations: `struct iio_backend`, `struct iio_backend_buffer_pair`, `function iio_backend_debugfs_read_reg`, `function iio_backend_debugfs_write_reg`, `function iio_backend_debugfs_read_name`, `function iio_backend_debugfs_add`, `function iio_backend_debugfs_print_chan_status`, `function iio_backend_chan_enable`, `function iio_backend_chan_disable`, `function __iio_backend_disable`.
- Atlas domain: Driver Families / drivers/iio.
- Implementation status: pattern 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.