From: Rishab Madhugiri <rishab.madhugiri@gmail.com>
To: jic23@kernel.org
Cc: dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Rishab Madhugiri <rishab.madhugiri@gmail.com>
Subject: [PATCH] iio: core: Avoid BUG() on invalid clock types
Date: Sun, 23 Aug 2026 22:25:02 +0000 [thread overview]
Message-ID: <20260823222502.30764-1-rishab.madhugiri@gmail.com> (raw)
Replace deprecated use of BUG() in default switch cases of
iio_get_time_ns() and current_timestamp_clock_show() with
WARN_ONCE() and return correct fallback or error codes.
Signed-off-by: Rishab Madhugiri <rishab.madhugiri@gmail.com>
---
drivers/iio/industrialio-core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 767a7794624a..c0411a29fe3f 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -341,7 +341,8 @@ s64 iio_get_time_ns(const struct iio_dev *indio_dev)
case CLOCK_TAI:
return ktime_get_clocktai_ns();
default:
- BUG();
+ WARN_ONCE(1, "Invalid clock type selected for IIO device\n");
+ return 0;
}
}
EXPORT_SYMBOL(iio_get_time_ns);
@@ -1518,7 +1519,8 @@ static ssize_t current_timestamp_clock_show(struct device *dev,
case CLOCK_TAI:
break;
default:
- BUG();
+ WARN_ONCE(1, "Invalid clock type selected for IIO device\n");
+ return -EINVAL;
}
return sysfs_emit(buf, "%s\n", clock_names[clk]);
--
2.43.0
next reply other threads:[~2026-08-23 22:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-23 22:25 Rishab Madhugiri [this message]
2026-08-23 22:48 ` Jonathan Cameron
2026-08-24 9:55 ` Andy Shevchenko
2026-08-24 10:05 ` Joshua Crofts
2026-08-24 14:48 ` Andy Shevchenko
2026-08-24 15:06 ` Joshua Crofts
2026-08-24 15:25 ` Andy Shevchenko
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=20260823222502.30764-1-rishab.madhugiri@gmail.com \
--to=rishab.madhugiri@gmail.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.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
all inboxes | Powered by JetHome®