[PATCH RFC 1/4] serdev: Export internal is_serdev_device() for drivers
From: Markus Probst
Date: Sat Dec 20 2025 - 13:44:07 EST
From: Kari Argillander <kari.argillander@xxxxxxxxx>
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@xxxxxxxxx>
---
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