From patchwork Wed Jul 31 13:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13748808 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DE28D16C86F for ; Wed, 31 Jul 2024 13:39:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433164; cv=none; b=M+M2s1b6PJDtyklIe2t2G9B7JDWJ1S4N4/lXQUO8hdU/W4f2hNHjsflfO3Umo+JH+VcW3V3DYmuGtg6bux/10wVnfKWxgHrlpmyqCUIcjc5fgJGol+k7SB8LCj77a4hO3qTvbjzkfDEaUW1Bguc1ULXp9sjKtB5OT3bprRtjy0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433164; c=relaxed/simple; bh=+TVw+TlndHwH7HlLLEFpqEbVDC1A4rLjBFXgr61a4hk=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=crCcd1FljPSeBtz3w58K2Sj92aQ8AYZsNI3uzmfdP7Kz9cep5FHq1XjiV9OSJpigSK6a/fiiZQTYYRVfbh2k2fD/QArVyYT9w42zRFQu86IpQ8ndpscckO0GDVcIHB5VT5yTord02BfQcf1QubDSbfJf2RIHpEm1pis+NSWHOxA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=XKdu2Kqv; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="XKdu2Kqv" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46V5wooq020807; Wed, 31 Jul 2024 08:39:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=PODMain02222019; bh=o2Oyi+avtfQT/pZF m9bAod35ADQ77tXIbJBBdb2HNDY=; b=XKdu2Kqv2KbeUZNl7hF4Wpmu9uDBsDDr m+raCfch7steGTfy55P3TqapuI4bg75BgM15I/CzxTDm5JWJjjaJJoXMX2CxY/YJ MC/k1Z/m5FHk33JmYAM3JSRzpVt0PQYQtyvFM+kzqoRESh05cDW35AlEQHdZLwkb i8KxLl/TdW5LS1rpCcjlajrux+fsjmtpQlAsfUwpdriLNvj0FG+r8bbbUIi6MMW2 vMBS0mjLhYEXWz9vsh4h+TPp8GAzFYkEmxR35G60Y7USQPyJFmHO78EZM/7EC4NA luB00eecNIagvFcym5TPIMjcitpPbysXa+mUYR7qyrmnQ3M60rV8iQ== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ymr5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 08:39:07 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 29317820244; Wed, 31 Jul 2024 13:39:05 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v2 1/4] ASoC: cs42l43: Remove redundant semi-colon at end of function Date: Wed, 31 Jul 2024 14:39:02 +0100 Message-ID: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: F3wNwgVdls5xMaStIfMzO8tKdwSB0dJ8 X-Proofpoint-ORIG-GUID: F3wNwgVdls5xMaStIfMzO8tKdwSB0dJ8 X-Proofpoint-Spam-Reason: safe Signed-off-by: Charles Keepax --- New since v1 of the series. sound/soc/codecs/cs42l43.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index 92674314227c4..80825777048a6 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -608,7 +608,7 @@ static int cs42l43_sdw_hw_params(struct snd_pcm_substream *substream, return ret; return cs42l43_set_sample_rate(substream, params, dai); -}; +} static const struct snd_soc_dai_ops cs42l43_sdw_ops = { .startup = cs42l43_startup, From patchwork Wed Jul 31 13:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13748809 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 205C51B1505 for ; Wed, 31 Jul 2024 13:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433164; cv=none; b=n/IWOGKysn84hzpSk62rmrbWzl0OzdMDveJ4E2AEZf2dL3ymPGdJVlvWO0JKCjxLDAKcKI4/p0r/2LU31d6E64UzC+s9lcWOsjEqMYz1NjFEnuIHik8BNBqBlBBVAGMNIsetp38PVWRI0c6ywHF8xemSKwxHO3gqOY3fZ4wdNok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433164; c=relaxed/simple; bh=peox8ipt1x98YyJnnqRypBM3sWyJIytax119sPS2OHk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=K7VR73wEBEWFqYAABS9OdpJxDlarjvacpJ77l4nxIcl+tKHHFMPkziiUyf30e4YApOvtVkBx8ZUAwoNXRyPK5hmMd7FeznI25SRgEy362oMeUXuw8TEEAEdyDoMS6WSg3ebOwrqWC1Uu/GM7RHCJo72WPczsu0Bp7zcF53WZ0bU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=Z07NpMsu; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="Z07NpMsu" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46V4lq20024935; Wed, 31 Jul 2024 08:39:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=Klyu//OpdFTJnJxf8+HRlP6ywB2NW5PJUxIZ/7SrSv8=; b= Z07NpMsuTrd0gsaDNjQRVdns3KxQgiDTxQz3YQvi5PXIOyAXVkXNUgH9ohoDao7A iEWtrNP7gTqCvzY26f/D9jsKEvtYRyMdcJ2ObY7PTfcie2F5iFUrxWp/B0bl0eoY CY59WCqQtoXqnu8wQ0wOLGcnnMtgqg3+/AUXrCSxydq9OTNOjT5X/aBWPul0gfEA hflkTB8+TuBCmE4rlwtvWtn62xkZyYnwby+rZUgNFmFti20QsPTj6AE5ItnqmJQZ F0aQNeSXDNQKfwbSm99kCENu9cFP6/oA8VlNIyKM+hbs1ni+hoOVrzDv16xIlGOB GmkvaoyEQP5v/bZW193MlQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ymr5u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 08:39:07 -0500 (CDT) Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 381CC820247; Wed, 31 Jul 2024 13:39:05 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v2 2/4] ASoC: soc-component: Add new snd_soc_component_get_kcontrol() helper Date: Wed, 31 Jul 2024 14:39:03 +0100 Message-ID: <20240731133905.1254796-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> References: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: PSUL5OdijzUFNtJdPN3EMHbb8OQWmQOJ X-Proofpoint-ORIG-GUID: PSUL5OdijzUFNtJdPN3EMHbb8OQWmQOJ X-Proofpoint-Spam-Reason: safe Add a new helper function that returns a kcontrol by name, but will factor in the components name_prefix, to handle situations where multiple components are present with the same controls. Signed-off-by: Charles Keepax --- New since v1 of the series. include/sound/soc-component.h | 2 ++ sound/soc/soc-component.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h index ceca69b46a821..61534ac0edd1d 100644 --- a/include/sound/soc-component.h +++ b/include/sound/soc-component.h @@ -462,6 +462,8 @@ int snd_soc_component_force_enable_pin_unlocked( const char *pin); /* component controls */ +struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component, + const char * const ctl); int snd_soc_component_notify_control(struct snd_soc_component *component, const char * const ctl); diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c index 4d7c2e3c929a9..1c0971823fb4d 100644 --- a/sound/soc/soc-component.c +++ b/sound/soc/soc-component.c @@ -236,11 +236,10 @@ int snd_soc_component_force_enable_pin_unlocked( } EXPORT_SYMBOL_GPL(snd_soc_component_force_enable_pin_unlocked); -int snd_soc_component_notify_control(struct snd_soc_component *component, - const char * const ctl) +struct snd_kcontrol *snd_soc_component_get_kcontrol(struct snd_soc_component *component, + const char * const ctl) { 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) @@ -248,7 +247,16 @@ int snd_soc_component_notify_control(struct snd_soc_component *component, else snprintf(name, ARRAY_SIZE(name), "%s", ctl); - kctl = snd_soc_card_get_kcontrol(component->card, name); + return snd_soc_card_get_kcontrol(component->card, name); +} +EXPORT_SYMBOL_GPL(snd_soc_component_get_kcontrol); + +int snd_soc_component_notify_control(struct snd_soc_component *component, + const char * const ctl) +{ + struct snd_kcontrol *kctl; + + kctl = snd_soc_component_get_kcontrol(component, ctl); if (!kctl) return soc_component_ret(component, -EINVAL); From patchwork Wed Jul 31 13:39:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13748807 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2055B1B1503 for ; Wed, 31 Jul 2024 13:39:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433163; cv=none; b=g8pfi+GHpo+CCmP9dJVY/0kCG8kQ+Si3u9twoHH9NYNb81KaJr/Tougimf6KDQM2tuQJBnepJLsa/4l+YCcnTc0CAEK/kgDX7mS8C1Ixgjgt6bqCdczBieUAcivrsxXVDauDxzlNaumXSpap/wkl2h+HYA1AlqZEnHs0hHgMO3Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433163; c=relaxed/simple; bh=lDiGNW+wpzqSfH3yDNtxZMX4vL2klH7bgyAQczyjYeE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BXP+SvbTUPkJTYbkR0pbmgkdcSrxftDSJLPpiaYuLzvhHiLqTZkYIUqddNQ7pqA0xt2cbFxhByrFKVW30sYDDYp0GP+2y9udiR2VAwbwY+UyLKfLdT3lTti0gcMZSwpPvX4OeMzkJTDpRmucG90A+WuGFSesfTodXMPF5suYlNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=Ctv9Enfx; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="Ctv9Enfx" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46V4lq21024935; Wed, 31 Jul 2024 08:39:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=Rh5jgZggqSRQKQ0ZFrEVWOjTyeku5L57e7FLHq8p/cU=; b= Ctv9EnfxP5NX+G4Wq7SvkRjSvw0QBg65m6KT921yIeXi4mXpYNLy0mT478O4G37N F26RRx3I+YheBZ1WVMeybho/UoG2rBQkhk02o5ybk6qhtmJb6esfmA1DxUAU/83L bRfPWak6cKfNKUjdHhFS/+qwfq89IlW+zWWfJZUfVikGEK7RCC27mQTpgPQL9TRe CEZnz+juHP1IiLXoQ37M2h1iMKruxNMgqWDO98nfdy6VQdVStSYnnlwyVa6mdTFE TCZNS0B37QWQiRdyPoGFeyTHYSl81GybkGImqnjMiOR7Gj0GobrzQoRr3ro3VH1P g4Pa2GiHYB6PJsAEJaVzNA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ymr5u-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 08:39:08 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 3C7AC82024B; Wed, 31 Jul 2024 13:39:05 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v2 3/4] ASoC: cs35l45: Use new snd_soc_component_get_kcontrol() helper Date: Wed, 31 Jul 2024 14:39:04 +0100 Message-ID: <20240731133905.1254796-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> References: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: JUKKl37_-MbMH4ROteYz0vRO8HR7oeh- X-Proofpoint-ORIG-GUID: JUKKl37_-MbMH4ROteYz0vRO8HR7oeh- X-Proofpoint-Spam-Reason: safe No longer any need to hard code the addition of the name prefix, use the new helper. Signed-off-by: Charles Keepax --- New since v1 of the series. sound/soc/codecs/cs35l45.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/cs35l45.c b/sound/soc/codecs/cs35l45.c index 2392c6effed85..1fefdb80d758c 100644 --- a/sound/soc/codecs/cs35l45.c +++ b/sound/soc/codecs/cs35l45.c @@ -176,17 +176,10 @@ static int cs35l45_activate_ctl(struct snd_soc_component *component, struct snd_kcontrol *kcontrol; struct snd_kcontrol_volatile *vd; unsigned int index_offset; - char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; - if (component->name_prefix) - snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s", - component->name_prefix, ctl_name); - else - snprintf(name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s", ctl_name); - - kcontrol = snd_soc_card_get_kcontrol_locked(component->card, name); + kcontrol = snd_soc_component_get_kcontrol_locked(component->card, ctl_name); if (!kcontrol) { - dev_err(component->dev, "Can't find kcontrol %s\n", name); + dev_err(component->dev, "Can't find kcontrol %s\n", ctl_name); return -EINVAL; } From patchwork Wed Jul 31 13:39:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13748810 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66E7A1B150E for ; Wed, 31 Jul 2024 13:39:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.149.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433165; cv=none; b=TwUG4t/fezuIgSV6NWBsNPSPN64HfVaDfoq0iDfhB6xwDBT96/SO+mzy9LjgD5pls3Q3OaY5GwHdz//4lrgVwBRWrz/pG2aLbor2QX8GlQv62d21B9Jj6g6YXy8u1fzJzAJEkRWzteULP3rCQTBQTvW1fIZRo3t00nW64wxSmrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722433165; c=relaxed/simple; bh=ifq4h83TLy8JXilG/hl+jWn6ga0DPqrZ8TNoSU2S0+0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LUEM/EWftQVJ0dMeGl4D8RAXatmAImjmiSb01nxVuq8k5+Yf1FpFOgRG1GgtBNQfSL7/k4InC66m3iZZYWlmf0cnBFnLptNfFzQN4XKO8RHwERVVxfuur1QYqTbT21+gkOHtNxW5wmi9DTDqtDWYsZ2gtVHOWG04EgKtqf3QVnA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com; spf=pass smtp.mailfrom=opensource.cirrus.com; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b=kBGAG7wl; arc=none smtp.client-ip=67.231.149.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=opensource.cirrus.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cirrus.com header.i=@cirrus.com header.b="kBGAG7wl" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46V4lq22024935; Wed, 31 Jul 2024 08:39:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= PODMain02222019; bh=cpiXLtlfye2O3//8/H7Ej9nzI0d79T4gUqLx5iJk4z8=; b= kBGAG7wlR0cqX7A0H1MEcRkjeKdO5v+ow8sWOyO66m6D8UojhhX8j0Amb3seWi72 DTmTygVZ5pc/cNfKZ+sDJHcZteVqbDFPLBG8t1QLEdQXE0YkRRL4eZ9l5vtkWVqf 7n4qgvy8vsqXlQBeSHRCpuxZaCG3GK7zw/SQk2qtsLor90nm/5SDpkMp1vSzKuAI 14AFDoybhCV0iaFtNGxrrqqu9xIWngOvfJrosl+eyanANrzf0Shn/Jf1/9J/Oeve +TyG3HVIQZ4uwexpqZWFaRVBh4ha5GMe++PulFbcVAYbBZcS4GF+ADQ99c1Yiw1y XNLkpSW5ZnQm7BjfWM/Zaw== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ymr5u-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 08:39:09 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) by anon-ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1544.9 via Frontend Transport; Wed, 31 Jul 2024 14:39:05 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 49AEF820258; Wed, 31 Jul 2024 13:39:05 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v2 4/4] ASoC: cs42l43: Cache shutter IRQ control pointers Date: Wed, 31 Jul 2024 14:39:05 +0100 Message-ID: <20240731133905.1254796-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> References: <20240731133905.1254796-1-ckeepax@opensource.cirrus.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: PSnaTqj-8-NyEOoxcx1o6FI1T5imnr3Q X-Proofpoint-ORIG-GUID: PSnaTqj-8-NyEOoxcx1o6FI1T5imnr3Q X-Proofpoint-Spam-Reason: safe The microphone/speaker privacy shutter ALSA control handlers need to call pm_runtime_resume, since the hardware needs to be powered up to check the hardware state of the shutter. The IRQ handler for the shutters also needs to notify the ALSA control to inform user-space the shutters updated. However this leads to a mutex inversion, between the sdw_dev_lock and the controls_rwsem. To avoid this mutex inversion cache the kctl pointers before the IRQ handler, which avoids the need to lookup the control and take the controls_rwsem. Suggested-by: Jaroslav Kysela Signed-off-by: Charles Keepax --- Changes since v1: - Rather than delaying to a work queue, cache the control pointers to avoid looking them up in the IRQ handler. sound/soc/codecs/cs42l43.c | 71 +++++++++++++++++++++++++++++--------- sound/soc/codecs/cs42l43.h | 2 ++ 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index 80825777048a6..4771f235b1cc4 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -252,24 +253,20 @@ CS42L43_IRQ_COMPLETE(load_detect) static irqreturn_t cs42l43_mic_shutter(int irq, void *data) { struct cs42l43_codec *priv = data; - static const char * const controls[] = { - "Decimator 1 Switch", - "Decimator 2 Switch", - "Decimator 3 Switch", - "Decimator 4 Switch", - }; - int i, ret; + struct snd_soc_component *component = priv->component; + int i; dev_dbg(priv->dev, "Microphone shutter changed\n"); - if (!priv->component) + if (!component) return IRQ_NONE; - for (i = 0; i < ARRAY_SIZE(controls); i++) { - ret = snd_soc_component_notify_control(priv->component, - controls[i]); - if (ret) + for (i = 1; i < ARRAY_SIZE(priv->kctl); i++) { + if (!priv->kctl[i]) return IRQ_NONE; + + snd_ctl_notify(component->card->snd_card, + SNDRV_CTL_EVENT_MASK_VALUE, &priv->kctl[i]->id); } return IRQ_HANDLED; @@ -278,18 +275,19 @@ static irqreturn_t cs42l43_mic_shutter(int irq, void *data) static irqreturn_t cs42l43_spk_shutter(int irq, void *data) { struct cs42l43_codec *priv = data; - int ret; + struct snd_soc_component *component = priv->component; dev_dbg(priv->dev, "Speaker shutter changed\n"); - if (!priv->component) + if (!component) return IRQ_NONE; - ret = snd_soc_component_notify_control(priv->component, - "Speaker Digital Switch"); - if (ret) + if (!priv->kctl[0]) return IRQ_NONE; + snd_ctl_notify(component->card->snd_card, + SNDRV_CTL_EVENT_MASK_VALUE, &priv->kctl[0]->id); + return IRQ_HANDLED; } @@ -610,7 +608,46 @@ static int cs42l43_sdw_hw_params(struct snd_pcm_substream *substream, return cs42l43_set_sample_rate(substream, params, dai); } +static int cs42l43_dai_probe(struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); + static const char * const controls[] = { + "Speaker Digital Switch", + "Decimator 1 Switch", + "Decimator 2 Switch", + "Decimator 3 Switch", + "Decimator 4 Switch", + }; + int i; + + static_assert(ARRAY_SIZE(controls) == ARRAY_SIZE(priv->kctl)); + + for (i = 0; i < ARRAY_SIZE(controls); i++) { + if (priv->kctl[i]) + continue; + + priv->kctl[i] = snd_soc_component_get_kcontrol(component, controls[i]); + } + + return 0; +} + +static int cs42l43_dai_remove(struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component); + int i; + + for (i = 0; i < ARRAY_SIZE(priv->kctl); i++) + priv->kctl[i] = NULL; + + return 0; +} + static const struct snd_soc_dai_ops cs42l43_sdw_ops = { + .probe = cs42l43_dai_probe, + .remove = cs42l43_dai_remove, .startup = cs42l43_startup, .set_stream = cs42l43_sdw_set_stream, .hw_params = cs42l43_sdw_hw_params, diff --git a/sound/soc/codecs/cs42l43.h b/sound/soc/codecs/cs42l43.h index 9924c13e1eb53..9c144e129535f 100644 --- a/sound/soc/codecs/cs42l43.h +++ b/sound/soc/codecs/cs42l43.h @@ -100,6 +100,8 @@ struct cs42l43_codec { struct delayed_work hp_ilimit_clear_work; bool hp_ilimited; int hp_ilimit_count; + + struct snd_kcontrol *kctl[5]; }; #if IS_REACHABLE(CONFIG_SND_SOC_CS42L43_SDW)