greybus: Revert "manifest: remove extra loop for finding module descriptor"

This reverts commit 4d1529e6687d53878b71cdcd646e28e10d62c2e8.

Alex reports that this causes problems.

Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Greg Kroah-Hartman 2014-11-14 14:37:56 -08:00
parent b7be8d2eb3
commit 86bf33afa3

View File

@ -54,8 +54,7 @@ static void release_manifest_descriptors(void)
* Returns the number of bytes consumed by the descriptor, or a * Returns the number of bytes consumed by the descriptor, or a
* negative errno. * negative errno.
*/ */
static int identify_descriptor(struct greybus_descriptor *desc, size_t size, static int identify_descriptor(struct greybus_descriptor *desc, size_t size)
bool *is_module)
{ {
struct greybus_descriptor_header *desc_header = &desc->header; struct greybus_descriptor_header *desc_header = &desc->header;
struct manifest_desc *descriptor; struct manifest_desc *descriptor;
@ -80,7 +79,6 @@ static int identify_descriptor(struct greybus_descriptor *desc, size_t size,
desc_size); desc_size);
return -EINVAL; return -EINVAL;
} }
*is_module = true;
break; break;
case GREYBUS_TYPE_STRING: case GREYBUS_TYPE_STRING:
expected_size = sizeof(struct greybus_descriptor_header); expected_size = sizeof(struct greybus_descriptor_header);
@ -311,7 +309,7 @@ out_free_vendor_string:
* the descriptors it contains, keeping track for each its type * the descriptors it contains, keeping track for each its type
* and the location size of its data in the buffer. * and the location size of its data in the buffer.
* *
* We also identify the module descriptor during this iteration, * Next we scan the descriptors, looking for a module descriptor;
* there must be exactly one of those. When found, we record the * there must be exactly one of those. When found, we record the
* information it contains, and then remove that descriptor (and any * information it contains, and then remove that descriptor (and any
* string descriptors it refers to) from further consideration. * string descriptors it refers to) from further consideration.
@ -365,9 +363,8 @@ bool gb_manifest_parse(struct gb_module *gmod, void *data, size_t size)
size -= sizeof(*header); size -= sizeof(*header);
while (size) { while (size) {
int desc_size; int desc_size;
bool is_module = false;
desc_size = identify_descriptor(desc, size, &is_module); desc_size = identify_descriptor(desc, size);
if (desc_size <= 0) { if (desc_size <= 0) {
if (!desc_size) if (!desc_size)
pr_err("zero-sized manifest descriptor\n"); pr_err("zero-sized manifest descriptor\n");
@ -376,17 +373,19 @@ bool gb_manifest_parse(struct gb_module *gmod, void *data, size_t size)
} }
desc = (struct greybus_descriptor *)((char *)desc + desc_size); desc = (struct greybus_descriptor *)((char *)desc + desc_size);
size -= desc_size; size -= desc_size;
}
if (is_module) { /* There must be a single module descriptor */
if (++found > 1) { list_for_each_entry(descriptor, &manifest_descs, links) {
pr_err("manifest must have 1 module descriptor (%u found)\n", if (descriptor->type == GREYBUS_TYPE_MODULE)
found); if (!found++)
result = false;
goto out;
} else {
module_desc = descriptor; module_desc = descriptor;
} }
} if (found != 1) {
pr_err("manifest must have 1 module descriptor (%u found)\n",
found);
result = false;
goto out;
} }
/* Parse the module manifest, starting with the module descriptor */ /* Parse the module manifest, starting with the module descriptor */