/* Send data contained in specified block. It will adjust data size and flush cache if necessary. If sending failed, allocated blocks will be released. */
static int send_block(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, size_t tx_block_index, size_t size)
/* Send data contained in specified block. It will adjust data size and flush cache if necessary. If sending failed, allocated blocks will be released. */
static int send_block(struct backend_data *dev_data, enum msg_type msg_type, uint8_t ept_addr, size_t tx_block_index, size_t size)
{
	struct block_content *block;
	int r;
	block = block_from_index(&dev_data->conf->tx, tx_block_index);
	block->header.size = size;
	__sync_synchronize();
	sys_cache_data_flush_range(block, size + BLOCK_HEADER_SIZE);
	r = send_control_message(dev_data, msg_type, ept_addr, tx_block_index);
	if (r < 0) {
		release_tx_blocks(dev_data, tx_block_index, size, -1);
	}
	return r;
}