/* Calculate block index based on data buffer pointer and validate it. */
static int buffer_to_index_validate(const struct channel_config *ch_conf, const uint8_t *buffer, size_t *size)
/* Calculate block index based on data buffer pointer and validate it. */
static int buffer_to_index_validate(const struct channel_config *ch_conf, const uint8_t *buffer, size_t *size)
{
	size_t block_index;
	uint8_t *expected;
	block_index = (buffer - ch_conf->blocks_ptr) / ch_conf->block_size;
	expected = buffer_from_index_validate(ch_conf, block_index, size, false);
	if (expected == NULL || expected != buffer) {
		LOG_ERR("Pointer invalid");
		return -EINVAL;
	}
	return block_index;
}