greybus: connection: Create gb_connection_create_range() to specify hd-cport-id range
authorViresh Kumar <viresh.kumar@linaro.org>
Tue, 21 Jul 2015 12:14:15 +0000 (17:44 +0530)
committerGreg Kroah-Hartman <gregkh@google.com>
Wed, 22 Jul 2015 17:11:05 +0000 (10:11 -0700)
We need to allocate specific hd-cport-id for AP's control/svc protocols.
Support that by splitting functionality of gb_connection_create() into a
new routine, which takes range of hd_cport_id's to allocate from.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/connection.c
drivers/staging/greybus/connection.h

index 9187a369bcbba9887fb5b2f3910f34677396c0c5..c6e1d701a6760624989241a2641a6175ea645de2 100644 (file)
@@ -141,8 +141,9 @@ void gb_connection_bind_protocol(struct gb_connection *connection)
  * Returns a pointer to the new connection if successful, or a null
  * pointer otherwise.
  */
-struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
-                               u16 cport_id, u8 protocol_id)
+struct gb_connection *
+gb_connection_create_range(struct gb_bundle *bundle, u16 cport_id,
+                          u8 protocol_id, u32 ida_start, u32 ida_end)
 {
        struct gb_connection *connection;
        struct greybus_host_device *hd = bundle->intf->hd;
@@ -165,7 +166,7 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
        if (!connection)
                return NULL;
 
-       retval = ida_simple_get(id_map, 0, CPORT_ID_MAX, GFP_KERNEL);
+       retval = ida_simple_get(id_map, ida_start, ida_end, GFP_KERNEL);
        if (retval < 0) {
                kfree(connection);
                return NULL;
@@ -221,6 +222,13 @@ struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
        return connection;
 }
 
+struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
+                               u16 cport_id, u8 protocol_id)
+{
+       return gb_connection_create_range(bundle, cport_id, protocol_id, 0,
+                                         CPORT_ID_MAX);
+}
+
 /*
  * Cancel all active operations on a connection.
  *
index fb7a1fb290ac001169febc55b10fbfb6d3a30304..bba14b527fed6466e185e5c06947b94c9ff4bb28 100644 (file)
@@ -47,6 +47,9 @@ struct gb_connection {
 
 struct gb_connection *gb_connection_create(struct gb_bundle *bundle,
                                u16 cport_id, u8 protocol_id);
+struct gb_connection *gb_connection_create_range(struct gb_bundle *bundle,
+                               u16 cport_id, u8 protocol_id, u32 ida_start,
+                               u32 ida_end);
 void gb_connection_destroy(struct gb_connection *connection);
 
 int gb_connection_init(struct gb_connection *connection);