From: Alex Elder Date: Tue, 18 Nov 2014 19:26:52 +0000 (-0600) Subject: greybus: stop storing hd in message X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3ed67aba9f3b2af83b9b9cf7cd6f7ab25de5acc2;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git greybus: stop storing hd in message The host device pointer doesn't have to be stored in every message. It can be derived by following up the chain of pointers back to the operation's connection. Signed-off-by: Alex Elder Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index 6c082cc16457..23cf745a337a 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -105,10 +105,10 @@ gb_pending_operation_find(struct gb_connection *connection, u16 id) static int gb_message_send(struct gb_message *message, gfp_t gfp_mask) { - struct greybus_host_device *hd = message->hd; + struct gb_connection *connection = message->operation->connection; message->status = -EINPROGRESS; - message->cookie = hd->driver->buffer_send(hd, + message->cookie = connection->hd->driver->buffer_send(connection->hd, message->dest_cport_id, message->buffer, message->buffer_size, @@ -124,10 +124,13 @@ static int gb_message_send(struct gb_message *message, gfp_t gfp_mask) static void gb_message_cancel(struct gb_message *message) { + struct greybus_host_device *hd; + if (message->status != -EINPROGRESS) return; - message->hd->driver->buffer_cancel(message->cookie); + hd = message->operation->connection->hd; + hd->driver->buffer_cancel(message->cookie); } /* @@ -255,7 +258,6 @@ static int gb_operation_message_init(struct gb_operation *operation, if (!message->buffer) return -ENOMEM; message->buffer_size = size; - message->hd = hd; message->dest_cport_id = dest_cport_id; message->status = -EBADR; /* Initial value--means "never set" */ @@ -273,9 +275,13 @@ static int gb_operation_message_init(struct gb_operation *operation, static void gb_operation_message_exit(struct gb_message *message) { + struct greybus_host_device *hd; + + hd = message->operation->connection->hd; + hd->driver->buffer_free(message->buffer); + message->operation = NULL; message->payload = NULL; - message->hd->driver->buffer_free(message->buffer); message->buffer = NULL; message->buffer_size = 0; } diff --git a/drivers/staging/greybus/operation.h b/drivers/staging/greybus/operation.h index 2fcb181749a9..5e068ff9f546 100644 --- a/drivers/staging/greybus/operation.h +++ b/drivers/staging/greybus/operation.h @@ -26,8 +26,8 @@ enum gb_operation_status { struct gb_message { void *payload; + struct gb_operation *operation; - struct greybus_host_device *hd; u16 dest_cport_id; /* Destination CPort id */ int status;