From patchwork Fri Jun 5 13:41:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Mouiche X-Patchwork-Id: 6553531 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 CF2D9C0020 for ; Fri, 5 Jun 2015 13:42:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADEC0206D6 for ; Fri, 5 Jun 2015 13:42:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E3DC3206D5 for ; Fri, 5 Jun 2015 13:42:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 67D43266850; Fri, 5 Jun 2015 15:42:11 +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,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 22C8E2667CE; Fri, 5 Jun 2015 15:42:01 +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 C3471266836; Fri, 5 Jun 2015 15:41:57 +0200 (CEST) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by alsa0.perex.cz (Postfix) with ESMTP id 57D542615B7 for ; Fri, 5 Jun 2015 15:41:50 +0200 (CEST) Received: by wiam3 with SMTP id m3so19694586wia.1 for ; Fri, 05 Jun 2015 06:41:50 -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=4JSQY59FhjR2lwS08fZv3xoNJFaFXMeS3sU8S+325WA=; b=eS9aBiuC0XP8oH1T8iWBmCerBkf0bFH/O91UIdQuUo1m8FnGUXtzu0PlOkk69INEVz neIO+5ob3lvD1wCIjEKdO/7eSO6pAwfdeNO1vUVBBopGRQ6c+ghUl85qsi3l15rHfzva SivFmOBbiQti7aq2PJ9rcgulhU0To/Ctr/A9/u3F9hRXxTJ9TT1ilMHSftKrbkHS/nzp v2xuDzuTy5oJmdp5SOY6QDUnL5f7CxE60Q0wuSLcMJcOU4YpLvNDY4fIVlbtMaWEXbYY HI/qbePftZnV735GEKobkZv9XFuij5dSiRv07yPBBgknsJt4Ud9BJJegJId1p3tXxfCE 3B/A== X-Gm-Message-State: ALoCoQl7HvfJ1ULKDF/WXlVgft1ZHwQ7YlqbxB+20oL2usTuxomWeOam7QcUvJ0y2M2vWFkslpcD X-Received: by 10.194.63.228 with SMTP id j4mr6774587wjs.38.1433511709979; Fri, 05 Jun 2015 06:41:49 -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 q2sm10657444wjz.15.2015.06.05.06.41.49 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jun 2015 06:41:49 -0700 (PDT) From: Arnaud Mouiche To: alsa-devel@alsa-project.org Date: Fri, 5 Jun 2015 15:41:14 +0200 Message-Id: <1433511674-29156-1-git-send-email-arnaud.mouiche@invoxia.com> X-Mailer: git-send-email 1.9.1 Cc: Arnaud Mouiche Subject: [alsa-devel] [PATCH] 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e19a676..7194df4 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: @@ -3416,6 +3419,8 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) } 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) {