Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Richard Fitzgerald <rf@opensource.cirrus.com>
To: broonie@kernel.org
Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@opensource.cirrus.com
Subject: [PATCH 4/5] ASoC: cs-amp-lib: Add a Kconfig symbol for enabling test hooks
Date: Wed, 21 Jan 2026 13:22:42 +0000	[thread overview]
Message-ID: <20260121132243.1256019-5-rf@opensource.cirrus.com> (raw)
In-Reply-To: <20260121132243.1256019-1-rf@opensource.cirrus.com>

Add Kconfig symbol CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS to enable
calling into functions that would normally abort because of missing
EFI functionality. Before this the code paths were only enabled if
the KUnit test for cs-amp-lib was enabled.

This change allows KUnit tests for clients of cs-amp-lib to install
redirection hooks in cs-amp-lib.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 sound/soc/codecs/Kconfig      |  5 +++++
 sound/soc/codecs/cs-amp-lib.c | 19 ++++++++-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 90f09d4bdf8e..21d5b79f079d 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -786,9 +786,14 @@ config SND_SOC_CROS_EC_CODEC
 config SND_SOC_CS_AMP_LIB
 	tristate
 
+config SND_SOC_CS_AMP_LIB_TEST_HOOKS
+	bool
+	depends on SND_SOC_CS_AMP_LIB
+
 config SND_SOC_CS_AMP_LIB_TEST
 	tristate "KUnit test for Cirrus Logic cs-amp-lib" if !KUNIT_ALL_TESTS
 	depends on SND_SOC_CS_AMP_LIB && KUNIT
+	select SND_SOC_CS_AMP_LIB_TEST_HOOKS
 	default KUNIT_ALL_TESTS
 	help
 	  This builds KUnit tests for the Cirrus Logic common
diff --git a/sound/soc/codecs/cs-amp-lib.c b/sound/soc/codecs/cs-amp-lib.c
index 9f8c99dfb798..f8c7f594d54a 100644
--- a/sound/soc/codecs/cs-amp-lib.c
+++ b/sound/soc/codecs/cs-amp-lib.c
@@ -211,7 +211,7 @@ int cs_amp_write_cal_coeffs(struct cs_dsp *dsp,
 			    const struct cirrus_amp_cal_controls *controls,
 			    const struct cirrus_amp_cal_data *data)
 {
-	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return _cs_amp_write_cal_coeffs(dsp, controls, data);
 	else
 		return -ENODEV;
@@ -230,7 +230,7 @@ int cs_amp_read_cal_coeffs(struct cs_dsp *dsp,
 			   const struct cirrus_amp_cal_controls *controls,
 			   struct cirrus_amp_cal_data *data)
 {
-	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return _cs_amp_read_cal_coeffs(dsp, controls, data);
 	else
 		return -ENODEV;
@@ -249,10 +249,7 @@ int cs_amp_write_ambient_temp(struct cs_dsp *dsp,
 			      const struct cirrus_amp_cal_controls *controls,
 			      u32 temp)
 {
-	if (IS_REACHABLE(CONFIG_FW_CS_DSP) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
-		return cs_amp_write_cal_coeff(dsp, controls, controls->ambient, temp);
-	else
-		return -ENODEV;
+	return cs_amp_write_cal_coeff(dsp, controls, controls->ambient, temp);
 }
 EXPORT_SYMBOL_NS_GPL(cs_amp_write_ambient_temp, "SND_SOC_CS_AMP_LIB");
 
@@ -611,7 +608,7 @@ static int _cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, i
 int cs_amp_get_efi_calibration_data(struct device *dev, u64 target_uid, int amp_index,
 				    struct cirrus_amp_cal_data *out_data)
 {
-	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return _cs_amp_get_efi_calibration_data(dev, target_uid, amp_index, out_data);
 	else
 		return -ENOENT;
@@ -647,7 +644,7 @@ EXPORT_SYMBOL_NS_GPL(cs_amp_get_efi_calibration_data, "SND_SOC_CS_AMP_LIB");
 int cs_amp_set_efi_calibration_data(struct device *dev, int amp_index, int num_amps,
 				    const struct cirrus_amp_cal_data *in_data)
 {
-	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST)) {
+	if (IS_ENABLED(CONFIG_EFI) || IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS)) {
 		scoped_guard(mutex, &cs_amp_efi_cal_write_lock) {
 			return _cs_amp_set_efi_calibration_data(dev, amp_index,
 								num_amps, in_data);
@@ -720,7 +717,7 @@ int cs_amp_get_vendor_spkid(struct device *dev)
 	int i, ret;
 
 	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE) &&
-	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return -ENOENT;
 
 	for (i = 0; i < ARRAY_SIZE(cs_amp_spkid_byte_types); i++) {
@@ -743,7 +740,7 @@ static const char *cs_amp_devm_get_dell_ssidex(struct device *dev,
 	int ret;
 
 	if (!efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE) &&
-	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST))
+	    !IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS))
 		return ERR_PTR(-ENOENT);
 
 	char *ssidex_buf __free(kfree) = cs_amp_alloc_get_efi_variable(DELL_SSIDEXV2_EFI_NAME,
@@ -849,7 +846,7 @@ static const struct cs_amp_test_hooks cs_amp_test_hook_ptrs = {
 };
 
 const struct cs_amp_test_hooks * const cs_amp_test_hooks =
-	PTR_IF(IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST), &cs_amp_test_hook_ptrs);
+	PTR_IF(IS_ENABLED(CONFIG_SND_SOC_CS_AMP_LIB_TEST_HOOKS), &cs_amp_test_hook_ptrs);
 EXPORT_SYMBOL_NS_GPL(cs_amp_test_hooks, "SND_SOC_CS_AMP_LIB");
 
 MODULE_DESCRIPTION("Cirrus Logic amplifier library");
-- 
2.47.3


  parent reply	other threads:[~2026-01-21 13:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-21 13:22 [PATCH 0/5] ASoC: cs35l56: Add support for new Dell laptops Richard Fitzgerald
2026-01-21 13:22 ` [PATCH 1/5] ASoC: cs-amp-lib: Support Dell SSIDExV2 UEFI variable Richard Fitzgerald
2026-01-21 13:22 ` [PATCH 2/5] ASoC: cs35l56: Use vendor-specific qualifier in firmware file search Richard Fitzgerald
2026-01-21 13:22 ` [PATCH 3/5] ASoC: cs-amp-lib-test: Tests for reading SSIDExV2 Richard Fitzgerald
2026-01-21 13:22 ` Richard Fitzgerald [this message]
2026-01-21 13:22 ` [PATCH 5/5] ASoC: cs35l56: Add KUnit testing of cs35l56_set_fw_suffix() Richard Fitzgerald
     [not found]   ` <202601221843.kS9IMZ0E-lkp@intel.com>
2026-01-22 14:56     ` Richard Fitzgerald
2026-01-22 15:44       ` Philip Li
2026-01-22 13:26 ` [PATCH 0/5] ASoC: cs35l56: Add support for new Dell laptops Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260121132243.1256019-5-rf@opensource.cirrus.com \
    --to=rf@opensource.cirrus.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox