summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/manifest.c
diff options
context:
space:
mode:
authorAlex Elder <elder@linaro.org>2015-06-09 17:42:55 -0500
committerGreg Kroah-Hartman <gregkh@google.com>2015-06-10 10:38:23 -0700
commita6b13eb648fd3d03d45e722f81f26eed9bdecb87 (patch)
treeed962c6c6492b554e1b3750d52c383189648d280 /drivers/staging/greybus/manifest.c
parentc46839d1cc418aad43c66344888cd266b689acf9 (diff)
downloadop-kernel-dev-a6b13eb648fd3d03d45e722f81f26eed9bdecb87.zip
op-kernel-dev-a6b13eb648fd3d03d45e722f81f26eed9bdecb87.tar.gz
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: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/manifest.c')
-rw-r--r--drivers/staging/greybus/manifest.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c
index d20cd80..1b79161 100644
--- a/drivers/staging/greybus/manifest.c
+++ b/drivers/staging/greybus/manifest.c
@@ -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)
{
struct gb_interface *intf = bundle->intf;
+ struct manifest_desc *desc;
+ struct manifest_desc *next;
+ u8 bundle_id = bundle->id;
u32 count = 0;
- while (true) {
- struct manifest_desc *descriptor;
+ /* Set up all cport descriptors associated with this bundle */
+ list_for_each_entry_safe(desc, next, &intf->manifest_descs, links) {
struct greybus_descriptor_cport *desc_cport;
u8 protocol_id;
u16 cport_id;
- bool found = false;
- /* Find a cport descriptor */
- list_for_each_entry(descriptor, &intf->manifest_descs, links) {
- if (descriptor->type == GREYBUS_TYPE_CPORT) {
- desc_cport = descriptor->data;
- if (desc_cport->bundle == bundle->id) {
- found = true;
- break;
- }
- }
- }
- if (!found)
- break;
+ if (desc->type != GREYBUS_TYPE_CPORT)
+ continue;
+
+ desc_cport = desc->data;
+ if (desc_cport->bundle != bundle_id)
+ continue;
/* Found one. Set up its function structure */
protocol_id = desc_cport->protocol_id;
@@ -230,8 +226,9 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
return 0; /* Error */
count++;
+
/* Release the cport descriptor */
- release_manifest_descriptor(descriptor);
+ release_manifest_descriptor(desc);
}
return count;
OpenPOWER on IntegriCloud