probe: refactor function to decrease indent

following commit fixes a bug but to do the fix we need to allow
ourselves more room to add ifs, so lets pull out this function

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
This commit is contained in:
Curtis Malainey 2021-06-02 16:14:26 -07:00 committed by Liam Girdwood
parent 8cec7d3ef1
commit ead5afa6c2
1 changed files with 13 additions and 8 deletions

View File

@ -176,6 +176,18 @@ int validate_data_packet(struct probe_data_packet *data_packet)
}
}
int process_sync(struct probe_data_packet *packet, uint32_t **w_ptr, uint32_t *total_data_to_copy)
{
/* request to copy data_size from probe packet */
*total_data_to_copy = packet->data_size_bytes /
sizeof(uint32_t);
if (packet->data_size_bytes > PACKET_MAX_SIZE)
packet = realloc(packet,
sizeof(struct probe_data_packet) + packet->data_size_bytes);
*w_ptr = (uint32_t *)&packet->data;
return 0;
}
void parse_data(char *file_in)
{
FILE *fd_in;
@ -250,14 +262,7 @@ void parse_data(char *file_in)
break;
case SYNC:
/* SYNC -> CHECK */
/* request to copy data_size from probe packet */
total_data_to_copy = packet->data_size_bytes /
sizeof(uint32_t);
if (packet->data_size_bytes > PACKET_MAX_SIZE)
packet = realloc(packet,
sizeof(struct probe_data_packet) +
packet->data_size_bytes);
w_ptr = (uint32_t *)&packet->data;
process_sync(packet, &w_ptr, &total_data_to_copy);
state = CHECK;
break;
case CHECK: