drivers/iio/inkern.c
Source file repositories/reference/linux-study-clean/drivers/iio/inkern.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/iio/inkern.c- Extension
.c- Size
- 25504 bytes
- Lines
- 1046
- 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.
- 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/err.hlinux/export.hlinux/minmax.hlinux/mm.hlinux/mutex.hlinux/property.hlinux/slab.hlinux/units.hlinux/iio/iio.hlinux/iio/iio-opaque.hiio_core.hlinux/iio/machine.hlinux/iio/driver.hlinux/iio/consumer.h
Detected Declarations
struct iio_map_internalfunction iio_map_array_unregister_lockedfunction list_for_each_entry_safefunction iio_map_array_registerfunction iio_map_array_unregisterfunction iio_map_array_unregister_cbfunction devm_iio_map_array_registerfunction num_channelsfunction __fwnode_iio_channel_getfunction __fwnode_iio_channel_get_by_namefunction list_for_each_entryfunction iio_channel_releasefunction devm_iio_channel_freefunction iio_channel_release_allfunction devm_iio_channel_free_allfunction iio_channel_readfunction iio_read_channel_rawfunction iio_read_channel_average_rawfunction iio_multiply_valuefunction iio_convert_raw_to_processed_unlockedfunction iio_convert_raw_to_processedfunction iio_read_channel_attributefunction iio_read_channel_offsetfunction iio_read_channel_processed_scalefunction iio_read_channel_processedfunction iio_read_channel_scalefunction iio_channel_read_availfunction iio_read_avail_channel_attributefunction iio_read_avail_channel_rawfunction iio_channel_read_maxfunction iio_read_max_channel_rawfunction iio_channel_read_minfunction iio_read_min_channel_rawfunction iio_get_channel_typefunction iio_channel_writefunction iio_write_channel_attributefunction iio_write_channel_rawfunction iio_get_channel_ext_info_countfunction iio_lookup_ext_infofunction iio_read_channel_ext_infofunction iio_write_channel_ext_infofunction iio_read_channel_labelexport iio_map_array_registerexport iio_map_array_unregisterexport devm_iio_map_array_registerexport fwnode_iio_channel_get_by_nameexport iio_channel_getexport iio_channel_release
Annotated Snippet
struct iio_map_internal {
struct iio_dev *indio_dev;
const struct iio_map *map;
struct list_head l;
};
static LIST_HEAD(iio_map_list);
static DEFINE_MUTEX(iio_map_list_lock);
static int iio_map_array_unregister_locked(struct iio_dev *indio_dev)
{
int ret = -ENODEV;
struct iio_map_internal *mapi, *next;
list_for_each_entry_safe(mapi, next, &iio_map_list, l) {
if (indio_dev == mapi->indio_dev) {
list_del(&mapi->l);
kfree(mapi);
ret = 0;
}
}
return ret;
}
int iio_map_array_register(struct iio_dev *indio_dev, const struct iio_map *maps)
{
struct iio_map_internal *mapi;
int i = 0;
int ret;
if (!maps)
return 0;
guard(mutex)(&iio_map_list_lock);
while (maps[i].consumer_dev_name) {
mapi = kzalloc_obj(*mapi);
if (!mapi) {
ret = -ENOMEM;
goto error_ret;
}
mapi->map = &maps[i];
mapi->indio_dev = indio_dev;
list_add_tail(&mapi->l, &iio_map_list);
i++;
}
return 0;
error_ret:
iio_map_array_unregister_locked(indio_dev);
return ret;
}
EXPORT_SYMBOL_GPL(iio_map_array_register);
/*
* Remove all map entries associated with the given iio device
*/
int iio_map_array_unregister(struct iio_dev *indio_dev)
{
guard(mutex)(&iio_map_list_lock);
return iio_map_array_unregister_locked(indio_dev);
}
EXPORT_SYMBOL_GPL(iio_map_array_unregister);
static void iio_map_array_unregister_cb(void *indio_dev)
{
iio_map_array_unregister(indio_dev);
}
int devm_iio_map_array_register(struct device *dev, struct iio_dev *indio_dev,
const struct iio_map *maps)
{
int ret;
ret = iio_map_array_register(indio_dev, maps);
if (ret)
return ret;
return devm_add_action_or_reset(dev, iio_map_array_unregister_cb, indio_dev);
}
EXPORT_SYMBOL_GPL(devm_iio_map_array_register);
static const struct iio_chan_spec
*iio_chan_spec_from_name(const struct iio_dev *indio_dev, const char *name)
{
int i;
const struct iio_chan_spec *chan = NULL;
for (i = 0; i < indio_dev->num_channels; i++)
if (indio_dev->channels[i].datasheet_name &&
strcmp(name, indio_dev->channels[i].datasheet_name) == 0) {
Annotation
- Immediate include surface: `linux/cleanup.h`, `linux/err.h`, `linux/export.h`, `linux/minmax.h`, `linux/mm.h`, `linux/mutex.h`, `linux/property.h`, `linux/slab.h`.
- Detected declarations: `struct iio_map_internal`, `function iio_map_array_unregister_locked`, `function list_for_each_entry_safe`, `function iio_map_array_register`, `function iio_map_array_unregister`, `function iio_map_array_unregister_cb`, `function devm_iio_map_array_register`, `function num_channels`, `function __fwnode_iio_channel_get`, `function __fwnode_iio_channel_get_by_name`.
- 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.