firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops
Subsystems (2)
Richard Fitzgerald
maintainercover firmware: cs_dsp: Remove need for clients to supply dummy cs_dsp_client_ops
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(+)
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 1/2 firmware: cs_dsp: Don't require client to provide a struct cs_dsp_client_ops
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.
--- drivers/firmware/cirrus/cs_dsp.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/firmware/cirrus/cs_dsp.c +6 -0
@@ -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 );
Signature · 1 line
2.47.3
Richard Fitzgerald
maintainerPATCH 2/2 firmware: cs_dsp: Add test cases for client_ops == NULL
In reply to Richard FitzgeraldAdd 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.
--- drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/cirrus/test/cs_dsp_test_callbacks.c +1 -0
@@ -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,
Signature · 1 line
2.47.3
Quoted 8 lines · Richard Fitzgerald
Clients of
cs_dspcan provide optional callback function pointers, in a structcs_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: 479b1f8d416501cc3c18b743b1cf63776934ada9All 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