/* Helper function for checking if particular entity is a part of the audio device. 
This function checks if given entity is a part of given audio device. If so then true is returned and audio_dev_data is considered correct device data. */
static bool is_entity_valid(struct usb_audio_dev_data *audio_dev_data, struct usb_audio_entity *entity)
/* Helper function for checking if particular entity is a part of the audio device. 
This function checks if given entity is a part of given audio device. If so then true is returned and audio_dev_data is considered correct device data. */
static bool is_entity_valid(struct usb_audio_dev_data *audio_dev_data, struct usb_audio_entity *entity)
{
	const struct cs_ac_if_descriptor *header;
	const struct feature_unit_descriptor *fu;
	header = audio_dev_data->desc_hdr;
	fu = (struct feature_unit_descriptor *)((uint8_t *)header +
						header->bLength +
						INPUT_TERMINAL_DESC_SIZE);
	if (fu->bUnitID == entity->id) {
		entity->subtype = fu->bDescriptorSubtype;
		return true;
	}
	if (header->bInCollection == 2) {
		fu = (struct feature_unit_descriptor *)((uint8_t *)fu +
			fu->bLength +
			INPUT_TERMINAL_DESC_SIZE +
			OUTPUT_TERMINAL_DESC_SIZE);
		if (fu->bUnitID == entity->id) {
			entity->subtype = fu->bDescriptorSubtype;
			return true;
		}
	}
	return false;
}