Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops
@ 2025-11-28 10:21 Richard Fitzgerald
  2025-11-28 10:21 ` [PATCH 1/2] firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops Richard Fitzgerald
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2025-11-28 10:21 UTC (permalink / raw)
  To: broonie; +Cc: linux-sound, linux-kernel, patches

Clients of cs_dsp can provide optional callback function pointers, in
a struct cs_dsp_client_ops. The client had to provide a pointer to a
struct even if it didn't implement any of the callbacks.

Commit 1 in this series changes that so the client doesn't have to
provide a dummy struct.

Commit 2 adds kunit tests cases for this.

Richard Fitzgerald (2):
  firmware: cs_dsp: Don't require client to provide a struct
    cs_dsp_client_ops
  firmware: cs_dsp: Add test cases for client_ops == NULL

 drivers/firmware/cirrus/cs_dsp.c                     | 6 ++++++
 drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c | 1 +
 2 files changed, 7 insertions(+)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops
  2025-11-28 10:21 [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Richard Fitzgerald
@ 2025-11-28 10:21 ` Richard Fitzgerald
  2025-11-28 10:21 ` [PATCH 2/2] firmware: cs_dsp: Add test cases for client_ops == NULL Richard Fitzgerald
  2025-11-29  1:41 ` [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2025-11-28 10:21 UTC (permalink / raw)
  To: broonie; +Cc: linux-sound, linux-kernel, patches

A client of cs_dsp does not necessarily need to implement any of the
optional callbacks in struct cs_dsp_client_ops, so allow the client_ops
pointer to be NULL.

This has been done by pointing client_ops at a default empty
cs_dsp_client_ops. It keeps the code cleaner by avoiding having to add
double nested NULL checks everywhere one of these callbacks is called.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 drivers/firmware/cirrus/cs_dsp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index 60a2061c444c..525ac0f0a75d 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -2329,6 +2329,9 @@ static int cs_dsp_create_name(struct cs_dsp *dsp)
 	return 0;
 }
 
+static const struct cs_dsp_client_ops cs_dsp_default_client_ops = {
+};
+
 static int cs_dsp_common_init(struct cs_dsp *dsp)
 {
 	int ret;
@@ -2342,6 +2345,9 @@ static int cs_dsp_common_init(struct cs_dsp *dsp)
 
 	mutex_init(&dsp->pwr_lock);
 
+	if (!dsp->client_ops)
+		dsp->client_ops = &cs_dsp_default_client_ops;
+
 #ifdef CONFIG_DEBUG_FS
 	/* Ensure this is invalid if client never provides a debugfs root */
 	dsp->debugfs_root = ERR_PTR(-ENODEV);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] firmware: cs_dsp: Add test cases for client_ops == NULL
  2025-11-28 10:21 [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Richard Fitzgerald
  2025-11-28 10:21 ` [PATCH 1/2] firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops Richard Fitzgerald
@ 2025-11-28 10:21 ` Richard Fitzgerald
  2025-11-29  1:41 ` [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2025-11-28 10:21 UTC (permalink / raw)
  To: broonie; +Cc: linux-sound, linux-kernel, patches

Add test cases for the client not providing a pointer to a
struct cs_dsp_client_ops. This proves that it is safe for the client
to leave the client_ops pointer at NULL if it does not need to
implement any of the callbacks.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
---
 drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c b/drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c
index 8a9b66a3b7d3..e5a389808e5f 100644
--- a/drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c
+++ b/drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c
@@ -600,6 +600,7 @@ KUNIT_ARRAY_PARAM(cs_dsp_callbacks_ops,
 
 static const struct cs_dsp_callbacks_test_param cs_dsp_no_callbacks_cases[] = {
 	{ .ops =  &cs_dsp_callback_test_empty_client_ops, .case_name = "empty ops" },
+	{ .ops =  NULL, .case_name = "NULL ops" },
 };
 
 KUNIT_ARRAY_PARAM(cs_dsp_no_callbacks,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops
  2025-11-28 10:21 [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Richard Fitzgerald
  2025-11-28 10:21 ` [PATCH 1/2] firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops Richard Fitzgerald
  2025-11-28 10:21 ` [PATCH 2/2] firmware: cs_dsp: Add test cases for client_ops == NULL Richard Fitzgerald
@ 2025-11-29  1:41 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-11-29  1:41 UTC (permalink / raw)
  To: Richard Fitzgerald; +Cc: linux-sound, linux-kernel, patches

On Fri, 28 Nov 2025 10:21:30 +0000, Richard Fitzgerald wrote:
> Clients of cs_dsp can provide optional callback function pointers, in
> a struct cs_dsp_client_ops. The client had to provide a pointer to a
> struct even if it didn't implement any of the callbacks.
> 
> Commit 1 in this series changes that so the client doesn't have to
> provide a dummy struct.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/2] firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops
      commit: af37511305c0da1d151cc9a1ee6077c2cbde4f1d
[2/2] firmware: cs_dsp: Add test cases for client_ops == NULL
      commit: 479b1f8d416501cc3c18b743b1cf63776934ada9

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-29  1:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-28 10:21 [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Richard Fitzgerald
2025-11-28 10:21 ` [PATCH 1/2] firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops Richard Fitzgerald
2025-11-28 10:21 ` [PATCH 2/2] firmware: cs_dsp: Add test cases for client_ops == NULL Richard Fitzgerald
2025-11-29  1:41 ` [PATCH 0/2] firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox