From 9a6e5e12be416bf996adee17b1a59d0428fa40d4 Mon Sep 17 00:00:00 2001 From: Srinivasarao Pathipati Date: Mon, 10 Oct 2022 14:47:07 +0530 Subject: [PATCH] virt: haven: rm_core: Remove current_recv_buffer tracking current_recv_buffer tracks the current end of an ongoing message from resource manager. It can be easily tracked by "conection->recv_buff + connection->recv_buff_size". Do that instead to make code clearer. Change-Id: I191dbdbf39c802868e1c6a262ef5420c02f127b2 Signed-off-by: Elliot Berman Signed-off-by: Srinivasarao Pathipati --- drivers/virt/haven/hh_rm_core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/virt/haven/hh_rm_core.c b/drivers/virt/haven/hh_rm_core.c index c4246b6ca3f6..2f7bbc5921bc 100644 --- a/drivers/virt/haven/hh_rm_core.c +++ b/drivers/virt/haven/hh_rm_core.c @@ -48,7 +48,6 @@ struct hh_rm_connection { u8 num_fragments; u8 fragments_received; - void *current_recv_buff; }; static struct task_struct *hh_rm_drv_recv_task; @@ -92,6 +91,9 @@ hh_rm_init_connection_buff(struct hh_rm_connection *connection, struct hh_rm_rpc_hdr *hdr = recv_buff; size_t max_buf_size; + connection->num_fragments = hdr->fragments; + connection->fragments_received = 0; + /* Some of the 'reply' types doesn't contain any payload */ if (!payload_size) return 0; @@ -107,15 +109,12 @@ hh_rm_init_connection_buff(struct hh_rm_connection *connection, /* If the data is split into multiple fragments, allocate a large * enough buffer to hold the payloads for all the fragments. */ - connection->recv_buff = connection->current_recv_buff = - kzalloc(max_buf_size, GFP_KERNEL); + connection->recv_buff = kzalloc(max_buf_size, GFP_KERNEL); if (!connection->recv_buff) return -ENOMEM; memcpy(connection->recv_buff, recv_buff + hdr_size, payload_size); - connection->current_recv_buff += payload_size; connection->recv_buff_size = payload_size; - connection->num_fragments = hdr->fragments; return 0; } @@ -352,9 +351,8 @@ static int hh_rm_process_cont(void *recv_buff, size_t recv_buff_size) payload_size = recv_buff_size - sizeof(*hdr); /* Keep appending the data to the previous fragment's end */ - memcpy(connection->current_recv_buff, + memcpy(connection->recv_buff + connection->recv_buff_size, recv_buff + sizeof(*hdr), payload_size); - connection->current_recv_buff += payload_size; connection->recv_buff_size += payload_size; connection->fragments_received++;