Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2422436rdh; Sun, 29 Oct 2023 15:56:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGR6PWu1Z5FCfQ7Z5/P7gYmgnv16gKuV4TsKrulajA6We8Uroya4RJPSAbqTQ6Cck9EqzS7 X-Received: by 2002:a05:6830:90a:b0:6c4:ae52:9599 with SMTP id v10-20020a056830090a00b006c4ae529599mr9584998ott.7.1698620203408; Sun, 29 Oct 2023 15:56:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698620203; cv=none; d=google.com; s=arc-20160816; b=YCEllNCgbby/BHzFFLJYudwAww/iAi2JoN7V0d4CYfp/ZqrWEqjJ/ELINOonKA5EQl Pzpyr3saQ7GRSLVWF9cFuFiMmt0xiVKXrW+Hr0HMhWSs9LqSFaN2EVpw7tS9LppEzSc/ gIVQ1MLR0U14gyxxg47+LeAJBilrvUmRftmyy785BTqxnTz9uAGYe6Q6ryBEsZLWXA7r 0y0kbf6NIkyfxBPgymDe9WdlEtX9atOwdrNqS9h3hhXb39bfzYyXjbbjdO/6XCGUZiSH AbgYYIU6Fp08xcvgj7N5FhC39EpmgSYeXeYu4Cle7ChZR7T+CRSLx2YSfXImY3WUDKlq evCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=55JQsHI1i0xjojYgyDwcF/ZhLFXHxyBpalFnZ2ma34Y=; fh=Bd2s7dLljPzoF9PptvV1uXyw1J9uMMgFO4nUc9DCecQ=; b=a8lGEqhpQWS4nyUCMPE+A1M/LWaH8adLTOAl5hS7ZMe1/eS5qyC8bUeJf6qPo35ORt qYW7MZGAQAaD6avVgkNb5WUI4Noa1QOrJyfcE4av26YiWIe59RvJaBdwGAemlA2LnPBo gb75jq6gr4BB2CY5rLmvbEXu8tEGnCyGuh8LYuI98i1FhX+D2Yc0HICnG5JimbKK2XAi 81RRc7klcviUj6xtKprzVJ0c6TFb41bljCCNDUTEY3FG41yhJ28+h0Z79PN1Ysb63l/2 jEvNqfSlTlfK3bJC9Wqtcef0V8TtKxCKmyxJryFEaTikUf7/c460lGezG7N/6GObkSf2 xfKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SZgeRFAJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 15-20020a17090a098f00b0026b365096e5si4237994pjo.53.2023.10.29.15.56.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 15:56:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SZgeRFAJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4DF968087F06; Sun, 29 Oct 2023 15:56:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbjJ2W4G (ORCPT + 99 others); Sun, 29 Oct 2023 18:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbjJ2Wzq (ORCPT ); Sun, 29 Oct 2023 18:55:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF79A10D2; Sun, 29 Oct 2023 15:55:13 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12A0C433CB; Sun, 29 Oct 2023 22:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698620109; bh=Ntf0w8qRyYGhdO1CgTARNydagiZ086VTsRI5WB97xJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SZgeRFAJAkg0yLUb4VgRNFFLuZ9dhhVQfszxduV77bRLdEVZog8YC3YUgdVq8+va5 N0Zf6L0Yi2tBglCYWiJHutmEiG4Ra8NfYZwVgpMr3GhAaB0+foNsnidf6xDcN4z4b0 FRgOhWSlxcr+/dv91/H03ZY2375gqv8CFeh2UjuFANwqviLibxDFRwop7ZNpHTKQul gowKGz377FgPNwULTDsELzrKbv9atujqHpGLenTorqZb3a+Hy7vmjAiHSmcfCG3ZCX SsSezLm8QAKBKp6Oz2Y5fHV544xpauHXVmD7VWWfAsHyb+zab8tLPHW1JbubNnANVT A4ZOuMeHnwGMA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Krzysztof Kozlowski , Mark Brown , Sasha Levin , lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 6.5 18/52] ASoC: soc-dapm: Add helper for comparing widget name Date: Sun, 29 Oct 2023 18:53:05 -0400 Message-ID: <20231029225441.789781-18-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231029225441.789781-1-sashal@kernel.org> References: <20231029225441.789781-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.9 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 29 Oct 2023 15:56:34 -0700 (PDT) From: Krzysztof Kozlowski [ Upstream commit 76aca10ccb7c23a7b7a0d56e0bfde2c8cdddfe24 ] Some drivers use one event callback for multiple widgets but still need to perform a bit different actions based on actual widget. This is done by comparing widget name, however drivers tend to miss possible name prefix. Add a helper to solve common mistakes. Signed-off-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20231003155710.821315-2-krzysztof.kozlowski@linaro.org Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- include/sound/soc-dapm.h | 1 + sound/soc/soc-component.c | 1 + sound/soc/soc-dapm.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 87f8e1793af15..295d63437e4d8 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -423,6 +423,7 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card); int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai); +int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s); /* dapm path setup */ int snd_soc_dapm_new_widgets(struct snd_soc_card *card); diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 4356cc320fea0..10b5fe5a3af85 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -242,6 +242,7 @@ int snd_soc_component_notify_control(struct snd_soc_component *component, char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; struct snd_kcontrol *kctl; + /* When updating, change also snd_soc_dapm_widget_name_cmp() */ if (component->name_prefix) snprintf(name, ARRAY_SIZE(name), "%s %s", component->name_prefix, ctl); else diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 3091e8160bad7..5fd32185fe63d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -2726,6 +2726,18 @@ int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream, } EXPORT_SYMBOL_GPL(snd_soc_dapm_update_dai); +int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s) +{ + struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); + const char *wname = widget->name; + + if (component->name_prefix) + wname += strlen(component->name_prefix) + 1; /* plus space */ + + return strcmp(wname, s); +} +EXPORT_SYMBOL_GPL(snd_soc_dapm_widget_name_cmp); + /* * dapm_update_widget_flags() - Re-compute widget sink and source flags * @w: The widget for which to update the flags -- 2.42.0