Re: [PATCH RFC 1/4] serdev: Export internal is_serdev_device() for drivers

From: Greg Kroah-Hartman

Date: Sun Dec 21 2025 - 11:10:09 EST


On Sat, Dec 20, 2025 at 06:44:05PM +0000, Markus Probst wrote:
> 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>

But why is that going to be needed?

> 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)

Yes, and usually that's not a good idea, unless you have a bus with
multiple types of devices on it. I don't think serdev has that, does
it?

Only under special circumstances should this be required, so I'm curious
as to why you would ever have a pointer to a struct device and not
"know" that it is of this type? Who is passing that to you?

thanks,

greg k-h