From patchwork Mon Feb 19 06:07:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10227175 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEA7060392 for ; Mon, 19 Feb 2018 06:07:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A215828778 for ; Mon, 19 Feb 2018 06:07:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FA3B2878F; Mon, 19 Feb 2018 06:07:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2C0628778 for ; Mon, 19 Feb 2018 06:07:58 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 6916C267351; Mon, 19 Feb 2018 07:07:57 +0100 (CET) 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 7D866267351; Mon, 19 Feb 2018 07:07:55 +0100 (CET) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by alsa0.perex.cz (Postfix) with ESMTP id 78108266E7D; Mon, 19 Feb 2018 07:07:52 +0100 (CET) Received: by mail-wr0-f196.google.com with SMTP id l43so8424350wrc.2; Sun, 18 Feb 2018 22:07:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=DazdOvqmjm6m36xjPKfS1h/o8UIKAGrrTl8QfBFNjsg=; b=WPdRdiAhI3oJlwfwzUizwF8AFdLN/21dj3f4QNJN88B4HKxqgtyULA8CdD3AgMh7fz iK2rSSdN4nwVBHw6gn5p3R8zo3Lb7fEy1aKBk7xhVWF1HlI9/F7EhDJ30LaxOohzVxnn 7AGK8NNwKc4VL/1lC9FhYFRVWV43GOAsD6YPGQJ5glUf4qrrH6JncKGsOjxay7KwFtL1 1JIrJ+NrF/F8Qqeg1GSv9ORQzsb07wHWnjNtPV2ig/+3oqhQJQZY2wVTKb8/R+vEy/JS LcX2LvVyFXcIlmqguoeSMJIBqPGKcxpvrX2v22Y5ib9nKfvpgPX4wEDjmP39JzN5PA3B jhTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DazdOvqmjm6m36xjPKfS1h/o8UIKAGrrTl8QfBFNjsg=; b=CO8NyvvswJQHA8Z4Qs1hgpVuy9Wy3O+i7NlGZYeQNdKixaiyUGL2y059t+vxE9+sYl yZU0m5aT2ppoVrgbbLD7P4YHVjJxbnStq1MAYZIm5/eaL5yge239TSEVV3u3odiMwIzC U6INUXdnPDGtZT1vEB4INQVvONmIoDr5OU1yJ+CHrIcnZVGXJuNZdSpUqvjy47WKuf42 cPZ1b4Jf8XvCL+1iNnijIDwMGCain5vMju4mY2RB/bpBC+rqBkm6b5QleDuRa7cxFOCO uMDv/1puM7cwbkiuD8SVsIFWFNcsB9tRLN/ENyT/yEPtum4ybMJo3lxh9NP18wDl7VCo 5Cag== X-Gm-Message-State: APf1xPDakok3DxuWPZhdaKQiq/nNAjzTDYu0A06fWBzZOrXVZQYPmlIl Gza83DoxXTaA3WMmf52Qg55wmpfOJz8= X-Google-Smtp-Source: AH8x2252SI1XWz4cmQl+x3+ysUrcqbwxXVA1Zq7AOZq4jutERMaHCPhyfwHYJm8GyXKdvITlRONAhg== X-Received: by 10.223.161.10 with SMTP id o10mr706902wro.60.1519020471778; Sun, 18 Feb 2018 22:07:51 -0800 (PST) Received: from gentoo0.localdomain (x4e3351bc.dyn.telefonica.de. [78.51.81.188]) by smtp.gmail.com with ESMTPSA id y1sm1534055wrh.80.2018.02.18.22.07.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Feb 2018 22:07:51 -0800 (PST) From: Kirill Marinushkin To: alsa-devel@alsa-project.org Date: Mon, 19 Feb 2018 07:07:57 +0100 Message-Id: <20180219060758.17344-1-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 Cc: patch@alsa-project.org, Kirill Marinushkin Subject: [alsa-devel] [PATCH, alsa-lib 1/2] topology: Fix parsing config with multiple hw_configs 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 Currently, if the config file includes several hw_configs sections, parse_hw_config_refs() returns after parsing only the first section. For example, the following config, based on alsa-lib/src/conf/topology/broadwell/broadwell.conf, is parsed incorrectly: ~~~~ SectionHWConfig."CodecHWConfig" { id "1" format "I2S" # physical audio format. bclk "master" # Platform is master of bit clock fsync "master" # platform is master of fsync } SectionHWConfig."CodecHWConfig2" { id "2" format "AC97" } SectionLink."Codec" { # used for binding to the physical link id "0" hw_configs [ "CodecHWConfig" "CodecHWConfig2" ] default_hw_conf_id "2" } ~~~~ Signed-off-by: Kirill Marinushkin Cc: alsa-devel@alsa-project.org Cc: patch@alsa-project.org --- src/topology/pcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/topology/pcm.c b/src/topology/pcm.c index 58cee31d..d3836677 100644 --- a/src/topology/pcm.c +++ b/src/topology/pcm.c @@ -882,6 +882,7 @@ static int parse_hw_config_refs(snd_tplg_t *tplg, snd_config_t *cfg, /* refer to a list of HW configs */ snd_config_for_each(i, next, cfg) { const char *val; + int err; n = snd_config_iterator_entry(i); if (snd_config_get_string(n, &val) < 0) @@ -893,7 +894,9 @@ static int parse_hw_config_refs(snd_tplg_t *tplg, snd_config_t *cfg, } link->num_hw_configs++; - return tplg_ref_add(elem, SND_TPLG_TYPE_HW_CONFIG, val); + err = tplg_ref_add(elem, SND_TPLG_TYPE_HW_CONFIG, val); + if (err < 0) + return err; } return 0;