All of lore.kernel.org
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: <broonie@kernel.org>
Cc: patches@opensource.cirrus.com, alsa-devel@alsa-project.org,
	lgirdwood@gmail.com
Subject: [PATCH 07/10] firmware: cs_dsp: Perform NULL check in cs_dsp_coeff_write/read_ctrl
Date: Tue, 16 Nov 2021 16:16:06 +0000	[thread overview]
Message-ID: <20211116161609.12223-7-ckeepax@opensource.cirrus.com> (raw)
In-Reply-To: <20211116161609.12223-1-ckeepax@opensource.cirrus.com>

Add a NULL check to the cs_dsp_coeff_write/read_ctrl functions. This is
a major convenience for users of the cs_dsp library as it allows the call
to cs_dsp_get_ctl to be inlined with the call to read/write the control
itself.

Signed-off-by: Charles Keepax <ckeepax@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 62ba4ebbf11f5..9eecd16265375 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -758,6 +758,9 @@ int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl, const void *buf, size_
 
 	lockdep_assert_held(&ctl->dsp->pwr_lock);
 
+	if (!ctl)
+		return -ENOENT;
+
 	if (ctl->flags & WMFW_CTL_FLAG_VOLATILE)
 		ret = -EPERM;
 	else if (buf != ctl->cache)
@@ -817,6 +820,9 @@ int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl, void *buf, size_t len)
 
 	lockdep_assert_held(&ctl->dsp->pwr_lock);
 
+	if (!ctl)
+		return -ENOENT;
+
 	if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) {
 		if (ctl->enabled && ctl->dsp->running)
 			return cs_dsp_coeff_read_ctrl_raw(ctl, buf, len);
-- 
2.11.0


  parent reply	other threads:[~2021-11-16 16:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-16 16:16 [PATCH 01/10] ASoC: wm_adsp: Remove the wmfw_add_ctl helper function Charles Keepax
2021-11-16 16:16 ` [PATCH 02/10] firmware: cs_dsp: Add lockdep asserts to interface functions Charles Keepax
2021-11-16 16:16 ` [PATCH 03/10] firmware: cs_dsp: Add version checks on coefficient loading Charles Keepax
2021-11-16 18:08   ` Mark Brown
2021-11-16 18:44     ` Simon Trimmer
2021-11-17 11:00       ` Charles Keepax
2021-11-17 12:54         ` Mark Brown
2021-11-16 16:16 ` [PATCH 04/10] firmware: cs_dsp: Add pre_run callback Charles Keepax
2021-11-16 16:16 ` [PATCH 05/10] firmware: cs_dsp: Print messages from bin files Charles Keepax
2021-11-16 16:16 ` [PATCH 06/10] firmware: cs_dsp: Add support for rev 2 coefficient files Charles Keepax
2021-11-16 16:16 ` Charles Keepax [this message]
2021-11-16 16:16 ` [PATCH 08/10] firmware: cs_dsp: Clarify some kernel doc comments Charles Keepax
2021-11-16 16:16 ` [PATCH 09/10] firmware: cs_dsp: Add offset to cs_dsp read/write Charles Keepax
2021-11-16 16:16 ` [PATCH 10/10] firmware: cs_dsp: Allow creation of event controls Charles Keepax

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=20211116161609.12223-7-ckeepax@opensource.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.