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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGSQo00QVhDg_qMAwq+sW9y+nA0M-Zw+9zyPJpe99kbqrE1B3A@mail.gmail.com>
Date: Sat, 27 Dec 2025 10:49:05 -0800
From: Matthew Maurer <mmaurer@...gle.com>
To: Kari Argillander <kari.argillander@...il.com>
Cc: 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>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
	"Rafael J. Wysocki" <rafael@...nel.org>, linux-kernel@...r.kernel.org, 
	rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v4 3/3] rust: Add SoC Driver Sample

On Sat, Dec 27, 2025 at 7:53 AM Kari Argillander
<kari.argillander@...il.com> wrote:
>
> On Fri, 26 Dec 2025 at 22:18, Matthew Maurer <mmaurer@...gle.com> wrote:
>
> > +    fn probe(
> > +        pdev: &platform::Device<Core>,
> > +        _info: Option<&Self::IdInfo>,
> > +    ) -> impl PinInit<Self, Error> {
> > +        let dev = pdev.as_ref();
> > +
> > +        dev_dbg!(dev, "Probe Rust SoC driver sample.\n");
> > +
> > +        let pdev = pdev.into();
> > +        pin_init_scope(move || {
> > +            let machine = CString::try_from(c"My cool ACME15 dev board")?;
> > +            let family = CString::try_from(c"ACME")?;
> > +            let revision = CString::try_from(c"1.2")?;
> > +            let serial_number = CString::try_from(c"12345")?;
> > +            let soc_id = CString::try_from(c"ACME15")?;
> > +
> > +            let attr = soc::Attributes {
> > +                machine: Some(machine),
> > +                family: Some(family),
> > +                revision: Some(revision),
> > +                serial_number: Some(serial_number),
> > +                soc_id: Some(soc_id),
> > +            };
>
> To me it seems little bit awkward that all needs to be CStrings. Maybe something
> like this could be used (basically cow)
>
> ```rust
> pub enum AttrStr {
>     Static(&'static CStr),
>     Owned(CString),
>     None,
> }
> ```
>
> This will also take out Option with same time. Then some nice ergonomic way
> to use this. This is suggestion and I have nothing to do with soc layer.

IMO something like this should not be a SoC-specific special type.
Feel free to propose a `CowCStr` in `kernel::str`, or adding the more
general `Cow` and appropriate trait definitions to `kernel::alloc`,
and we could modify the API in the future. Basically, this seems like
a suggestion for a new vocabulary type rather than something for SoC.

We could technically also do a many-parameter'd struct and put `:
Deref<Target=CStr>` bounds on everything, but putting 6 type
parameters on something, which would then need explicit resolution
when `None` was used, seems potentially worse ergonomically.

>
>     Argillander

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ