u8 class)
{
struct gb_bundle *bundle;
- int retval;
/*
* Reject any attempt to reuse a bundle id. We initialize
bundle->class = class;
INIT_LIST_HEAD(&bundle->connections);
- /* Build up the bundle device structures and register it with the
- * driver core */
bundle->dev.parent = &intf->dev;
bundle->dev.bus = &greybus_bus_type;
bundle->dev.type = &greybus_bundle_type;
device_initialize(&bundle->dev);
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 %u\n", bundle_id);
- put_device(&bundle->dev);
- return NULL;
- }
-
list_add(&bundle->links, &intf->bundles);
return bundle;
}
+int gb_bundle_add(struct gb_bundle *bundle)
+{
+ int ret;
+
+ ret = device_add(&bundle->dev);
+ if (ret) {
+ dev_err(&bundle->dev, "failed to register bundle: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
static void gb_bundle_connections_exit(struct gb_bundle *bundle)
{
struct gb_connection *connection;
*/
void gb_bundle_destroy(struct gb_bundle *bundle)
{
- list_del(&bundle->links);
-
gb_bundle_connections_exit(bundle);
- device_unregister(&bundle->dev);
-}
+ if (device_is_registered(&bundle->dev))
+ device_del(&bundle->dev);
+ list_del(&bundle->links);
+
+ put_device(&bundle->dev);
+}
u8 protocol_id;
u16 cport_id;
u32 count = 0;
- int ret;
/* Set up all cport descriptors associated with this bundle */
list_for_each_entry_safe(desc, next, &intf->manifest_descs, links) {
if (!connection)
goto exit;
- ret = gb_connection_init(connection);
- if (ret) {
- gb_connection_destroy(connection);
- goto exit;
- }
-
count++;
/* Release the cport descriptor */
*/
static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
{
+ struct gb_connection *connection;
struct manifest_desc *desc;
struct gb_bundle *bundle;
struct gb_bundle *bundle_next;
u32 count = 0;
u8 bundle_id;
u8 class;
+ int ret;
while ((desc = get_next_bundle_desc(intf))) {
struct greybus_descriptor_bundle *desc_bundle;
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++;
}