From patchwork Thu Aug 1 10:04:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13750109 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 7E3EB170A30 for ; Thu, 1 Aug 2024 10:04:43 +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=1722506684; cv=none; b=evy3v2jX2MNGVrOda7oGjmeNJM1VFUDAuu2ll+GsTZh2Fto1nUHkOiaXseWR6KKajyb+3mkpwS63LzNLKxu4sDDjukHtbBjAWaL2Cla5soIYrn43GrhKYiQtw9h2pkLKvxUB4A661MSXVQR0SbgkuQYwLlVzipy0VI1M0/qUR2k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722506684; c=relaxed/simple; bh=cH5eDuobalJxLJ/mr3WuJttYJjRw1YMPr7S0eAcCCa0=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=a3u0Go+CjU+s2/VhMv1CY214f4hKEb+Wlh1F5Y8825mo3hyfkSs7+4gASzoYZ5KFeCdBpkbXzHuWBKKcG5dkoX+IgvoT2VUlRHcv24hqymtmbwplZrHKSj6YmGZyuG5pw+Ng12HnFUE+oa56gM8KahL8ifuo6JzV0uHW9JxqX5k= 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=Ilf7xjJg; 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="Ilf7xjJg" 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 4714lo5e015269; Thu, 1 Aug 2024 05:04:16 -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=2WX+1YjFQVoWULtA y6k0/ProlB4jPdKOFcK9Azt/TVo=; b=Ilf7xjJgSu3C1CAS/e+jToTKAU6izFhh JToPoYl+5kRt7qwS08x6wdV1NWBTi9hGH1iPGAamZSXxwRNuQTcVSLgN06vaffqu UAcKYyiA+wr3kjCA12jT0uOCNVi9xdFNoee3L3QQg6XgjFaKeWmrKeBWcjNm9fq2 j3e4ubJu6ALRHLYrawahh4IWzTmFsFbI8GlbF+f4JYXa6eMipU36mOF7u5YLbd9n VnfaHGBrZS5QMGX5RgzDkBuPz0sdEoe84XWHC/hyUqpV4pT6OyS8hULADb2i1rJV HIQvTq7Y8kSET1NqWQr1z+zZF3XSGZ5o1UcK0aoWW/L4xajCgJQxCA== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ypeqe-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Aug 2024 05:04:16 -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; Thu, 1 Aug 2024 11:04:13 +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; Thu, 1 Aug 2024 11:04:13 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 32207820244; Thu, 1 Aug 2024 10:04:13 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v3 1/4] ASoC: cs42l43: Remove redundant semi-colon at end of function Date: Thu, 1 Aug 2024 11:04:10 +0100 Message-ID: <20240801100413.1620481-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: uy1aMvcDqTVUrPM2i5ii0102UqFK56Qw X-Proofpoint-ORIG-GUID: uy1aMvcDqTVUrPM2i5ii0102UqFK56Qw X-Proofpoint-Spam-Reason: safe Signed-off-by: Charles Keepax --- No change since v2. Thanks, Charles 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 Thu Aug 1 10:04:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13750110 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 7E43D171066 for ; Thu, 1 Aug 2024 10:04:43 +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=1722506685; cv=none; b=Tn0EMqjt9mRpQ4JnWtGuE9wi1NXNouW9uZyIOsSN8f94ZHOOpDOKmB3p64C14SpEzSc2d7fWpC0dJR1+OD1G3ZXtEUuJMt4KKxaqNjdCSXO7qstzDVfFjEgfyzGqIK9gy47CW9kCb1Jd7rJWwdecSFogf+3QLJ2iz/+NOWjE/y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722506685; c=relaxed/simple; bh=YPEOuCX/tLruFZngidu2lJ0zqPL/bKr/3UJVVn/JDNY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VwtclJaikQ9dE3ATwE5vIvkwjGgoWlaoHTtp6zM8YW0PxKgDqTAqV+xB0Z60goHAgtPFPzTqVOapDo2jxmeub4oDQ+W0muX6XrIvW/yggGVoJ2sV34LmEH+rHev5liIYYp0Q0ySNFtZLO25/jVzdB+03dB7nfZ1jc8W2C+9rM/w= 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=kW+XtKus; 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="kW+XtKus" 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 4714lo5d015269; Thu, 1 Aug 2024 05:04:15 -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=1llHGiab/7Xp80F4DpTdMVyvazaB9lx1EQcCzeeNHWI=; b= kW+XtKusq4M+AWWfx+QSZ9p2Q+Zv3/p7slHv3Aw3eUVTAsioiH0Fzmzrm4KoGDfN 6mbNZR0r4qvw8rSiFiSpCSTGffJp8PbRjWC5UjQRXhCwL1liyDWViUcur+LA9/bf PA3KivsgoK8Kmdmn92Z2umxTgoHZMEWjnVEYxoLLkjUvxbOu6JXcli/MKPuHo2/2 Q0D8jQbbK/mKyiBR2V2A3H7RmYJFZi8oza7nLVyuVaHt/daZdSW5siq2dMq1nugf sF0bGP3H0I3y6T9akrN7ZAG4+P30TCkPrCusadAmjq60Xo8S/WS89g/uXCye+DTg yBA8UvYf9Ys6hXEiyEW85A== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ypeqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Aug 2024 05:04:15 -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; Thu, 1 Aug 2024 11:04:13 +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; Thu, 1 Aug 2024 11:04:13 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 3F71F820247; Thu, 1 Aug 2024 10:04:13 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v3 2/4] ASoC: soc-component: Add new snd_soc_component_get_kcontrol() helper Date: Thu, 1 Aug 2024 11:04:11 +0100 Message-ID: <20240801100413.1620481-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801100413.1620481-1-ckeepax@opensource.cirrus.com> References: <20240801100413.1620481-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: _x36C4D2QSHIO9iQBfPxrDwdK7CzZZmq X-Proofpoint-ORIG-GUID: _x36C4D2QSHIO9iQBfPxrDwdK7CzZZmq 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 --- No change since v2. Thanks, Charles 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 Thu Aug 1 10:04:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13750107 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) (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 418EB1EB4BD for ; Thu, 1 Aug 2024 10:04:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.152.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722506676; cv=none; b=DryIHPwd3WD3ZaHvenXd18JcR5PEgqN3wTmv60yH9ghBrlhqUdLcIv5vE7OGz552YSC7efhVzRdHFbazAntDFX0hpHHxPENYge50yWwPrkV8V7tRCbKncmUNdylzQoPI7SbnXusKfvwnUyth94wCJJZMae1Y4rZGW06lNfXcQW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722506676; c=relaxed/simple; bh=R3f5L/FwBwcqABV/TedChclC/Yh0it+s1YziXSXlVo0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YQi5SJo3n1TDVHElX9mP33snRRNmwrHzifWil4UoCIwABSKe9nfSrBZ14csXC7bc3UgQAF9jim+d1ZObEY7ovkSnNPD76NGoYreAPbPrgnwpFNbNLqP7RWlWD992yIjDRoauwPp9VYXTBavVVV9nZDQRA8M0L1yZaVcJHcSc+jA= 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=HtvRvm2M; arc=none smtp.client-ip=67.231.152.168 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="HtvRvm2M" Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46VI6V0S018617; Thu, 1 Aug 2024 05:04:15 -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=tcgwggdtoWBAPNGedmXqNjPdVZO8b39UZh+W8UyMLO4=; b= HtvRvm2MCCreopMlolVHdZzzHUi/d9hXuo5uZIV9FNNjO8j3/tJls1Y/TJGQzvJu O/dDpP4atL9ztCnRISshSBlOHhPpySXuSIhjQVjLgN3JD8Y3SHg7ok/RziAxJCOZ 7J0W5OaSg1e3GmCnZj8316i6BwCeojmcdjm4Agbj3K/w5YLujRdu8HlxGTNKjgl0 Jq1nyTOjS2IKbITmjIEt7SUr7yvgz/6AcwXxzQA4oIKrUHG1FutvGiESkGY7lzsH 4q4q1lTxSdy3ehZLosbC153nJTMjdvwVAHyMThkhL2n03kEVPBSVUFIQBnXzJ6ud FAYlwyKd/mP7ZN1xy15IpA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 40qjw9a356-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Aug 2024 05:04:15 -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; Thu, 1 Aug 2024 11:04:13 +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; Thu, 1 Aug 2024 11:04:13 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 427DE82024B; Thu, 1 Aug 2024 10:04:13 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v3 3/4] ASoC: cs35l45: Use new snd_soc_component_get_kcontrol() helper Date: Thu, 1 Aug 2024 11:04:12 +0100 Message-ID: <20240801100413.1620481-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801100413.1620481-1-ckeepax@opensource.cirrus.com> References: <20240801100413.1620481-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: YWKcvRltJdCOlBD_GnZZwKDqZ6RIn2Bi X-Proofpoint-ORIG-GUID: YWKcvRltJdCOlBD_GnZZwKDqZ6RIn2Bi 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 --- No change since v2. Thanks, Charles 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 Thu Aug 1 10:04:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13750108 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 946BC170A30 for ; Thu, 1 Aug 2024 10:04:40 +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=1722506682; cv=none; b=FRkf2dnIcpVA6KAo4GtqYw9mmJ4vmpKCrtPTie3FIYb/r+QI2x1z5seX8iYiOdw2AJ8L5SCUswwirH9v6601MI3aXG5/3ZP685ORrB3A52KDTQ7bVrRCqyZo5o30UmjVVeT0clajKVJ2WITYhf0sr1NZ6kaYLMFtvJ7QrpbOxkA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722506682; c=relaxed/simple; bh=zoU4Lf/PPsA3GMUOCsjDCfy1D2Vo8A6EE5i6DhW0Umw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kQinSu/GjDhVCsmody1nOO5b0Pj1+MbDdhZvNwMnBdyFEOD8gWKwf7HLhKvKPxyYaLhk6NlFhunHXJW1sGdjEr8WLIG7M6GwMEJ3IcCGo997vw9EQqU8uhxofPn6sKsjQ05IU0Onqwgz567a8BD0Ok3MQuaHZ2K9E0weG1TdwqA= 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=DwYZG3SF; 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="DwYZG3SF" 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 4714lo5f015269; Thu, 1 Aug 2024 05:04:17 -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=H8QFG9IYG4iiEx7cqm33uX87JIeQVPmanSrzUVpH6Ok=; b= DwYZG3SFyPE7nyYME1uSAPOViEfFFGkBOia0Boi4mHNXi5iMphcSP2YLJGOcLouc jb1nqdXzDvnfqHB4NCB7ZBhIjFaC84mZugrryh0EqZaac49cl2lxUYW4mJ7wlfdZ tf62QWlCBkFHDP0gktTRte916cLsBDmJKRFDxRSv7hwk/WeBxYd0iq5ByfLaL9Ot vlvCMqyHAAy30p1mpLsMAuhGod3kQNS7nbCZVn6Fd2amlThVraYXaORJTqum+xzm EGWYaaVdL1sZZVY8y7J/UR7ezpsTToZW5Ir6fzTCWqD1aPZgG8pvyNcrw82mgEgI Zxy2ifhqGkwR+N5Mc6B4bQ== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 40mx9ypeqe-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Aug 2024 05:04:17 -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; Thu, 1 Aug 2024 11:04:13 +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; Thu, 1 Aug 2024 11:04:13 +0100 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 4F46F820258; Thu, 1 Aug 2024 10:04:13 +0000 (UTC) From: Charles Keepax To: , , CC: , , Subject: [PATCH v3 4/4] ASoC: cs42l43: Cache shutter IRQ control pointers Date: Thu, 1 Aug 2024 11:04:13 +0100 Message-ID: <20240801100413.1620481-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240801100413.1620481-1-ckeepax@opensource.cirrus.com> References: <20240801100413.1620481-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: lBHIxIH0HfMPNMqPsZHi0S4q9bOgBQIe X-Proofpoint-ORIG-GUID: lBHIxIH0HfMPNMqPsZHi0S4q9bOgBQIe 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 v2: - Added DAI probe/remove for ASP as well Thanks, Charles sound/soc/codecs/cs42l43.c | 73 +++++++++++++++++++++++++++++--------- sound/soc/codecs/cs42l43.h | 2 ++ 2 files changed, 58 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index 80825777048a6..5183b45864243 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; } @@ -590,7 +588,46 @@ static int cs42l43_asp_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mas return 0; } +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_asp_ops = { + .probe = cs42l43_dai_probe, + .remove = cs42l43_dai_remove, .startup = cs42l43_startup, .hw_params = cs42l43_asp_hw_params, .set_fmt = cs42l43_asp_set_fmt, @@ -611,6 +648,8 @@ static int cs42l43_sdw_hw_params(struct snd_pcm_substream *substream, } 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)