Separate connection creation from enabling.
This will ultimately allow connection structures to be created while
parsing manifests, but the connections to not be enabled until a driver
is bound.
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
static int gb_connection_bind_protocol(struct gb_connection *connection);
static void gb_connection_unbind_protocol(struct gb_connection *connection);
-static int gb_connection_init(struct gb_connection *connection);
static DEFINE_SPINLOCK(gb_connections_lock);
struct gb_connection *connection;
struct ida *id_map = &hd->cport_id_map;
int ida_start, ida_end;
- int retval;
u8 major = 0;
u8 minor = 1;
spin_unlock_irq(&gb_connections_lock);
- retval = gb_connection_init(connection);
- if (retval) {
- dev_err(&hd->dev, "%s: failed to initialize connection: %d\n",
- connection->name, retval);
- gb_connection_destroy(connection);
- return NULL;
- }
-
return connection;
err_free_connection:
return 0;
}
-static int gb_connection_init(struct gb_connection *connection)
+int gb_connection_init(struct gb_connection *connection)
{
int ret;
return !connection->intf;
}
+int gb_connection_init(struct gb_connection *connection);
+
void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id,
u8 *data, size_t length);
return ret;
}
+ ret = gb_connection_init(hd->svc_connection);
+ if (ret) {
+ gb_connection_destroy(hd->svc_connection);
+ device_del(&hd->dev);
+ return ret;
+ }
+
return 0;
}
EXPORT_SYMBOL_GPL(gb_hd_add);
return -ENOMEM;
}
+ ret = gb_connection_init(connection);
+ if (ret) {
+ gb_connection_destroy(connection);
+ return ret;
+ }
+
/* Get manifest size using control protocol on CPort */
size = gb_control_get_manifest_size_operation(intf);
if (size <= 0) {
*/
static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
{
+ struct gb_connection *connection;
struct gb_interface *intf = bundle->intf;
struct manifest_desc *desc;
struct manifest_desc *next;
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) {
/* Found one. Set up its function structure */
protocol_id = desc_cport->protocol_id;
- if (!gb_connection_create_dynamic(intf, bundle, cport_id,
- protocol_id))
+ connection = gb_connection_create_dynamic(intf, bundle,
+ cport_id,
+ protocol_id);
+ if (!connection)
goto exit;
+ ret = gb_connection_init(connection);
+ if (ret) {
+ gb_connection_destroy(connection);
+ goto exit;
+ }
+
count++;
/* Release the cport descriptor */