static int configure_sync_endpoint(struct snd_usb_substream *subs)
{
	int ret;
	struct audioformat *fp;
	struct audioformat *sync_fp = NULL;
	int cur_score = 0;
	int sync_period_bytes = subs->period_bytes;
	struct snd_usb_substream *sync_subs =
		&subs->stream->substream[subs->direction ^ 1];

	if (subs->sync_endpoint->type != SND_USB_ENDPOINT_TYPE_DATA ||
	    !subs->stream)
		return snd_usb_endpoint_set_params(subs->sync_endpoint,
						   subs->pcm_format,
						   subs->channels,
						   subs->period_bytes,
						   0, 0,
						   subs->cur_rate,
						   subs->cur_audiofmt,
						   NULL);

	/* Try to find the best matching audioformat. */
	list_for_each_entry(fp, &sync_subs->fmt_list, list) {
		int score = match_endpoint_audioformats(subs,
							fp, subs->cur_audiofmt,
			subs->cur_rate, subs->pcm_format);

		if (score > cur_score) {
			sync_fp = fp;
			cur_score = score;
		}
	}

	if (unlikely(sync_fp == NULL)) {
		dev_err(&subs->dev->dev,
			"%s: no valid audioformat for sync ep %x found\n",
			__func__, sync_subs->ep_num);
		return -EINVAL;
	}

	/*
	 * Recalculate the period bytes if channel number differ between
	 * data and sync ep audioformat.
	 */
	if (sync_fp->channels != subs->channels) {
		sync_period_bytes = (subs->period_bytes / subs->channels) *
			sync_fp->channels;
		dev_dbg(&subs->dev->dev,
			"%s: adjusted sync ep period bytes (%d -> %d)\n",
			__func__, subs->period_bytes, sync_period_bytes);
	}

	ret = snd_usb_endpoint_set_params(subs->sync_endpoint,
					  subs->pcm_format,
					  sync_fp->channels,
					  sync_period_bytes,
					  0, 0,
					  subs->cur_rate,
					  sync_fp,
					  NULL);

	return ret;
}
static int configure_sync_endpoint(struct snd_usb_substream *subs)
{
	int ret;
	struct audioformat *fp;
	struct audioformat *sync_fp = NULL;
	int cur_score = 0;
	int sync_period_bytes = subs->period_bytes;
	struct snd_usb_substream *sync_subs =
		&subs->stream->substream[subs->direction ^ 1];

	if (subs->sync_endpoint->type != SND_USB_ENDPOINT_TYPE_DATA ||
	    !subs->stream)
		return snd_usb_endpoint_set_params(subs->sync_endpoint,
						   subs->pcm_format,
						   subs->channels,
						   subs->period_bytes,
						   0, 0,
						   subs->cur_rate,
						   subs->cur_audiofmt,
						   NULL);

	 
	list_for_each_entry(fp, &sync_subs->fmt_list, list) {
		int score = match_endpoint_audioformats(subs,
							fp, subs->cur_audiofmt,
			subs->cur_rate, subs->pcm_format);

		if (score > cur_score) {
			sync_fp = fp;
			cur_score = score;
		}
	}

	if (unlikely(sync_fp == NULL)) {
		dev_err(&subs->dev->dev,
			"%s: no valid audioformat for sync ep %x found\n",
			__func__, sync_subs->ep_num);
		return -EINVAL;
	}

	 
	if (sync_fp->channels != subs->channels) {
		sync_period_bytes = (subs->period_bytes / subs->channels) *
			sync_fp->channels;
		dev_dbg(&subs->dev->dev,
			"%s: adjusted sync ep period bytes (%d -> %d)\n",
			__func__, subs->period_bytes, sync_period_bytes);
	}

	ret = snd_usb_endpoint_set_params(subs->sync_endpoint,
					  subs->pcm_format,
					  sync_fp->channels,
					  sync_period_bytes,
					  0, 0,
					  subs->cur_rate,
					  sync_fp,
					  NULL);

	return ret;
}