Commit 7c183f70 authored by Viresh Kumar's avatar Viresh Kumar Committed by Greg Kroah-Hartman

greybus: bundle: Create bundles using bundle descriptors

Currently we are creating bundles based on interface descriptors. An interface
can have one or more bundles associated with it and so a bundle must be created
based on a bundle descriptor.

Also get class_type from bundle descriptor.
Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 581baacd
......@@ -80,7 +80,8 @@ void gb_bundle_bind_protocols(void)
* bundle. Returns a pointer to the new bundle or a null
* pointer if a failure occurs due to memory exhaustion.
*/
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 interface_id)
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
u8 class_type)
{
struct gb_bundle *bundle;
int retval;
......@@ -90,7 +91,8 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 interface_id)
return NULL;
bundle->intf = intf;
bundle->id = interface_id;
bundle->id = bundle_id;
bundle->class_type = class_type;
INIT_LIST_HEAD(&bundle->connections);
/* Invalid device id to start with */
......@@ -103,12 +105,12 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 interface_id)
bundle->dev.type = &greybus_bundle_type;
bundle->dev.groups = bundle_groups;
device_initialize(&bundle->dev);
dev_set_name(&bundle->dev, "%s:%d", dev_name(&intf->dev), interface_id);
dev_set_name(&bundle->dev, "%s:%d", dev_name(&intf->dev), bundle_id);
retval = device_add(&bundle->dev);
if (retval) {
pr_err("failed to add bundle device for id 0x%02hhx\n",
interface_id);
bundle_id);
put_device(&bundle->dev);
kfree(bundle);
return NULL;
......
......@@ -17,6 +17,7 @@ struct gb_bundle {
struct device dev;
struct gb_interface *intf;
u8 id;
u8 class_type;
u8 device_id;
struct list_head connections;
......@@ -27,7 +28,8 @@ struct gb_bundle {
#define GB_DEVICE_ID_BAD 0xff
/* Greybus "private" definitions" */
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 module_id);
struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,
u8 class_type);
void gb_bundle_destroy(struct gb_interface *intf);
int gb_bundle_init(struct gb_interface *intf, u8 module_id, u8 device_id);
......
......@@ -108,6 +108,9 @@ static int identify_descriptor(struct gb_interface *intf,
break;
case GREYBUS_TYPE_INTERFACE:
break;
case GREYBUS_TYPE_BUNDLE:
expected_size += sizeof(struct greybus_descriptor_bundle);
break;
case GREYBUS_TYPE_CPORT:
expected_size += sizeof(struct greybus_descriptor_cport);
break;
......@@ -237,7 +240,7 @@ static u32 gb_manifest_parse_cports(struct gb_interface *intf,
/*
* Find bundle descriptors in the manifest and set up their data
* structures. Returns the number of bundles set up for the
* given module.
* given interface.
*/
static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
{
......@@ -245,13 +248,13 @@ static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
while (true) {
struct manifest_desc *descriptor;
struct greybus_descriptor_interface *desc_interface;
struct greybus_descriptor_bundle *desc_bundle;
struct gb_bundle *bundle;
bool found = false;
/* Find an bundle descriptor */
list_for_each_entry(descriptor, &intf->manifest_descs, links) {
if (descriptor->type == GREYBUS_TYPE_INTERFACE) {
if (descriptor->type == GREYBUS_TYPE_BUNDLE) {
found = true;
break;
}
......@@ -260,8 +263,9 @@ static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
break;
/* Found one. Set up its bundle structure*/
desc_interface = descriptor->data;
bundle = gb_bundle_create(intf, desc_interface->id);
desc_bundle = descriptor->data;
bundle = gb_bundle_create(intf, desc_bundle->id,
desc_bundle->class_type);
if (!bundle)
return 0; /* Error */
......
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