/* Validate the buffer size with adc channels mask. If it is lower than what we need return -ENOSPC.  */
static int adc_npcx_validate_buffer_size(const struct device *dev, const struct adc_sequence *sequence)
/* Validate the buffer size with adc channels mask. If it is lower than what we need return -ENOSPC.  */
static int adc_npcx_validate_buffer_size(const struct device *dev, const struct adc_sequence *sequence)
{
	const struct adc_npcx_config *config = dev->config;
	uint8_t channels = 0;
	uint32_t mask;
	size_t needed;
	for (mask = BIT(config->channel_count - 1); mask != 0; mask >>= 1) {
		if (mask & sequence->channels) {
			channels++;
		}
	}
	needed = channels * sizeof(uint16_t);
	if (sequence->options) {
		needed *= (1 + sequence->options->extra_samplings);
	}
	if (sequence->buffer_size < needed) {
		return -ENOSPC;
	}
	return 0;
}