[alsa-devel] [PATCH v8 2/3] ALSA: hdac_ext: add hdac extended controller

Takashi Iwai tiwai at suse.de
Wed Jun 10 20:41:08 CEST 2015


At Wed, 10 Jun 2015 18:36:01 +0530,
Vinod Koul wrote:
> 
> +/**
> + * snd_hdac_ext_bus_get_link_index - get link based on codec name
> + * @ebus: HD-audio extended core bus
> + * @codec_name: codec name
> + */
> +struct hdac_ext_link *snd_hdac_ext_bus_get_link(struct hdac_ext_bus *ebus,
> +						 const char *codec_name)
> +{
> +	int i;
> +	struct hdac_ext_link *hlink = NULL;
> +	char name[32];
> +
> +	list_for_each_entry(hlink, &ebus->hlink_list, list) {
> +		for (i = 0; i < HDA_MAX_CODECS; i++) {
> +			snprintf(name, sizeof(name), "codec#%03x", hlink->codec[i]);
> +			if (!strncmp(name, codec_name, strlen(codec_name)))
> +				return hlink;

Is this name supposed to be identical with the string the patch 1
sets?  If so, this looks incompatible.

Also, it'd be easier to parse the string only once like:

	int bus_idx, addr;

	if (sscanf(codec_name, "ehdaudio%dD%d", &bus_idx, &addr) != 2)
		return NULL;
	if (ebus->index != bus_idx)
		return NULL;
	list_for_each_entry(hlink, &ebus->hlink_list, list)
		if (hlink->lsdiid && (0x1 << addr))
			return hlink;

	return NULL;
		

Takashi


More information about the Alsa-devel mailing list