drivers/media/v4l2-core/v4l2-fwnode.c
Source file repositories/reference/linux-study-clean/drivers/media/v4l2-core/v4l2-fwnode.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/v4l2-core/v4l2-fwnode.c- Extension
.c- Size
- 33973 bytes
- Lines
- 1310
- Domain
- Driver Families
- Bucket
- drivers/media
- 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/acpi.hlinux/kernel.hlinux/mm.hlinux/module.hlinux/of.hlinux/property.hlinux/slab.hlinux/string.hlinux/types.hmedia/v4l2-async.hmedia/v4l2-fwnode.hmedia/v4l2-subdev.hv4l2-subdev-priv.h
Detected Declarations
struct v4l2_fwnode_int_propsfunction get_v4l2_fwnode_bus_conv_by_fwnode_busfunction v4l2_fwnode_bus_type_to_mbusfunction v4l2_fwnode_bus_type_to_stringfunction get_v4l2_fwnode_bus_conv_by_mbusfunction v4l2_fwnode_mbus_type_to_stringfunction v4l2_fwnode_endpoint_parse_csi2_busfunction v4l2_fwnode_endpoint_parse_parallel_busfunction v4l2_fwnode_endpoint_parse_csi1_busfunction __v4l2_fwnode_endpoint_parsefunction v4l2_fwnode_endpoint_parsefunction v4l2_fwnode_endpoint_freefunction v4l2_fwnode_endpoint_alloc_parsefunction v4l2_fwnode_parse_linkfunction v4l2_fwnode_put_linkfunction v4l2_fwnode_string_to_connector_typefunction v4l2_fwnode_connector_parse_analogfunction v4l2_fwnode_connector_freefunction list_for_each_entry_safefunction v4l2_fwnode_get_connector_typefunction v4l2_fwnode_connector_parsefunction v4l2_fwnode_connector_add_linkfunction v4l2_fwnode_device_parsefunction v4l2_fwnode_reference_parsefunction endpointfunction v4l2_fwnode_reference_get_int_propfunction fwnode_for_each_child_nodefunction v4l2_fwnode_reference_parse_int_propsfunction v4l2_async_nf_releasefunction __v4l2_async_register_subdev_sensorexport v4l2_fwnode_endpoint_parseexport v4l2_fwnode_endpoint_freeexport v4l2_fwnode_endpoint_alloc_parseexport v4l2_fwnode_parse_linkexport v4l2_fwnode_put_linkexport v4l2_fwnode_connector_freeexport v4l2_fwnode_connector_parseexport v4l2_fwnode_connector_add_linkexport v4l2_fwnode_device_parseexport __v4l2_async_register_subdev_sensor
Annotated Snippet
struct v4l2_fwnode_int_props {
const char *name;
const char * const *props;
unsigned int nprops;
};
/*
* v4l2_fwnode_reference_parse_int_props - parse references for async
* sub-devices
* @dev: struct device pointer
* @notifier: notifier for @dev
* @prop: the name of the property
* @props: the array of integer property names
* @nprops: the number of integer properties
*
* Use v4l2_fwnode_reference_get_int_prop to find fwnodes through reference in
* property @prop with integer arguments with child nodes matching in properties
* @props. Then, set up V4L2 async sub-devices for those fwnodes in the notifier
* accordingly.
*
* While it is technically possible to use this function on DT, it is only
* meaningful on ACPI. On Device tree you can refer to any node in the tree but
* on ACPI the references are limited to devices.
*
* Return: 0 on success
* -ENOENT if no entries (or the property itself) were found
* -EINVAL if property parsing otherwisefailed
* -ENOMEM if memory allocation failed
*/
static int
v4l2_fwnode_reference_parse_int_props(struct device *dev,
struct v4l2_async_notifier *notifier,
const struct v4l2_fwnode_int_props *p)
{
struct fwnode_handle *fwnode;
unsigned int index;
int ret;
const char *prop = p->name;
const char * const *props = p->props;
unsigned int nprops = p->nprops;
index = 0;
do {
fwnode = v4l2_fwnode_reference_get_int_prop(dev_fwnode(dev),
prop, index,
props, nprops);
if (IS_ERR(fwnode)) {
/*
* Note that right now both -ENODATA and -ENOENT may
* signal out-of-bounds access. Return the error in
* cases other than that.
*/
if (PTR_ERR(fwnode) != -ENOENT &&
PTR_ERR(fwnode) != -ENODATA)
return PTR_ERR(fwnode);
break;
}
fwnode_handle_put(fwnode);
index++;
} while (1);
for (index = 0;
!IS_ERR((fwnode = v4l2_fwnode_reference_get_int_prop(dev_fwnode(dev),
prop, index,
props,
nprops)));
index++) {
struct v4l2_async_connection *asd;
asd = v4l2_async_nf_add_fwnode(notifier, fwnode,
struct v4l2_async_connection);
fwnode_handle_put(fwnode);
if (IS_ERR(asd)) {
ret = PTR_ERR(asd);
/* not an error if asd already exists */
if (ret == -EEXIST)
continue;
return PTR_ERR(asd);
}
}
return !fwnode || PTR_ERR(fwnode) == -ENOENT ? 0 : PTR_ERR(fwnode);
}
/**
* v4l2_async_nf_parse_fwnode_sensor - parse common references on
* sensors for async sub-devices
* @dev: the device node the properties of which are parsed for references
* @notifier: the async notifier where the async subdevs will be added
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/kernel.h`, `linux/mm.h`, `linux/module.h`, `linux/of.h`, `linux/property.h`, `linux/slab.h`, `linux/string.h`.
- Detected declarations: `struct v4l2_fwnode_int_props`, `function get_v4l2_fwnode_bus_conv_by_fwnode_bus`, `function v4l2_fwnode_bus_type_to_mbus`, `function v4l2_fwnode_bus_type_to_string`, `function get_v4l2_fwnode_bus_conv_by_mbus`, `function v4l2_fwnode_mbus_type_to_string`, `function v4l2_fwnode_endpoint_parse_csi2_bus`, `function v4l2_fwnode_endpoint_parse_parallel_bus`, `function v4l2_fwnode_endpoint_parse_csi1_bus`, `function __v4l2_fwnode_endpoint_parse`.
- Atlas domain: Driver Families / drivers/media.
- 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.