From patchwork Tue Aug 18 10:12:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Mengdong" X-Patchwork-Id: 7030291 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 69371C05AC for ; Tue, 18 Aug 2015 09:59:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6FEAF206B8 for ; Tue, 18 Aug 2015 09:59:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 33B73206AD for ; Tue, 18 Aug 2015 09:59:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 47BAE26170F; Tue, 18 Aug 2015 11:59:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 17FAE2617AB; Tue, 18 Aug 2015 11:58:55 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 63B79261740; Tue, 18 Aug 2015 11:58:53 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by alsa0.perex.cz (Postfix) with ESMTP id 2E0D1260A5B for ; Tue, 18 Aug 2015 11:58:32 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP; 18 Aug 2015 02:58:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,701,1432623600"; d="scan'208";a="785926471" Received: from amanda-hsw-pc.sh.intel.com ([10.239.159.75]) by fmsmga002.fm.intel.com with ESMTP; 18 Aug 2015 02:58:30 -0700 From: mengdong.lin@intel.com To: alsa-devel@alsa-project.org Date: Tue, 18 Aug 2015 18:12:01 +0800 Message-Id: <50ef2cb41e76b1582b71910b4dfea144388dcc5f.1439892263.git.mengdong.lin@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Cc: tiwai@suse.de, Mengdong Lin , broonie@kernel.org, mengdong.lin@linux.intel.com, liam.r.girdwood@intel.com Subject: [alsa-devel] [PATCH v2 2/3] ASoC: topology: Reduce arguments of soc_tplg_kcontrol_bind_io() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Mengdong Lin Add the pointer of struct soc_tplg as one argument, so no need to pass standard/vendor specific kcontrol handlers and their count. Signed-off-by: Mengdong Lin diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 707c360..9ec97f4 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -508,20 +508,22 @@ static void remove_pcm_dai(struct snd_soc_component *comp, /* bind a kcontrol to it's IO handlers */ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, struct snd_kcontrol_new *k, - const struct snd_soc_tplg_kcontrol_ops *ops, int num_ops, - const struct snd_soc_tplg_kcontrol_ops *bops, int num_bops) + const struct soc_tplg *tplg) { - int i; + const struct snd_soc_tplg_kcontrol_ops *ops; + int num_ops, i; /* try and map vendor specific kcontrol handlers first */ - for (i = 0; i < num_bops; i++) { - - if (k->put == NULL && bops[i].id == hdr->ops.put) - k->put = bops[i].put; - if (k->get == NULL && bops[i].id == hdr->ops.get) - k->get = bops[i].get; - if (k->info == NULL && bops[i].id == hdr->ops.info) - k->info = bops[i].info; + ops = tplg->io_ops; + num_ops = tplg->io_ops_count; + for (i = 0; i < num_ops; i++) { + + if (k->put == NULL && ops[i].id == hdr->ops.put) + k->put = ops[i].put; + if (k->get == NULL && ops[i].id == hdr->ops.get) + k->get = ops[i].get; + if (k->info == NULL && ops[i].id == hdr->ops.info) + k->info = ops[i].info; } /* vendor specific handlers found ? */ @@ -529,6 +531,8 @@ static int soc_tplg_kcontrol_bind_io(struct snd_soc_tplg_ctl_hdr *hdr, return 0; /* none found so try standard kcontrol handlers */ + ops = io_ops; + num_ops = ARRAY_SIZE(io_ops); for (i = 0; i < num_ops; i++) { if (k->put == NULL && ops[i].id == hdr->ops.put) @@ -682,8 +686,7 @@ static int soc_tplg_dbytes_create(struct soc_tplg *tplg, unsigned int count, INIT_LIST_HEAD(&sbe->dobj.list); /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, io_ops, - ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count); + err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc, tplg); if (err) { soc_control_err(tplg, &be->hdr, be->hdr.name); kfree(sbe); @@ -777,8 +780,7 @@ static int soc_tplg_dmixer_create(struct soc_tplg *tplg, unsigned int count, INIT_LIST_HEAD(&sm->dobj.list); /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, io_ops, - ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count); + err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc, tplg); if (err) { soc_control_err(tplg, &mc->hdr, mc->hdr.name); kfree(sm); @@ -950,8 +952,7 @@ static int soc_tplg_denum_create(struct soc_tplg *tplg, unsigned int count, } /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&ec->hdr, &kc, io_ops, - ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count); + err = soc_tplg_kcontrol_bind_io(&ec->hdr, &kc, tplg); if (err) { soc_control_err(tplg, &ec->hdr, ec->hdr.name); kfree(se); @@ -1137,8 +1138,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( INIT_LIST_HEAD(&sm->dobj.list); /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc[i], io_ops, - ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count); + err = soc_tplg_kcontrol_bind_io(&mc->hdr, &kc[i], tplg); if (err) { soc_control_err(tplg, &mc->hdr, mc->hdr.name); kfree(sm); @@ -1235,8 +1235,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create( } /* map io handlers */ - err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, io_ops, - ARRAY_SIZE(io_ops), tplg->io_ops, tplg->io_ops_count); + err = soc_tplg_kcontrol_bind_io(&ec->hdr, kc, tplg); if (err) { soc_control_err(tplg, &ec->hdr, ec->hdr.name); goto err_se; @@ -1306,9 +1305,7 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create( INIT_LIST_HEAD(&sbe->dobj.list); /* map standard io handlers and check for external handlers */ - err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc[i], io_ops, - ARRAY_SIZE(io_ops), tplg->io_ops, - tplg->io_ops_count); + err = soc_tplg_kcontrol_bind_io(&be->hdr, &kc[i], tplg); if (err) { soc_control_err(tplg, &be->hdr, be->hdr.name); kfree(sbe);