Commit a6b13eb6 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: manifest: rework cport parsing

Rework the the code that parses the manifest for CPorts associated
with a bundle so it only touches each manifest descriptor once.
(Previously the list was scanned from the beginning repeatedly
until all bundle CPorts were found.)  Shorten the name of the
descriptor variable, to avoid line wrap.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent c46839d1
...@@ -201,27 +201,23 @@ static char *gb_string_get(struct gb_interface *intf, u8 string_id) ...@@ -201,27 +201,23 @@ static char *gb_string_get(struct gb_interface *intf, u8 string_id)
static u32 gb_manifest_parse_cports(struct gb_bundle *bundle) static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
{ {
struct gb_interface *intf = bundle->intf; struct gb_interface *intf = bundle->intf;
struct manifest_desc *desc;
struct manifest_desc *next;
u8 bundle_id = bundle->id;
u32 count = 0; u32 count = 0;
while (true) { /* Set up all cport descriptors associated with this bundle */
struct manifest_desc *descriptor; list_for_each_entry_safe(desc, next, &intf->manifest_descs, links) {
struct greybus_descriptor_cport *desc_cport; struct greybus_descriptor_cport *desc_cport;
u8 protocol_id; u8 protocol_id;
u16 cport_id; u16 cport_id;
bool found = false;
/* Find a cport descriptor */ if (desc->type != GREYBUS_TYPE_CPORT)
list_for_each_entry(descriptor, &intf->manifest_descs, links) { continue;
if (descriptor->type == GREYBUS_TYPE_CPORT) {
desc_cport = descriptor->data; desc_cport = desc->data;
if (desc_cport->bundle == bundle->id) { if (desc_cport->bundle != bundle_id)
found = true; continue;
break;
}
}
}
if (!found)
break;
/* Found one. Set up its function structure */ /* Found one. Set up its function structure */
protocol_id = desc_cport->protocol_id; protocol_id = desc_cport->protocol_id;
...@@ -230,8 +226,9 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle) ...@@ -230,8 +226,9 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
return 0; /* Error */ return 0; /* Error */
count++; count++;
/* Release the cport descriptor */ /* Release the cport descriptor */
release_manifest_descriptor(descriptor); release_manifest_descriptor(desc);
} }
return count; return count;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment