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: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/drivers/staging/greybus/bundle.c b/drivers/staging/greybus/bundle.c
index 5ced992..47a3413 100644
--- a/drivers/staging/greybus/bundle.c
+++ b/drivers/staging/greybus/bundle.c
@@ -80,7 +80,8 @@
* 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 @@
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 @@
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;
diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h
index 62969cf..385c90a 100644
--- a/drivers/staging/greybus/bundle.h
+++ b/drivers/staging/greybus/bundle.h
@@ -17,6 +17,7 @@
struct device dev;
struct gb_interface *intf;
u8 id;
+ u8 class_type;
u8 device_id;
struct list_head connections;
@@ -27,7 +28,8 @@
#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);
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c
index c00e378..8541a2a 100644
--- a/drivers/staging/greybus/manifest.c
+++ b/drivers/staging/greybus/manifest.c
@@ -108,6 +108,9 @@
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 @@
/*
* 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 @@
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 @@
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 */