From patchwork Thu Jan 31 11:30:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiwei Jiang X-Patchwork-Id: 10790317 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3F9817E9 for ; Thu, 31 Jan 2019 11:56:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAA3130B7A for ; Thu, 31 Jan 2019 11:56:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B72D130B87; Thu, 31 Jan 2019 11:56:23 +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=-2.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham 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 CB03E30B75 for ; Thu, 31 Jan 2019 11:56:18 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0EBDC26791D; Thu, 31 Jan 2019 12:31:09 +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 39DFF26792E; Thu, 31 Jan 2019 12:31:06 +0100 (CET) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by alsa0.perex.cz (Postfix) with ESMTP id 42C3326687D for ; Thu, 31 Jan 2019 12:31:04 +0100 (CET) Received: by mail-pf1-f195.google.com with SMTP id y126so1346436pfb.4 for ; Thu, 31 Jan 2019 03:31:03 -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:mime-version :content-transfer-encoding; bh=oNv0JE5CSLKIeFOycq0zQ7rCCuMx/vP5u62Spz1WZpo=; b=B9wVJrWSpUNbwX2aX3zZJEL/FwY2mObzsYPNRzUXRp9CpjUOrJ6N8GaPTNtgM1VtSk vWFNdkhBK+sHlSk/hKNZeR7c1BCdVdx0by05kM2J4l0hv8//OcwKlLd+/qA+Dt+yHN5+ ZOggw4DfDqLbNt+RB0CTCHVRbOtnrKqz9lH3XGBpRJQoZJCvQbnFPwY9p1ukRxU2/dLG 6F4y1rhKTaBo55Ph31kzVikGmgzhjLNJgOSlY215g32u13zy9DylCAH323NjmRlfuVEo Rxqpi6S/U6nNYpTJjUDI+I2MbaK2URGflc5vnBT2k+7A3AjfIEgaDQSwH6xZWsReUu7T +0HA== 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:mime-version :content-transfer-encoding; bh=oNv0JE5CSLKIeFOycq0zQ7rCCuMx/vP5u62Spz1WZpo=; b=jqanG/gTWxJ3QZYXeV4AOtmMUujnUomF5rQYbhG20OqIUxpx36BUw4OoyBIMCOqG7p OFgLWnLC08ZQuoOg1Awa/XRaUBDi1/kky8lpr2oDM0nFOlzGrXG3xRCIkpWxaBrjWP+3 Kf4zpbW7jkgHMBfYZOWdv0uXevs8upnIrEqYSAeN4JjbZYr6eRgUUH8DAsWclhBtF8LS +yBEITuCuZ4FvbO6z5Dnd65fqeU1kCZUetbIl8D1ZqbDfuDknEcSDTJK8M5USAds74Qt AiiqVZqj36vrb4Cqi9qiPhjxE9eEzTs/cIfx8c2/aRZjh0DSXU++wvyYrFxZydQH7lof mcPQ== X-Gm-Message-State: AJcUukeOvc3Jc+5V59Z8hwxoaSJPTJZ5QqBI0/XkUphomegLKk+5SrHX jj8bu5X4029Ftnh64PancgI= X-Google-Smtp-Source: ALg8bN7fXHugPq3Q5GmDUhcft1fN6K1sbK+N8xI5VBosxINFfXrZEngaABUnQxXbABT2Yvevg3paeQ== X-Received: by 2002:a63:5a57:: with SMTP id k23mr30922002pgm.5.1548934263000; Thu, 31 Jan 2019 03:31:03 -0800 (PST) Received: from localhost.localdomain ([183.207.178.209]) by smtp.gmail.com with ESMTPSA id g190sm5635313pgc.28.2019.01.31.03.30.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Jan 2019 03:31:02 -0800 (PST) From: Zhiwei Jiang To: qq282012236@gmail.com Date: Thu, 31 Jan 2019 19:30:05 +0800 Message-Id: <20190131113005.13380-1-qq282012236@gmail.com> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, tiwai@suse.com, broonie@kernel.org Subject: [alsa-devel] [PATCH] ASoC: dapm: Add warnings for widget overwrite when adding route 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, in some complex cases, more than one widgets have same name and registed from differnt dapm context, and route add from another context too. When snd_soc_dapm_add_route, the previous registered widget will overwritten by the latest same name widget, will cause unexpect error. For Asoc framework we cant avoid this situation and we cant decide which widget that wanted with route. At least we can give users a notice. Signed-off-by: Zhiwei Jiang --- sound/soc/soc-dapm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index a5178845065b..af45ffcf712d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2741,6 +2741,8 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, char prefixed_sink[80]; char prefixed_source[80]; const char *prefix; + unsigned int sink_ref = 0; + unsigned int source_ref = 0; int ret; prefix = soc_dapm_prefix(dapm); @@ -2774,6 +2776,11 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, if (wsource) break; } + sink_ref++; + if (sink_ref > 1) + dev_warn(dapm->dev, + "ASoC: sink widget %s overwritten\n", + w->name); continue; } if (!wsource && !(strcmp(w->name, source))) { @@ -2783,6 +2790,11 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, if (wsink) break; } + source_ref++; + if (source_ref > 1) + dev_warn(dapm->dev, + "ASoC: source widget %s overwritten\n", + w->name); } } /* use widget from another DAPM context if not found from this */