From: Alex Elder Date: Thu, 2 Oct 2014 17:30:04 +0000 (-0500) Subject: greybus: allocate connection host cport id X-Git-Tag: v4.14-rc1~2366^2~378^2~21^2~2053 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e8a6860f5d113b42334b27f12217ee9fb9970f9;p=platform%2Fkernel%2Flinux-rpi.git greybus: allocate connection host cport id Allocate a cport id from the host device whenever creating a connection. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index fa5ab5d..b16ac4c 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -23,7 +23,7 @@ * pointer otherwise. */ struct gb_connection *gb_connection_create(struct greybus_host_device *hd, - u16 cport_id, struct gb_function *function) + struct gb_function *function) { struct gb_connection *connection; @@ -31,8 +31,13 @@ struct gb_connection *gb_connection_create(struct greybus_host_device *hd, if (!connection) return NULL; + connection->cport_id = greybus_hd_cport_id_alloc(hd); + if (connection->cport_id == CPORT_ID_BAD) { + kfree(connection); + return NULL; + } + connection->hd = hd; /* XXX refcount? */ - connection->cport_id = cport_id; connection->function = function; /* XXX refcount? */ INIT_LIST_HEAD(&connection->operations); atomic_set(&connection->op_cycle, 0); @@ -51,6 +56,7 @@ void gb_connection_destroy(struct gb_connection *connection) /* XXX Need to wait for any outstanding requests to complete */ WARN_ON(!list_empty(&connection->operations)); + greybus_hd_cport_id_free(connection->hd, connection->cport_id); /* kref_put(function); */ /* kref_put(hd); */ kfree(connection); diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h index 6094fb4..f06ff92 100644 --- a/drivers/staging/greybus/connection.h +++ b/drivers/staging/greybus/connection.h @@ -25,7 +25,7 @@ struct gb_connection { }; struct gb_connection *gb_connection_create(struct greybus_host_device *hd, - u16 cport_id, struct gb_function *function); + struct gb_function *function); void gb_connection_destroy(struct gb_connection *connection); u16 gb_connection_op_id(struct gb_connection *connection);