From patchwork Wed Mar 21 19:08:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Marinushkin X-Patchwork-Id: 10300087 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 BE9D460386 for ; Wed, 21 Mar 2018 19:08:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C91F28F5F for ; Wed, 21 Mar 2018 19:08:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FAE5285CD; Wed, 21 Mar 2018 19:08:02 +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 82D5B285CD for ; Wed, 21 Mar 2018 19:08:00 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 26EB4267332; Wed, 21 Mar 2018 20: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 768D9267339; Wed, 21 Mar 2018 20:07:54 +0100 (CET) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by alsa0.perex.cz (Postfix) with ESMTP id 19F182670F8 for ; Wed, 21 Mar 2018 20:07:51 +0100 (CET) Received: by mail-wm0-f68.google.com with SMTP id e194so11637149wmd.3 for ; Wed, 21 Mar 2018 12:07:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=LbhRUfrbAmjX/jMQ1sSXyEYxGh4qDLQ0FBZnM0kjXRE=; b=HcUEPEifBNtIRpTPrM7T4ZjV1On8r03qBI4MMnI/PwLle6J79swtrmJ7HnojC9ni0X KBuJBYB6zMk5Q54O2gMnDTQPIphPZfem5SuVTbhS/ZrMxYJ5W4/u4dFpJhDOXB2rSa2t ISh+8vNvFOZAzcbJJbbuatdaC0+91UG2/oqIXGwGXGVQb1qHbqULYBYLTwHRz8WfwSbU dd60AQmHsM1bUN2cLtEym8+vxNO3Z9rbr3adECS3RtfUnVW36Pp+tKxDxuDtf4tzcvnU KMGD+VVr6IF7vMYfkuIyoIswk8yGYo6pcHDUT3OmLZJ/gXDFp45wxLwoyETT3E2rYYSP db7Q== 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=LbhRUfrbAmjX/jMQ1sSXyEYxGh4qDLQ0FBZnM0kjXRE=; b=RNqGzOcPCdzpFRQJ8tBqhouqVnP9kdC2EIp0bR6u2xRPAgXSetQZO9J6ODClj4wZGB j373WQnlqeaULKBo99XvxusAtE2BuxuRk9vI0PCBkFniPcZDcmIjvseVMuyiXYuw1Fpa 5jcCP1cWZ6BHr/pPjgmyxLYEa6MkB5bD6gyPFVAtdOFv+rm//fCjW10JOoYhCDqAS9rC aP6YxxCx80HzBJWtGhcnOSJ6cnqd1H7Uux8ALatR/TI+mVDc9sc4hC3Y9CGrJzDQt8G0 4NBZTA+ycfWWyoiVaJa+lGm0P7ihXP6Wxv0rUQAzTv+mHMBSyHmc0eTU1/fSan/qqTYU BY0w== X-Gm-Message-State: AElRT7EJ6OQkUsxiqvGsL4PvCkhKTjU2ZbJ6IeZaYSp8m3NpJUepH0Gh 0cLPiXhijYDYCNhD4FnajpA= X-Google-Smtp-Source: AG47ELu/b9JICOqEMVz+fmJPd+I1zLlBUlVINID5sgkNyTl+TyHKDlrkIMMpcpK8OWvLj2V8mp4jBQ== X-Received: by 10.80.162.199 with SMTP id 65mr22792451edm.255.1521659271249; Wed, 21 Mar 2018 12:07:51 -0700 (PDT) Received: from gentoo0.localdomain (x4dbc3a40.dyn.telefonica.de. [77.188.58.64]) by smtp.gmail.com with ESMTPSA id p7sm3979054edc.20.2018.03.21.12.07.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Mar 2018 12:07:45 -0700 (PDT) From: Kirill Marinushkin To: Jaroslav Kysela , Takashi Iwai Date: Wed, 21 Mar 2018 20:08:04 +0100 Message-Id: <20180321190804.6168-1-k.marinushkin@gmail.com> X-Mailer: git-send-email 2.13.6 Cc: alsa-devel@alsa-project.org, Kirill Marinushkin Subject: [alsa-devel] [PATCH RESEND, alsa-lib, v2] 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: Jaroslav Kysela Cc: Takashi Iwai Cc: alsa-devel@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;