lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4b55501e500edb8416ed690757f72752f1c49517.camel@posteo.de>
Date: Sun, 21 Dec 2025 16:28:11 +0000
From: Markus Probst <markus.probst@...teo.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Rob Herring <robh@...nel.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>, linux-serial@...r.kernel.org, 
	linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH RFC 1/4] serdev: Export internal is_serdev_device() for
 drivers

On Sun, 2025-12-21 at 17:10 +0100, Greg Kroah-Hartman wrote:
> On Sat, Dec 20, 2025 at 06:44:05PM +0000, Markus Probst wrote:
> > 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>
> 
> 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?
For example, the pwm rust abstraction currently only provides a
`device::Device<device::Bound>` reference in callbacks [1]. If we want
to write data to the serial device in one of the pwm callbacks, we need
to convert the `device::Device<device::Bound>` reference to
`serdev::Device<device::Bound>`. The TryFrom implementation provides a
*safe* abstraction.

At least in the pwm example, this could/should be circumvented with the
`AsBusDevice` trait [2].

But this technically also applies to all other bus device abstractions
and they also have a `TryFrom<&device::Device<Ctx>>` implementation, so
with this it would be consistent across all rust bus device
abstractions.

Thanks
- Markus Probst

[1] https://rust.docs.kernel.org/kernel/pwm/trait.PwmOps.html

[2]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/rust/kernel/device.rs?id=e4addc7cc2dfcc19f1c8c8e47f3834b22cb21559

> 
> thanks,
> 
> greg k-h

Download attachment "signature.asc" of type "application/pgp-signature" (871 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ