Commit 708d07a9 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: interface: separate manifest parsing from bundle registration

Separate manifest parsing, including bundle and connection creation,
from bundle registration.

Note that this is also needed to allow the interface to not be
registered until the manifest has been parsed.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent a7e36d0e
...@@ -162,6 +162,7 @@ void gb_interfaces_remove(struct gb_host_device *hd) ...@@ -162,6 +162,7 @@ void gb_interfaces_remove(struct gb_host_device *hd)
*/ */
int gb_interface_init(struct gb_interface *intf, u8 device_id) int gb_interface_init(struct gb_interface *intf, u8 device_id)
{ {
struct gb_bundle *bundle, *tmp;
struct gb_connection *connection; struct gb_connection *connection;
int ret, size; int ret, size;
void *manifest; void *manifest;
...@@ -215,14 +216,25 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id) ...@@ -215,14 +216,25 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id)
goto free_manifest; goto free_manifest;
} }
/* /* Register the interface bundles. */
* XXX list_for_each_entry_safe_reverse(bundle, tmp, &intf->bundles, links) {
* We've successfully parsed the manifest. Now we need to ret = gb_bundle_add(bundle);
* allocate CPort Id's for connecting to the CPorts found on if (ret) {
* other modules. For each of these, establish a connection gb_bundle_destroy(bundle);
* between the local and remote CPorts (including continue;
* configuring the switch to allow them to communicate). }
*/
list_for_each_entry(connection, &bundle->connections,
bundle_links) {
ret = gb_connection_init(connection);
if (ret)
break;
}
if (ret)
gb_bundle_destroy(bundle);
}
ret = 0;
free_manifest: free_manifest:
kfree(manifest); kfree(manifest);
......
...@@ -286,14 +286,12 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle) ...@@ -286,14 +286,12 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
*/ */
static u32 gb_manifest_parse_bundles(struct gb_interface *intf) static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
{ {
struct gb_connection *connection;
struct manifest_desc *desc; struct manifest_desc *desc;
struct gb_bundle *bundle; struct gb_bundle *bundle;
struct gb_bundle *bundle_next; struct gb_bundle *bundle_next;
u32 count = 0; u32 count = 0;
u8 bundle_id; u8 bundle_id;
u8 class; u8 class;
int ret;
while ((desc = get_next_bundle_desc(intf))) { while ((desc = get_next_bundle_desc(intf))) {
struct greybus_descriptor_bundle *desc_bundle; struct greybus_descriptor_bundle *desc_bundle;
...@@ -349,23 +347,6 @@ static u32 gb_manifest_parse_bundles(struct gb_interface *intf) ...@@ -349,23 +347,6 @@ static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
continue; continue;
} }
ret = gb_bundle_add(bundle);
if (ret) {
gb_bundle_destroy(bundle);
continue;
}
list_for_each_entry(connection, &bundle->connections,
bundle_links) {
ret = gb_connection_init(connection);
if (ret)
break;
}
if (ret) {
gb_bundle_destroy(bundle);
continue;
}
count++; 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