From: "Nuno Sá" <nuno.sa@analog.com>
To: <linux-iio@vger.kernel.org>, <alsa-devel@alsa-project.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Olivier Moysan <olivier.moysan@st.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Arnaud Pouliquen <arnaud.pouliquen@st.com>,
Takashi Iwai <tiwai@suse.com>, Mark Brown <broonie@kernel.org>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH 2/2] iio: buffer: Return error if no callback is given
Date: Sat, 21 Nov 2020 17:14:57 +0100 [thread overview]
Message-ID: <20201121161457.957-3-nuno.sa@analog.com> (raw)
In-Reply-To: <20201121161457.957-1-nuno.sa@analog.com>
Return error in case no callback is provided to
`iio_channel_get_all_cb()`. There's no point in setting up a buffer-cb
if no callback is provided.
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
drivers/iio/buffer/industrialio-buffer-cb.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c
index 47c96f7f4976..4c12b7a94af5 100644
--- a/drivers/iio/buffer/industrialio-buffer-cb.c
+++ b/drivers/iio/buffer/industrialio-buffer-cb.c
@@ -54,6 +54,11 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev,
struct iio_cb_buffer *cb_buff;
struct iio_channel *chan;
+ if (!cb) {
+ dev_err(dev, "Invalid arguments: A callback must be provided!\n");
+ return ERR_PTR(-EINVAL);
+ }
+
cb_buff = kzalloc(sizeof(*cb_buff), GFP_KERNEL);
if (cb_buff == NULL)
return ERR_PTR(-ENOMEM);
--
2.17.1
next prev parent reply other threads:[~2020-11-21 16:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-21 16:14 [PATCH 0/2] Make cb a required parameter of buffer-cb Nuno Sá
2020-11-21 16:14 ` [PATCH 1/2] ASoC: stm32: dfsdm: add stm32_adfsdm_dummy_cb() callback Nuno Sá
2020-11-23 13:51 ` Mark Brown
2020-11-21 16:14 ` Nuno Sá [this message]
2020-11-23 8:40 ` [PATCH 2/2] iio: buffer: Return error if no callback is given Olivier MOYSAN
2020-11-22 16:19 ` [PATCH 0/2] Make cb a required parameter of buffer-cb Jonathan Cameron
2020-11-28 13:25 ` Jonathan Cameron
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=20201121161457.957-3-nuno.sa@analog.com \
--to=nuno.sa@analog.com \
--cc=alsa-devel@alsa-project.org \
--cc=arnaud.pouliquen@st.com \
--cc=broonie@kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=olivier.moysan@st.com \
--cc=pmeerw@pmeerw.net \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).