2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-23 20:53:53 +08:00

greybus: manifest interface descriptor parsing

Add support for parsing one or more interface descriptors in a module
manifest.  There must be at least one, but we impose no limit on the
number of interfaces associated with a module.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
This commit is contained in:
Alex Elder 2014-10-01 21:54:17 -05:00 committed by Greg Kroah-Hartman
parent b09c94a1b7
commit d88bfb5b7d

View File

@ -171,6 +171,45 @@ static char *gb_string_get(u8 string_id)
return string;
}
/*
* Find interface descriptors in the manifest and set up their data
* structures. Returns the number of interfaces set up for the
* given module.
*/
static u32 gb_manifest_parse_interfaces(struct gb_module *gmod)
{
u32 count = 0;
while (true) {
struct manifest_desc *descriptor;
struct greybus_descriptor_interface *desc_interface;
struct gb_interface *interface;
bool found = false;
/* Find an interface descriptor */
list_for_each_entry(descriptor, &manifest_descs, links) {
if (descriptor->type == GREYBUS_TYPE_DEVICE) {
found = true;
break;
}
}
if (!found)
break;
/* Found one. Set up its interface structure*/
desc_interface = descriptor->data;
interface = gb_interface_create(gmod, desc_interface->id);
if (!interface)
return 0; /* Error */
count++;
/* Done with this interface descriptor */
release_manifest_descriptor(descriptor);
}
return count;
}
struct gb_module *gb_manifest_parse_module(struct manifest_desc *module_desc)
{
struct greybus_descriptor *desc = module_desc->data;
@ -202,6 +241,13 @@ struct gb_module *gb_manifest_parse_module(struct manifest_desc *module_desc)
/* Release the module descriptor, now that we're done with it */
release_manifest_descriptor(module_desc);
/* A module must have at least one interface descriptor */
if (!gb_manifest_parse_interfaces(gmod)) {
pr_err("manifest interface descriptors not valid\n");
gb_module_destroy(gmod);
return NULL;
}
return gmod;
}