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);
/* A zero string id means no string (but no error) */ if (!string_id) return NULL;
list_for_each_entry(descriptor, &intf->manifest_descs, links) { if (descriptor->type != GREYBUS_TYPE_STRING) continue;
desc_string = descriptor->data; if (desc_string->id == string_id) {
found = true; break;
}
} if (!found) return ERR_PTR(-ENOENT);
/* Allocate an extra byte so we can guarantee it's NUL-terminated */
string = kmemdup(&desc_string->string, desc_string->length + 1,
GFP_KERNEL); if (!string) return ERR_PTR(-ENOMEM);
string[desc_string->length] = '\0';
/* Ok we've used this string, so we're done with it */
release_manifest_descriptor(descriptor);
/* Set up all cport descriptors associated with this bundle */
list_for_each_entry_safe(desc, next, &intf->manifest_descs, links) { if (desc->type != GREYBUS_TYPE_CPORT) continue;
desc_cport = desc->data; if (desc_cport->bundle != bundle_id) continue;
cport_id = le16_to_cpu(desc_cport->id); if (cport_id > CPORT_ID_MAX) gotoexit;
/* Nothing else should have its cport_id as control cport id */ if (cport_id == GB_CONTROL_CPORT_ID) {
dev_err(&bundle->dev, "invalid cport id found (%02u)\n",
cport_id); gotoexit;
}
while ((desc = get_next_bundle_desc(intf))) { struct greybus_descriptor_bundle *desc_bundle;
/* Found one. Set up its bundle structure*/
desc_bundle = desc->data;
bundle_id = desc_bundle->id; class = desc_bundle->class;
/* Done with this bundle descriptor */
release_manifest_descriptor(desc);
/* Ignore any legacy control bundles */ if (bundle_id == GB_CONTROL_BUNDLE_ID) {
dev_dbg(&intf->dev, "%s - ignoring control bundle\n",
__func__);
release_cport_descriptors(&intf->manifest_descs,
bundle_id); continue;
}
/* Nothing else should have its class set to control class */ if (class == GREYBUS_CLASS_CONTROL) {
dev_err(&intf->dev, "bundle %u cannot use control class\n",
bundle_id); goto cleanup;
}
bundle = gb_bundle_create(intf, bundle_id, class); if (!bundle) goto cleanup;
/* Release the interface descriptor, now that we're done with it */
release_manifest_descriptor(interface_desc);
/* An interface must have at least one bundle descriptor */ if (!gb_manifest_parse_bundles(intf)) {
dev_err(&intf->dev, "manifest bundle descriptors not valid\n"); goto out_err;
}
/* Manifest descriptor list should be empty here */ if (WARN_ON(!list_empty(&intf->manifest_descs))) returnfalse;
/* we have to have at _least_ the manifest header */ if (size < sizeof(*header)) {
dev_err(&intf->dev, "short manifest (%zu < %zu)\n",
size, sizeof(*header)); returnfalse;
}
/* Make sure the size is right */
manifest = data;
header = &manifest->header;
manifest_size = le16_to_cpu(header->size); if (manifest_size != size) {
dev_err(&intf->dev, "manifest size mismatch (%zu != %u)\n",
size, manifest_size); returnfalse;
}
/* Validate major/minor number */ if (header->version_major > GREYBUS_VERSION_MAJOR) {
dev_err(&intf->dev, "manifest version too new (%u.%u > %u.%u)\n",
header->version_major, header->version_minor,
GREYBUS_VERSION_MAJOR, GREYBUS_VERSION_MINOR); returnfalse;
}
/* OK, find all the descriptors */
desc = manifest->descriptors;
size -= sizeof(*header); while (size) { int desc_size;
/* There must be a single interface descriptor */
list_for_each_entry(descriptor, &intf->manifest_descs, links) { if (descriptor->type == GREYBUS_TYPE_INTERFACE) if (!found++)
interface_desc = descriptor;
} if (found != 1) {
dev_err(&intf->dev, "manifest must have 1 interface descriptor (%u found)\n",
found);
result = false; goto out;
}
/* Parse the manifest, starting with the interface descriptor */
result = gb_manifest_parse_interface(intf, interface_desc);
/* *Wereallyshouldhavenoremainingdescriptors,butwe *don'tknowwhatnewerformatmanifestsmightleave.
*/ if (result && !list_empty(&intf->manifest_descs))
dev_info(&intf->dev, "excess descriptors in interface manifest\n");
out:
release_manifest_descriptors(intf);
return result;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-09-30)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.