Skip to content

Commit af37511

Browse files
rfvirgilbroonie
authored andcommitted
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. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Link: https://patch.msgid.link/20251128102132.1575177-2-rf@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a76e1d9 commit af37511

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

drivers/firmware/cirrus/cs_dsp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,9 @@ static int cs_dsp_create_name(struct cs_dsp *dsp)
23292329
return 0;
23302330
}
23312331

2332+
static const struct cs_dsp_client_ops cs_dsp_default_client_ops = {
2333+
};
2334+
23322335
static int cs_dsp_common_init(struct cs_dsp *dsp)
23332336
{
23342337
int ret;
@@ -2342,6 +2345,9 @@ static int cs_dsp_common_init(struct cs_dsp *dsp)
23422345

23432346
mutex_init(&dsp->pwr_lock);
23442347

2348+
if (!dsp->client_ops)
2349+
dsp->client_ops = &cs_dsp_default_client_ops;
2350+
23452351
#ifdef CONFIG_DEBUG_FS
23462352
/* Ensure this is invalid if client never provides a debugfs root */
23472353
dsp->debugfs_root = ERR_PTR(-ENODEV);

0 commit comments

Comments
 (0)