drivers/greybus/manifest.c
Source file repositories/reference/linux-study-clean/drivers/greybus/manifest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/greybus/manifest.c- Extension
.c- Size
- 14712 bytes
- Lines
- 533
- Domain
- Driver Families
- Bucket
- drivers/greybus
- 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/greybus.h
Detected Declarations
struct manifest_descfunction release_manifest_descriptorfunction release_manifest_descriptorsfunction release_cport_descriptorsfunction list_for_each_entry_safefunction thefunction validfunction list_for_each_entryfunction gb_manifest_parse_cportsfunction list_for_each_entryfunction gb_manifest_parse_bundlesfunction gb_manifest_parse_interfacefunction gb_manifest_parse
Annotated Snippet
struct manifest_desc {
struct list_head links;
size_t size;
void *data;
enum greybus_descriptor_type type;
};
static void release_manifest_descriptor(struct manifest_desc *descriptor)
{
list_del(&descriptor->links);
kfree(descriptor);
}
static void release_manifest_descriptors(struct gb_interface *intf)
{
struct manifest_desc *descriptor;
struct manifest_desc *next;
list_for_each_entry_safe(descriptor, next, &intf->manifest_descs, links)
release_manifest_descriptor(descriptor);
}
static void release_cport_descriptors(struct list_head *head, u8 bundle_id)
{
struct manifest_desc *desc, *tmp;
struct greybus_descriptor_cport *desc_cport;
list_for_each_entry_safe(desc, tmp, head, links) {
desc_cport = desc->data;
if (desc->type != GREYBUS_TYPE_CPORT)
continue;
if (desc_cport->bundle == bundle_id)
release_manifest_descriptor(desc);
}
}
static struct manifest_desc *get_next_bundle_desc(struct gb_interface *intf)
{
struct manifest_desc *descriptor;
struct manifest_desc *next;
list_for_each_entry_safe(descriptor, next, &intf->manifest_descs, links)
if (descriptor->type == GREYBUS_TYPE_BUNDLE)
return descriptor;
return NULL;
}
/*
* Validate the given descriptor. Its reported size must fit within
* the number of bytes remaining, and it must have a recognized
* type. Check that the reported size is at least as big as what
* we expect to see. (It could be bigger, perhaps for a new version
* of the format.)
*
* Returns the (non-zero) number of bytes consumed by the descriptor,
* or a negative errno.
*/
static int identify_descriptor(struct gb_interface *intf,
struct greybus_descriptor *desc, size_t size)
{
struct greybus_descriptor_header *desc_header = &desc->header;
struct manifest_desc *descriptor;
size_t desc_size;
size_t expected_size;
if (size < sizeof(*desc_header)) {
dev_err(&intf->dev, "manifest too small (%zu < %zu)\n", size,
sizeof(*desc_header));
return -EINVAL; /* Must at least have header */
}
desc_size = le16_to_cpu(desc_header->size);
if (desc_size > size) {
dev_err(&intf->dev, "descriptor too big (%zu > %zu)\n",
desc_size, size);
return -EINVAL;
}
/* Descriptor needs to at least have a header */
expected_size = sizeof(*desc_header);
switch (desc_header->type) {
case GREYBUS_TYPE_STRING:
expected_size += sizeof(struct greybus_descriptor_string);
expected_size += desc->string.length;
Annotation
- Immediate include surface: `linux/greybus.h`.
- Detected declarations: `struct manifest_desc`, `function release_manifest_descriptor`, `function release_manifest_descriptors`, `function release_cport_descriptors`, `function list_for_each_entry_safe`, `function the`, `function valid`, `function list_for_each_entry`, `function gb_manifest_parse_cports`, `function list_for_each_entry`.
- Atlas domain: Driver Families / drivers/greybus.
- 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.