From patchwork Thu Jan 25 10:31: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: 13530370 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 BB5DA1CA82 for ; Thu, 25 Jan 2024 10:31:26 +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=1706178688; cv=none; b=eBWuG2/SIsYzhY1tqlT31X7p+kFtBfZyOBdru4LJKG3CABDMnlhmna7XzLngNQOwqtuvFd2zDq0zeMM/HDsHjWXtQTvS/iUGUyYbtiMKvAp9A12wHEb/Iaf2nHVTxgswNKUH8biwHnMweymwuOob2j3rLClawEOFVfehlFiNxSE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178688; c=relaxed/simple; bh=dP1nGXxsMCY2F5/u1k++YVby2qiBM6bGmD+FcrbasGY=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=IVQti3r1u8mnLhVMiv2W12yjupofYLyZ5aG/o63DshMae4PT8VC/+p97pRVFP1uQhBUce6Fp7m97iVok0JYpUq9HhGabPdn008Fc2L+RLzEwIUL9XxVpx1TRIPjHwhNVE6r2CY8b4pJjeMtk033Y10u1YypxXP/qUOxKnvmoxP0= 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=kIWbEIlk; 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="kIWbEIlk" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ2010841; Thu, 25 Jan 2024 04:31:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=PODMain02222019; bh=q YrlmXtQv18SjBS8+hZTJonIOBNbD4DOAkMk4mxdJ5w=; b=kIWbEIlk33UMbYwOy /ceY/PFruGM5paYRW3cD6WJtwE/pCfh8kT3vFlF/2vLz0CCUmM2ldzbuaNUpUeDF oc9r7Hm2HrTwJ1ZvJJ+75qeDfLcbH9eCaoDk6VEGQI1wCyhP9MNYmIWQbGtED5jH XsRqftmADFzXyaS/3zt+YgIUQ+QJ4qbkY8kdULkwiPxY4rigZm0buMuW5rvUyUJ/ pUChDNpfgewacq2zxZX0gneQkNToER4J3HfWU09e/v0Nfiw4LpuyoNO7GoabEwV2 ic0yYNQfwvM0DgY54nQ+wOzhlBNYUEi6ke1yPuzDz13baSuUyf3HTjRnwBzym05y 6W6Yw== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:19 -0600 (CST) Received: from ediex01.ad.cirrus.com (198.61.84.80) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 70A4A820246; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 1/7] ASoC: cs42l43: Tidy up header includes Date: Thu, 25 Jan 2024 10:31:11 +0000 Message-ID: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: fcZMI8xpfq7jlJIQx7NtCYEk9o8_2uur X-Proofpoint-GUID: fcZMI8xpfq7jlJIQx7NtCYEk9o8_2uur X-Proofpoint-Spam-Reason: safe Use more forward declarations, move header guards to cover other includes, and rely less on including headers through other headers. Suggested-by: Andy Shevchenko Signed-off-by: Charles Keepax Reviewed-by: Andy Shevchenko --- Changes since v1: - Shuffle forward declarations around Thanks, Charles sound/soc/codecs/cs42l43-jack.c | 5 +++++ sound/soc/codecs/cs42l43-sdw.c | 1 + sound/soc/codecs/cs42l43.c | 8 ++++++++ sound/soc/codecs/cs42l43.h | 21 ++++++++++++--------- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c index 24a598f2ed9a3..1d8d7bf0a6b0d 100644 --- a/sound/soc/codecs/cs42l43-jack.c +++ b/sound/soc/codecs/cs42l43-jack.c @@ -6,19 +6,24 @@ // Cirrus Logic International Semiconductor Ltd. #include +#include #include #include #include #include #include #include +#include #include #include +#include +#include #include #include #include #include #include +#include #include #include "cs42l43.h" diff --git a/sound/soc/codecs/cs42l43-sdw.c b/sound/soc/codecs/cs42l43-sdw.c index 388f95853b699..60c00c05da055 100644 --- a/sound/soc/codecs/cs42l43-sdw.c +++ b/sound/soc/codecs/cs42l43-sdw.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index 6a64681767de8..f2332f90f8337 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -6,17 +6,25 @@ // Cirrus Logic International Semiconductor Ltd. #include +#include +#include #include #include #include #include +#include #include #include #include +#include #include +#include #include +#include #include +#include #include +#include #include #include #include diff --git a/sound/soc/codecs/cs42l43.h b/sound/soc/codecs/cs42l43.h index 125e36861d5d5..9924c13e1eb53 100644 --- a/sound/soc/codecs/cs42l43.h +++ b/sound/soc/codecs/cs42l43.h @@ -6,19 +6,14 @@ * Cirrus Logic International Semiconductor Ltd. */ -#include +#ifndef CS42L43_ASOC_INT_H +#define CS42L43_ASOC_INT_H + #include -#include #include -#include -#include #include -#include +#include #include -#include - -#ifndef CS42L43_ASOC_INT_H -#define CS42L43_ASOC_INT_H #define CS42L43_INTERNAL_SYSCLK 24576000 #define CS42L43_DEFAULT_SLOTS 0x3F @@ -37,6 +32,14 @@ #define CS42L43_N_BUTTONS 6 +struct clk; +struct device; + +struct snd_soc_component; +struct snd_soc_jack; + +struct cs42l43; + struct cs42l43_codec { struct device *dev; struct cs42l43 *core; From patchwork Thu Jan 25 10:31: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: 13530371 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 6EB7F1CA94 for ; Thu, 25 Jan 2024 10:31:27 +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=1706178688; cv=none; b=ZRYMXFISGFpYs4lWmPmP/NiP/f0em1QWrgcTikxpZfWcEnV011NQ3pkK7g8x2L1gUoIrDyWchWXgXrBVIJl/H5x1kQZ1YaI25aIlgo7UbmbxbK+p8+vM0H/uK2azEpBNIV7kHAa7jwUc7rAxrQdM3JaSy6I4wfH1geVC2gZ7U8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178688; c=relaxed/simple; bh=mcO1kO6Eusffstk0a+UN48hUNihoWe2RVTyOdQQQLSc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=X6l11uuNVCYfyUYjHpUrB4tSK65Diw/tIeP7SaClTkQ2Yo9mXx4NDorDBo94Qq15C9iOVh/6EGd4XtiwuEQdzmz/XAkrHRdOCbfxMsvKSsmdqKdOXxAeCwD83mq/q2v6QTsHwZuiDwIbN3Uzf+0phoZ3MkOsMAMYz+uTiekB6eA= 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=Qu4YdkA0; 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="Qu4YdkA0" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ3010841; Thu, 25 Jan 2024 04:31:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=6rjHj7YqFV202SVDxF4wuFl4W48j8/J0dMPI7OQKbSM=; b= Qu4YdkA0IJS3AdWIFjIkddN49LUy7HOCJknUW3P9F6ZjExqtrFvIh1sJwgEbiDko qTzNVpfvfKfI46aJWFg1UxsQF9JoAK+THNuHFG7Pu1Auekqg8h31g3z0z6sD+Oe/ uJ19jE9R/PNNe8n7K4LUB/CNsabGNsoRTxDrnqNdNQybBpaViQWogLx4vLGr9UdQ mHm0jcWw+itUPPYO/CQ9IKKke2xmAK14pZNXKaSyEBYujqaKrRAXwWtadECn3540 HbItKRPq7pAK4rbHOJNvHDY5aefZrXvNToKecg1BrJlZcXGXESkpZNGYG1AnjP9f Tw8kpmNJ0Xsf3eAjbY8N1g== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:19 -0600 (CST) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 75972820247; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 2/7] ASoC: cs42l43: Minor code tidy ups Date: Thu, 25 Jan 2024 10:31:12 +0000 Message-ID: <20240125103117.2622095-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> References: <20240125103117.2622095-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-ORIG-GUID: Y8ct22JkvgvxYLPfMkDowfVIWHa1qeeh X-Proofpoint-GUID: Y8ct22JkvgvxYLPfMkDowfVIWHa1qeeh X-Proofpoint-Spam-Reason: safe Add some missing commas, refactor a couple small bits of code. Suggested-by: Andy Shevchenko Signed-off-by: Charles Keepax --- Changes since v1: - Move static assert Thanks, Charles sound/soc/codecs/cs42l43-jack.c | 10 +++++----- sound/soc/codecs/cs42l43.c | 12 ++++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c index 1d8d7bf0a6b0d..4f7a405b7e06a 100644 --- a/sound/soc/codecs/cs42l43-jack.c +++ b/sound/soc/codecs/cs42l43-jack.c @@ -29,11 +29,11 @@ #include "cs42l43.h" static const unsigned int cs42l43_accdet_us[] = { - 20, 100, 1000, 10000, 50000, 75000, 100000, 200000 + 20, 100, 1000, 10000, 50000, 75000, 100000, 200000, }; static const unsigned int cs42l43_accdet_db_ms[] = { - 0, 125, 250, 500, 750, 1000, 1250, 1500 + 0, 125, 250, 500, 750, 1000, 1250, 1500, }; static const unsigned int cs42l43_accdet_ramp_ms[] = { 10, 40, 90, 170 }; @@ -851,6 +851,9 @@ static const char * const cs42l43_jack_text[] = { "Line-In", "Microphone", "Optical", }; +static_assert(ARRAY_SIZE(cs42l43_jack_override_modes) == + ARRAY_SIZE(cs42l43_jack_text) - 1); + SOC_ENUM_SINGLE_VIRT_DECL(cs42l43_jack_enum, cs42l43_jack_text); int cs42l43_jack_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -873,9 +876,6 @@ int cs42l43_jack_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *u struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int override = ucontrol->value.integer.value[0]; - BUILD_BUG_ON(ARRAY_SIZE(cs42l43_jack_override_modes) != - ARRAY_SIZE(cs42l43_jack_text) - 1); - if (override >= e->items) return -EINVAL; diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index f2332f90f8337..d418c0b0ce9aa 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -1059,12 +1059,10 @@ static int cs42l43_decim_get(struct snd_kcontrol *kcontrol, int ret; ret = cs42l43_shutter_get(priv, CS42L43_STATUS_MIC_SHUTTER_MUTE_SHIFT); - if (ret < 0) - return ret; + if (ret > 0) + ret = cs42l43_dapm_get_volsw(kcontrol, ucontrol); else if (!ret) ucontrol->value.integer.value[0] = ret; - else - ret = cs42l43_dapm_get_volsw(kcontrol, ucontrol); return ret; } @@ -1077,12 +1075,10 @@ static int cs42l43_spk_get(struct snd_kcontrol *kcontrol, int ret; ret = cs42l43_shutter_get(priv, CS42L43_STATUS_SPK_SHUTTER_MUTE_SHIFT); - if (ret < 0) - return ret; + if (ret > 0) + ret = snd_soc_get_volsw(kcontrol, ucontrol); else if (!ret) ucontrol->value.integer.value[0] = ret; - else - ret = snd_soc_get_volsw(kcontrol, ucontrol); return ret; } From patchwork Thu Jan 25 10:31: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: 13530372 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 990401CA9B for ; Thu, 25 Jan 2024 10:31:27 +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=1706178688; cv=none; b=f8qdC6HAFvwPUWi+BwxnuRbwF2+HEZ5QqAYCYpbX1I3NezLQCo9aejHiQWNQt1HRCYHA8WoF8g3NtxbIaXM4PQSRBAJ31sw+p60tdGesHOnDfUrPYMtiRFaAo7Agd5au0qbKTHe9fO7pK+4YHuiVm14cr1oZwwb9qWLr/ji/Tro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178688; c=relaxed/simple; bh=3c2WLm7voiPlhOCguvGRmsQTxZnmMPUZId3QqKoMQGs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uoc2BhKTeb4ILSGstGw6h/6/VUen5GU619BwXupdt45GLDc5TVvM16k+iNjHvIK8NotORhu1XA2R75PmyMSQbhHRLf37F6ozUy3cA0vi81RhUQGaxWDSM9mj+kfRRxQdjvvOtU9+dzinb592Xem8TnLIzFFb6TM+nVAhjLXPn5M= 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=MijUqIEH; 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="MijUqIEH" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ4010841; Thu, 25 Jan 2024 04:31:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=5NE00DJFrknWt0m9ssj1yTdWdZvVXFRtc5Ne25W/FF0=; b= MijUqIEH4wH3udgGfSed2JxAvnKmpyeu+sm4pX15RXa7q4WLla39jczzvNcrxp1j YK1aACM4xusRXrYrXcXoYRorw2UAOm76xkNAPifj3IwBB9LHbRyhdROcMJ0NpsyF Dq5fXHpl3nyIVis1MiAv4PzPxal0Q8yUMgGMFbMi4OGoFAJrG1FbkWpCzEbqRjgY dpXxuZFgx084jxpDZotH6otTMrISHFhUdnq9wDOvbLiNYhblcgDUQQ4wGTYYnrR9 jC6wT2l5UfVoO7LkH4f8MyWs5yw+glxA+tUlI59ZntdIuSpn+IyPD82rzGHR+v4L HdGfUw3p3dRYTLCgwOEb3g== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:20 -0600 (CST) Received: from ediex01.ad.cirrus.com (198.61.84.80) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 77528820248; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 3/7] ASoC: cs42l43: Check error from device_property_read_u32_array() Date: Thu, 25 Jan 2024 10:31:13 +0000 Message-ID: <20240125103117.2622095-3-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> References: <20240125103117.2622095-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-ORIG-GUID: c3XXlWmtyJYH1UhrPLR1YCkVKEsjBD-A X-Proofpoint-GUID: c3XXlWmtyJYH1UhrPLR1YCkVKEsjBD-A X-Proofpoint-Spam-Reason: safe Whilst reading cirrus,buttons-ohms the error from device_property_read_u32_array() is not checked, whilst there is a preceding device_property_count_u32() which is checked the property read can still fail. Add the missing check. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Signed-off-by: Charles Keepax --- Changes since v1: - Add () to funcs in commit message Thanks, Charles sound/soc/codecs/cs42l43-jack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c index 4f7a405b7e06a..67ccdc8bab6f6 100644 --- a/sound/soc/codecs/cs42l43-jack.c +++ b/sound/soc/codecs/cs42l43-jack.c @@ -106,8 +106,13 @@ int cs42l43_set_jack(struct snd_soc_component *component, goto error; } - device_property_read_u32_array(cs42l43->dev, "cirrus,buttons-ohms", - priv->buttons, ret); + ret = device_property_read_u32_array(cs42l43->dev, "cirrus,buttons-ohms", + priv->buttons, ret); + if (ret < 0) { + dev_err(priv->dev, "Property cirrus,button-ohms malformed: %d\n", + ret); + goto error; + } } else { priv->buttons[0] = 70; priv->buttons[1] = 185; From patchwork Thu Jan 25 10:31:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13530373 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 405801CAA2 for ; Thu, 25 Jan 2024 10:31:27 +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=1706178689; cv=none; b=sDJoa4LuZVlJh1PDVYiweZYXzSo/NTBRY2OesqQ+dM2aLM0WHRmywmGvFF4Q2GKYNHS/RZIbu8E2ryJ/exE8jbvPRFa1Y5MoCVGemWqTsj3Th1CsL9ifVxHleK4SnYDBDh+Sy6TF2MDFBAFK5bj3DIdA3gqTf/agbpOfU+vGFQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178689; c=relaxed/simple; bh=tT3rEg+Hnli5xVMR7wEmp2rtZ+JsRr53eHkR4QJp6Cg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=WbD+1Cm7jsvyXVCqC7PlxqkvINLTKP55h8A53NL31lqWcFVM2py1TFWxdUJDkXLwp1JEgsamTE5MMR859ZPsTOwldCSzPmzev7YiTAthhgutLF/bBtQ6QZIX5lHfoBaPIKvT+CWKT/g0YG3zT1vvDdKNTk5s7pdH1tkl+4bgR8M= 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=UPt9sLPs; 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="UPt9sLPs" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ6010841; Thu, 25 Jan 2024 04:31:21 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=wM66v6KnK8q48bXk35LK6FA8cA2NdL6vYO6G9pylDtE=; b= UPt9sLPsCbGDrnbHiAOFVmPwyf6c41OPjV6kXUm+j48ZRMlIqO2fmYpaYpQlacdX SQDM5QTN08AiixYaekHXIoHLx8Mte2E4E5vY+31PZGx/KXb3hbVC98AsPKgc6RLJ P15e9JSfLojOyS5nONR1G1Ou4zdONnJMKsyIn1UQO14MhO2wnBiQKCqlrT2MSxEv ax5Qf6ani87a0GjdVL+3s4+WYTWqBK/Lihgw/jftZyR6kk32JB+RGnKJ4CKhl2t9 9qtwxnfhCFSgI/4D3AFFt4LW11TmAbKE7KJkoiDf4pbwAPXrxmtCoN3Fb7QLdjNw 5iQ83SAK9d3ftJd3LLY5lg== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jn-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:21 -0600 (CST) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 84606820249; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 4/7] ASoC: cs42l43: Add pm_ptr around the power ops Date: Thu, 25 Jan 2024 10:31:14 +0000 Message-ID: <20240125103117.2622095-4-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> References: <20240125103117.2622095-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-ORIG-GUID: VyPs16uuCx-jB0x4IiOJZHQe2NylKGe_ X-Proofpoint-GUID: VyPs16uuCx-jB0x4IiOJZHQe2NylKGe_ X-Proofpoint-Spam-Reason: safe Add missing pm_ptr around the power ops. Suggested-by: Andy Shevchenko Signed-off-by: Charles Keepax --- Changes since v1: - Added commit message 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 d418c0b0ce9aa..1852cb072bd0e 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -2349,7 +2349,7 @@ MODULE_DEVICE_TABLE(platform, cs42l43_codec_id_table); static struct platform_driver cs42l43_codec_driver = { .driver = { .name = "cs42l43-codec", - .pm = &cs42l43_codec_pm_ops, + .pm = pm_ptr(&cs42l43_codec_pm_ops), }, .probe = cs42l43_codec_probe, From patchwork Thu Jan 25 10:31:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13530375 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 43D9C1CA82 for ; Thu, 25 Jan 2024 10:31:28 +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=1706178690; cv=none; b=fykrTO+Kic094ZgBS7/CnZrgyGjbbXxeYD9Ng78CD/83TsFUBqfqGsSl/rJbqafxgnfMYra8Hzvq6Orw7vfCwzOHdkjiKIbeWkGdm0oa723cp2bwpe2oECzGC4N/XaUBGwbr93Ni+oWeLDN9dnQhc9ROd5sDj0JwWuGrWP4NXZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178690; c=relaxed/simple; bh=vSJibILx1FQQKeQdHPnJ863kMO9AQhrPccT6H3AnZP0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uHqua9KrcRYFpZXISbPgDwAO/q8a1w0ElapBzYHMX4FD9V8BsYyMeyGGSFOiKGBXwRZGp3KNpzQ2HcnSrp62YYwxLxE7nz78xeTdCD3AfcPzyG9PRmtrlkO+khOMobhFcxgKlE28mpTS9pwizXqYqQQSzYn4ml4c6IEUoRkg5ZY= 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=MT7fEFNw; 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="MT7fEFNw" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ7010841; Thu, 25 Jan 2024 04:31:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=4jDna+FV0NsPQi6M7P1oE7gYF+t382pNOxgF0rN3KAM=; b= MT7fEFNwMzyfq4xwAMny8RuNox/MxQ15BkD02tC4bhXFQYoK4TM4B6Jy/MfyKCbZ UuJTIZd9AGaVm3CVmHFLG9Vo90yaLjM3QRf5ZKbJMSVrYX5HHDVhK2TjdSiqgly/ D55YYRYoqUafWdHN5uq+RhUF8a5hHKX9kyXMPtPujURg0u3TEFhWO/Dsv6DouMsU NizZTZtu2vVda3ljxOMPtecbtcCObuQMVCQYBy3BTFoRxBIJDlR9ZzjF6TnWFtsS AWfO/J01LzO6OLabYxA7W+0RcH0vT9Zyqytnln3Ms0mHnNwAYS+bKCrrL/1RN5c+ VdFiae4yQj0rv0rGsVEe6Q== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jn-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:22 -0600 (CST) Received: from ediex01.ad.cirrus.com (198.61.84.80) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 90AF782024A; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 5/7] ASoC: cs42l43: Use USEC_PER_MSEC rather than hard coding Date: Thu, 25 Jan 2024 10:31:15 +0000 Message-ID: <20240125103117.2622095-5-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> References: <20240125103117.2622095-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-ORIG-GUID: tCXoiafLFG6En8yssmyX7Q14oZ6b4o4a X-Proofpoint-GUID: tCXoiafLFG6En8yssmyX7Q14oZ6b4o4a X-Proofpoint-Spam-Reason: safe Use USEC_PER_MSEC rather than the hard coded value of 1000. Suggested-by: Andy Shevchenko Reviewed-by: Andy Shevchenko Signed-off-by: Charles Keepax --- Changes since v1: - Added commit message Thanks, Charles sound/soc/codecs/cs42l43-jack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/cs42l43-jack.c b/sound/soc/codecs/cs42l43-jack.c index 67ccdc8bab6f6..901b9dbcf5854 100644 --- a/sound/soc/codecs/cs42l43-jack.c +++ b/sound/soc/codecs/cs42l43-jack.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -647,7 +648,7 @@ static int cs42l43_run_load_detect(struct cs42l43_codec *priv, bool mic) static int cs42l43_run_type_detect(struct cs42l43_codec *priv) { struct cs42l43 *cs42l43 = priv->core; - int timeout_ms = ((2 * priv->detect_us) / 1000) + 200; + int timeout_ms = ((2 * priv->detect_us) / USEC_PER_MSEC) + 200; unsigned int type = 0xff; unsigned long time_left; From patchwork Thu Jan 25 10:31:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13530374 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 276FC1CAAC for ; Thu, 25 Jan 2024 10:31:28 +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=1706178690; cv=none; b=XObLrPDT4Idd9ZOy2i7R4NjTgENiyZRsP/I2WcWwrj7sPs2Mt4LmEJn6WKKnb6Vug98up+3TdyBC+HTtQg3Kosa+xYruvdCu9O4Xr1+hJT5jNnr1pcqQgj5nUZYFPOUD6A7FcTCd5PHrtyb9deaGyt+QtTDGZBc/qWSobV5WaFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178690; c=relaxed/simple; bh=DnL8qyxPAZZwTMxHIG2MKKM+ChzHTpH10rW3atpweQM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HlwYuvgvjYb6/NAWGCrqxl4VIMw8djovExKYumgjlBl176q+npezYgQ8l4nl8tZocWBjo56UC6yfCE61lnyWD3hEdSBNDDwuVP+CFsuyg1rF8QRv5R2+IADpOVV7agm2sRvNyDkF6Z2zbkytF9JHuFJWNenESTnbvwW+SZfi3Vw= 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=SPf5uprr; 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="SPf5uprr" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ5010841; Thu, 25 Jan 2024 04:31:20 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=2nE2uB7fXFPU8yKpy9Qhz0K5Jd5tNvY/0Pf9AeiGvv0=; b= SPf5uprrX9nVIEjL0+VWYcIqrr9qnucaQgRXdcKHS0hXAwwIsVXmsST9X4w7CLiv Gmnsx3k0U1AdaOgCmgZfEmzgJN2c8N6McHgh0pvjLUpNnB2EzEdxdhK9wtO0i486 1Zlm8ijy1d3Zjz9AsOkPdSxE/MvmawDTWC69Di8nBODScS7qOm/LbXJjTOoODgg4 9wjZq9Usp/4YEkog3hgMRhxtkhkFNT6DvDYRMZdwb7Sy97M6qUJDlWa1Ute0GCjO OTfgeIsc4eN19qsdRiUFEQjg2q37XMncakVIETQD6GJuR+ZgzDlG+8EFM3Xt4bfA 38t2oGQisz6uf2YxIIVF2w== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jp-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:20 -0600 (CST) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswmail9.ad.cirrus.com (198.61.86.93) 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id 9D61E82024B; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 6/7] ASoC: cs42l43: Refactor to use for_each_set_bit() Date: Thu, 25 Jan 2024 10:31:16 +0000 Message-ID: <20240125103117.2622095-6-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> References: <20240125103117.2622095-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-ORIG-GUID: -pT4GVl0oVzOXTT5zO8ymtKoZoS1uS-W X-Proofpoint-GUID: -pT4GVl0oVzOXTT5zO8ymtKoZoS1uS-W X-Proofpoint-Spam-Reason: safe Refactor the code in cs42l43_mask_to_slots() to use for_each_set_bit(). Suggested-by: Andy Shevchenko Signed-off-by: Charles Keepax --- Changes since v1: - Added () after funcs in commit message - Use BITS_PER_TYPE - Pass size into cs42l43_mask_to_slots() Thanks, Charles sound/soc/codecs/cs42l43.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index 1852cb072bd0e..23e9557494afa 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -6,10 +6,12 @@ // Cirrus Logic International Semiconductor Ltd. #include +#include #include #include #include #include +#include #include #include #include @@ -547,23 +549,22 @@ static int cs42l43_asp_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; } -static void cs42l43_mask_to_slots(struct cs42l43_codec *priv, unsigned int mask, int *slots) +static void cs42l43_mask_to_slots(struct cs42l43_codec *priv, unsigned long mask, + int *slots, unsigned int nslots) { - int i; + int i = 0; + int slot; - for (i = 0; i < CS42L43_ASP_MAX_CHANNELS; ++i) { - int slot = ffs(mask) - 1; - - if (slot < 0) + for_each_set_bit(slot, &mask, BITS_PER_TYPE(mask)) { + if (i == nslots) { + dev_warn(priv->dev, "Too many channels in TDM mask: %lx\n", + mask); return; + } - slots[i] = slot; - - mask &= ~(1 << slot); + slots[i++] = slot; } - if (mask) - dev_warn(priv->dev, "Too many channels in TDM mask\n"); } static int cs42l43_asp_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, @@ -580,8 +581,10 @@ static int cs42l43_asp_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mas rx_mask = CS42L43_DEFAULT_SLOTS; } - cs42l43_mask_to_slots(priv, tx_mask, priv->tx_slots); - cs42l43_mask_to_slots(priv, rx_mask, priv->rx_slots); + cs42l43_mask_to_slots(priv, tx_mask, priv->tx_slots, + ARRAY_SIZE(priv->tx_slots)); + cs42l43_mask_to_slots(priv, rx_mask, priv->rx_slots, + ARRAY_SIZE(priv->rx_slots)); return 0; } @@ -2098,8 +2101,10 @@ static int cs42l43_component_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, cs42l43->regmap); - cs42l43_mask_to_slots(priv, CS42L43_DEFAULT_SLOTS, priv->tx_slots); - cs42l43_mask_to_slots(priv, CS42L43_DEFAULT_SLOTS, priv->rx_slots); + cs42l43_mask_to_slots(priv, CS42L43_DEFAULT_SLOTS, priv->tx_slots, + ARRAY_SIZE(priv->tx_slots)); + cs42l43_mask_to_slots(priv, CS42L43_DEFAULT_SLOTS, priv->rx_slots, + ARRAY_SIZE(priv->rx_slots)); priv->component = component; priv->constraint = cs42l43_constraint; From patchwork Thu Jan 25 10:31:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 13530376 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 A560E1CA82 for ; Thu, 25 Jan 2024 10:31:33 +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=1706178694; cv=none; b=NsBAW2OQdNiHU6gJ2yi9DskcKQT52hFe7Wa5VlJxo5zICt+F3T5+bw4ImU1pVa1pzGWTn/TyQyFtZPxwTqpLFWJIYczobFpqkZolYAe0Wrmbg9+UYtRgrdGJ+sY4ht9h+9uTp1cmlrFL4B1l5VkH8hh/LLGp2/AEJGXFHP9GhTk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706178694; c=relaxed/simple; bh=74xy6bXGMuQCFhfauhIX2FmqVaxkq835O7ubysl9X9E=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KVvTnSglSn1VWF8si2ObBayVWl0GgrW0crrSyHaZtpAyImpZabgYd7+H6mSyu61l6O303iVE8vb+wc+p0XahEO4CkQ+kcnEYOCU4SCZEfY8BCy9lCYh2XA1cI++LFGNEAuRY7Uv3CX+EBZfioxPAKqEFopc1jYZKIlL2XNrXoCM= 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=JQdrJRU4; 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="JQdrJRU4" Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 40P6oFQ8010841; Thu, 25 Jan 2024 04:31:23 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= PODMain02222019; bh=b00fmaNr6KFnOua3z2NJYeD2LfAVRCQxrGXVQrSrW00=; b= JQdrJRU4kja38XML6pj9OvE9rwJaCDeDGq6eVaiPHhjUQNiHxhEt2WGDu7zisE8k z/Meeoc1g5+PDiZ5w4ZRwOcjT+D22vuaYDaHc794ojAvnP4fEf0iWLOyXhEBH8Oi z2mvjigUiAQFvy/sxLqly5dq+NeCEYOEk7Z6MYdNAESTdUWYp9SEIFNgOeL7alai jbcQ0o2254aunOp6r8fpfPYKgRcomstEeOhR36Pf72lPibR4XjPLoyyukGiMbze8 h7AlTlUsGObGE5EhyhTxstBBu4cTtsNITroWByLMi6UbcyuS5MrD0VsI0/29sTpW qX1ST5ip7xFKMl6CvFe/rA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3vtmfhj3jn-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jan 2024 04:31:23 -0600 (CST) 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.1118.40; Thu, 25 Jan 2024 10:31:17 +0000 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.1118.40 via Frontend Transport; Thu, 25 Jan 2024 10:31:17 +0000 Received: from ediswws07.ad.cirrus.com (ediswws07.ad.cirrus.com [198.90.208.14]) by ediswmail9.ad.cirrus.com (Postfix) with ESMTP id AA5D5820270; Thu, 25 Jan 2024 10:31:17 +0000 (UTC) From: Charles Keepax To: CC: , , , , Subject: [PATCH v2 7/7] ASoC: cs42l43: Use fls to calculate the pre-divider for the PLL Date: Thu, 25 Jan 2024 10:31:17 +0000 Message-ID: <20240125103117.2622095-7-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240125103117.2622095-1-ckeepax@opensource.cirrus.com> References: <20240125103117.2622095-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-ORIG-GUID: wTqMl6uxuAiMH9BltiOe4Yhf_F3B6Eqw X-Proofpoint-GUID: wTqMl6uxuAiMH9BltiOe4Yhf_F3B6Eqw X-Proofpoint-Spam-Reason: safe Use fls to calculate the pre-divider and input frequency for the PLL, this is marginally faster than the previous loop. Suggested-by: Andy Shevchenko Signed-off-by: Charles Keepax --- Changes since v1: - Change / into >> Thanks, Charles sound/soc/codecs/cs42l43.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c index 23e9557494afa..2c402086924d3 100644 --- a/sound/soc/codecs/cs42l43.c +++ b/sound/soc/codecs/cs42l43.c @@ -1338,10 +1338,9 @@ static int cs42l43_enable_pll(struct cs42l43_codec *priv) dev_dbg(priv->dev, "Enabling PLL at %uHz\n", freq); - while (freq > cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq) { - div++; - freq /= 2; - } + div = fls(freq) - + fls(cs42l43_pll_configs[ARRAY_SIZE(cs42l43_pll_configs) - 1].freq); + freq >>= div; if (div <= CS42L43_PLL_REFCLK_DIV_MASK) { int i;