From: Marco Chen <marcochen.dev@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Hartmut Knaack" <knaack.h@gmx.de>,
"Daniel Baluta" <daniel.baluta@intel.com>,
"Linus Walleij" <linusw@kernel.org>,
linux-iio@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linux.dev
Subject: [PATCH 2/2] tools: iio: iio_generic_buffer: return error if no channels can be enabled
Date: Fri, 27 Nov 2026 03:57:22 -0500 [thread overview]
Message-ID: <20261127085722.126797-3-marcochen.dev@gmail.com> (raw)
In-Reply-To: <20261127085722.126797-1-marcochen.dev@gmail.com>
If no channels end up being enabled when using the -a flag,
iio_generic_buffer prints "Still no channels after auto-enabling, giving
up". However, it exits with status 0 because ret still holds 0 from
the preceding build_channel_array() call, so callers see success even
though no data was captured. This happens, for example, when
iio_generic_buffer runs without permission to write to the scan element
enable files.
Set ret=-ENOENT before jumping to the error label. This fix matches the
"No channels are enabled" error directly below, which already returns
-ENOENT.
Fixes: 5f991a921a08 ("iio: tools: generic_buffer: auto-enable channels")
Signed-off-by: Marco Chen <marcochen.dev@gmail.com>
---
I used -ENOENT to match the existing "No channels are enabled" path,
but I am not 100% sure if this is the right error code to return here.
I would be glad to hear your input on this.
Thank you.
tools/iio/iio_generic_buffer.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 122fa54bb74a..974548150eb1 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -643,6 +643,7 @@ int main(int argc, char **argv)
if (!num_channels) {
fprintf(stderr, "Still no channels after "
"auto-enabling, giving up\n");
+ ret = -ENOENT;
goto error;
}
}
--
2.56.1
prev parent reply other threads:[~2026-11-27 8:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 8:57 [PATCH 0/2] tools: iio: iio_generic_buffer: fix exit status Marco Chen
2026-11-27 8:57 ` [PATCH 1/2] tools: iio: iio_generic_buffer: return 0 on success Marco Chen
2026-11-27 8:57 ` Marco Chen [this message]
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=20261127085722.126797-3-marcochen.dev@gmail.com \
--to=marcochen.dev@gmail.com \
--cc=andy@kernel.org \
--cc=daniel.baluta@intel.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=linusw@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=nuno.sa@analog.com \
--cc=skhan@linuxfoundation.org \
/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