From patchwork Fri Jun 5 16:38:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Mouiche X-Patchwork-Id: 6556351 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 62201C0020 for ; Fri, 5 Jun 2015 16:39:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8110B20701 for ; Fri, 5 Jun 2015 16:39:08 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0A91E206FB for ; Fri, 5 Jun 2015 16:39:07 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 329E22668BE; Fri, 5 Jun 2015 18:39:05 +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=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 0D8B726689A; Fri, 5 Jun 2015 18:38:57 +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 BCE472668AB; Fri, 5 Jun 2015 18:38:55 +0200 (CEST) Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by alsa0.perex.cz (Postfix) with ESMTP id AC67A26688E for ; Fri, 5 Jun 2015 18:38:48 +0200 (CEST) Received: by wgme6 with SMTP id e6so61001117wgm.2 for ; Fri, 05 Jun 2015 09:38:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=6wVFAmreJFiAwTKtlEt2R0xdFdXb87SWLuywcUsIGqY=; b=i99p+QEwUc4ykrhegMOe1KhAIhfnOGsjCdZZfjvElmiALphB5WQJIpZDEBeNmqVRM2 GE6W5MX+f6kLBscqP6MxsD1ghM9ywamyhpq8ZrRsM/jrI64DdJYhtzKhvkn5vvuL2WnM z1zuaY4WmlmD1w+GwnAzRWEEZWvT4sx1LvAh5mtDRFITf80ZZGc6hqAKJBJuPQ7L5hU6 FcPwwZ0PdOR3L5zL9FV9eksJDZpAaY8lAsIHjVyP5kQfwr+PEa5qYodjnoBD/5F8BGjw btrIjdeUyA9lD+kGfKtqbmd+rpffoufs3JCngNb25kWlpG5fHFZAE2g1iXnw9VaIpwgX 8tUA== X-Gm-Message-State: ALoCoQmZHVcr4W7jdiy4TOaE79nMwWlJSr/HtxkAx8wzF8RZ5S324CGjkGVSY5yasgv1VNDJyyRc X-Received: by 10.194.84.179 with SMTP id a19mr7813781wjz.29.1433522328293; Fri, 05 Jun 2015 09:38:48 -0700 (PDT) Received: from localhost.localdomain (AAnnecy-653-1-146-177.w86-200.abo.wanadoo.fr. [86.200.209.177]) by mx.google.com with ESMTPSA id x10sm11368228wjf.45.2015.06.05.09.38.47 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 09:38:47 -0700 (PDT) From: Arnaud Mouiche To: alsa-devel@alsa-project.org Date: Fri, 5 Jun 2015 18:38:25 +0200 Message-Id: <1433522305-10339-1-git-send-email-arnaud.mouiche@invoxia.com> X-Mailer: git-send-email 1.9.1 Cc: Arnaud Mouiche Subject: [alsa-devel] [PATCH v2] ASoC: dapm: fix prefixed stream name matching in snd_soc_dapm_link_dai_widgets 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 commit "ASoC: dapm: Modify widget stream name according to prefix" fixed a part of the problem when dai_w->name and w->sname are equal before being prefixed. Remains the case where w->sname is only a sub string of dai_w->name. For example, TLV320AIC3x codec defines the widget SND_SOC_DAPM_DAC("Left DAC", "Left Playback", DAC_PWR, 7, 0) In snd_soc_dapm_link_dai_widgets, we will failed to match "[prefix] Left Playback" with "[prefix] Playback". Since dai_w and w necessarily belongs to the same dapm when strstr() is called, they necessarily have the same prefix which allow us to compare 'w->sname + prefix_len' with 'dai_w->name + prefix_len' directly without length check. Signed-off-by: Arnaud Mouiche --- sound/soc/soc-dapm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e19a676..fc4408b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3392,6 +3392,9 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) /* For each DAI widget... */ list_for_each_entry(dai_w, &card->widgets, list) { + const char *prefix = soc_dapm_prefix(dai_w->dapm); + size_t prefix_len = prefix ? strlen(prefix)+1 : 0; + switch (dai_w->id) { case snd_soc_dapm_dai_in: case snd_soc_dapm_dai_out: @@ -3415,7 +3418,8 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) break; } - if (!w->sname || !strstr(w->sname, dai_w->name)) + if (!w->sname || + !strstr(w->sname + prefix_len, dai_w->name + prefix_len)) continue; if (dai_w->id == snd_soc_dapm_dai_in) {