From patchwork Mon Feb 19 20:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10229027 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 DB5C0602B1 for ; Mon, 19 Feb 2018 20:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC4972857D for ; Mon, 19 Feb 2018 20:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0DAF286F5; Mon, 19 Feb 2018 20:38:42 +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 1FD2B2857D for ; Mon, 19 Feb 2018 20:38:42 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EB0EF2674F0; Mon, 19 Feb 2018 21:38:38 +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 B191A2674F0; Mon, 19 Feb 2018 21:38:37 +0100 (CET) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by alsa0.perex.cz (Postfix) with ESMTP id 0A8EF266EDF; Mon, 19 Feb 2018 21:38:34 +0100 (CET) Received: by mail-wr0-f193.google.com with SMTP id u15so10965954wrg.3; Mon, 19 Feb 2018 12:38:34 -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:in-reply-to:references; bh=DazdOvqmjm6m36xjPKfS1h/o8UIKAGrrTl8QfBFNjsg=; b=bWN5EDYtvGR1EgfkvxIcb7AthZK5HSdM93YejBzVEl3CsvPn3XldjQ+g4yYfDEa5dE DLg4Pp3eL/h+UYdKZ3QpCVZ/FbMp2DTsnWR74xZg7ypiZSuohhly38CGT6AMrmKgjKea bar+dLQriCaMjAdZR4WUgW4ShdzZiQV2GUphMDivKG3KKf7/LX4axK6dETf56eC4lWTf yHczmFAsatb423LPa3SKQxco7yF6otlkNE4dwMUQ0BTLm4nS2UIMDUOmlDTJZTYiAdE3 WoUGLnsEFt91cH4HgRd+hmfwpAzfr2gOATuQEzk4JCaNCasUd/tBZCMftjTsST3CJuId CysQ== 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:in-reply-to :references; bh=DazdOvqmjm6m36xjPKfS1h/o8UIKAGrrTl8QfBFNjsg=; b=VT75qjVei3Ir3FYo+hjvSIzhFl8q+1cTY95q+016DWfHlBmcbhdkeag0h5eS0K8j5Y h1W0fnR6FMavREpOpQmfj+3/UDX/h/zKaCqX4e98GHmT/OfwAKPZg4UaqkJLrFXAZ619 6NNdhpP/BbrrcxliWCJK9170nc3d7sJpHzkm3az59boQ1N16j6hG12TP+Vw49dmDpRzu QHHc7LagAVttUgSMcYAR0C9ggZVICZ4Hvi+6qFvhMWY/A4RI1aWYjMCGcFxLBnj2jRmw l3DwBqVpiVf4j/Mrirqvu8Qt1/oYlWQ4c+gWH79aZ4dwDr8M8YVC6U0Aae6/k8naKd01 /3Qw== X-Gm-Message-State: APf1xPA9FjCcKCf94V37739SQe8aDqGysWc9c3IHU6xAJILt0d/ejW7z tSt3mYz71pjMI2UPoZQ/CR2P0hNH X-Google-Smtp-Source: AH8x224/4wUL0VJMmwyzQdviWxaEXqnEEppzMLYs0TG4PLUjOz1sQxQf9x/6X6Lfk07h0wjyY22I3w== X-Received: by 10.223.156.145 with SMTP id d17mr14695828wre.1.1519072714246; Mon, 19 Feb 2018 12:38:34 -0800 (PST) Received: from gentoo0.localdomain (x4e3351bc.dyn.telefonica.de. [78.51.81.188]) by smtp.gmail.com with ESMTPSA id u63sm13349686wrc.26.2018.02.19.12.38.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2018 12:38:33 -0800 (PST) From: Kirill Marinushkin To: Takashi Sakamoto Date: Mon, 19 Feb 2018 21:38:42 +0100 Message-Id: <20180219203843.3781-1-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: Cc: alsa-devel@alsa-project.org, patch@alsa-project.org, Kirill Marinushkin Subject: [alsa-devel] [PATCH, alsa-lib v2 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;