From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vinod Koul Subject: Re: [PATCH v8 2/3] ALSA: hdac_ext: add hdac extended controller Date: Thu, 11 Jun 2015 09:48:17 +0530 Message-ID: <20150611041817.GY28601@localhost> References: <1433941562-5778-1-git-send-email-vinod.koul@intel.com> <1433941562-5778-3-git-send-email-vinod.koul@intel.com> <20150611034346.GX28601@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id 825572612AE for ; Thu, 11 Jun 2015 06:16:56 +0200 (CEST) Content-Disposition: inline In-Reply-To: <20150611034346.GX28601@localhost> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Takashi Iwai Cc: liam.r.girdwood@linux.intel.com, patches.audio@intel.com, alsa-devel@alsa-project.org, broonie@kernel.org, Jeeja KP List-Id: alsa-devel@alsa-project.org On Thu, Jun 11, 2015 at 09:13:46AM +0530, Vinod Koul wrote: > On Wed, Jun 10, 2015 at 08:41:08PM +0200, Takashi Iwai wrote: > > 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. > Yes my miss :( > > This also means that I would be required to save the idx number, so I am > thinking of returning the idx value in snd_hdac_ext_bus_device_init() and > then pass on snd_hdac_ext_bus_map_codec_to_link() API which can save this in > the array and then use idx here as well and use I like below so will add > this and i overlooked ebus->index below, so yes this makes much better so saved it there and also removed snd_hdac_ext_bus_map_codec_to_link() we dont need that and array anymore :) -- ~Vinod > > > > > 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; > > Thanks > > -- > ~Vinod > --