summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2015-12-07 15:05:34 +0100
committerGreg Kroah-Hartman <gregkh@google.com>2015-12-08 15:31:14 -0500
commit0bf1f2441979e290945f4e5af40d76582c61da1e (patch)
tree9656af68832e9aa9594eac0acbbff2c64d5ae66a /drivers
parent36173112354a4f5993d464f95b04d41e1eec10a0 (diff)
downloadop-kernel-dev-0bf1f2441979e290945f4e5af40d76582c61da1e.zip
op-kernel-dev-0bf1f2441979e290945f4e5af40d76582c61da1e.tar.gz
greybus: connection: separate connection creation and enabling
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/greybus/connection.c12
-rw-r--r--drivers/staging/greybus/connection.h2
-rw-r--r--drivers/staging/greybus/hd.c7
-rw-r--r--drivers/staging/greybus/interface.c6
-rw-r--r--drivers/staging/greybus/manifest.c14
5 files changed, 28 insertions, 13 deletions
diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c
index 980244a8..c936502 100644
--- a/drivers/staging/greybus/connection.c
+++ b/drivers/staging/greybus/connection.c
@@ -14,7 +14,6 @@
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);
@@ -125,7 +124,6 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
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;
@@ -194,14 +192,6 @@ gb_connection_create(struct gb_host_device *hd, int hd_cport_id,
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:
@@ -396,7 +386,7 @@ static int gb_connection_protocol_get_version(struct gb_connection *connection)
return 0;
}
-static int gb_connection_init(struct gb_connection *connection)
+int gb_connection_init(struct gb_connection *connection)
{
int ret;
diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h
index 77f77bf..329b705 100644
--- a/drivers/staging/greybus/connection.h
+++ b/drivers/staging/greybus/connection.h
@@ -63,6 +63,8 @@ static inline bool gb_connection_is_static(struct gb_connection *connection)
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);
diff --git a/drivers/staging/greybus/hd.c b/drivers/staging/greybus/hd.c
index b280925..74569a3 100644
--- a/drivers/staging/greybus/hd.c
+++ b/drivers/staging/greybus/hd.c
@@ -124,6 +124,13 @@ int gb_hd_add(struct gb_host_device *hd)
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);
diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c
index 9ff7464..e8eed85 100644
--- a/drivers/staging/greybus/interface.c
+++ b/drivers/staging/greybus/interface.c
@@ -180,6 +180,12 @@ int gb_interface_init(struct gb_interface *intf, u8 device_id)
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) {
diff --git a/drivers/staging/greybus/manifest.c b/drivers/staging/greybus/manifest.c
index 72400e3..2d47050 100644
--- a/drivers/staging/greybus/manifest.c
+++ b/drivers/staging/greybus/manifest.c
@@ -228,6 +228,7 @@ static char *gb_string_get(struct gb_interface *intf, u8 string_id)
*/
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;
@@ -235,6 +236,7 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
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) {
@@ -254,10 +256,18 @@ static u32 gb_manifest_parse_cports(struct gb_bundle *bundle)
/* 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 */
OpenPOWER on IntegriCloud