[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251220-rust_serdev-v1-1-e44645767621@posteo.de>
Date: Sat, 20 Dec 2025 18:44:05 +0000
From: Markus Probst <markus.probst@...teo.de>
To: Rob Herring <robh@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>, Miguel Ojeda <ojeda@...nel.org>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>,
Kari Argillander <kari.argillander@...il.com>
Cc: linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, Markus Probst <markus.probst@...teo.de>
Subject: [PATCH RFC 1/4] serdev: Export internal is_serdev_device() for
drivers
From: Kari Argillander <kari.argillander@...il.com>
The serdev core has an internal is_serdev_device() helper, but it was
not accessible to drivers. Make it public by declaring it in serdev.h
and exporting the symbol so that modular serdev drivers can rely on it
instead of duplicating type checks.
This allows example future Rust serdev abstraction to have
TryFrom<&device::Device<Ctx>> for &serdev::Device<Ctx>
That way using bus is easy for other substystems. Also some other
subsystems expose similar function:
- bool is_usb_device(const struct device *dev)
- bool dev_is_pci(const struct device *dev)
Signed-off-by: Kari Argillander <kari.argillander@...il.com>
---
drivers/tty/serdev/core.c | 3 ++-
include/linux/serdev.h | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index b33e708cb245..1f6bf8e826d8 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -69,10 +69,11 @@ static const struct device_type serdev_device_type = {
.release = serdev_device_release,
};
-static bool is_serdev_device(const struct device *dev)
+bool is_serdev_device(const struct device *dev)
{
return dev->type == &serdev_device_type;
}
+EXPORT_SYMBOL_GPL(is_serdev_device);
static void serdev_ctrl_release(struct device *dev)
{
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 34562eb99931..0043b6cc6d01 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -116,6 +116,8 @@ static inline struct serdev_controller *to_serdev_controller(struct device *d)
return container_of(d, struct serdev_controller, dev);
}
+bool is_serdev_device(const struct device *dev);
+
static inline void *serdev_device_get_drvdata(const struct serdev_device *serdev)
{
return dev_get_drvdata(&serdev->dev);
--
2.51.2
Powered by blists - more mailing lists