Linux Serial subsystem development
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Markus Probst" <markus.probst@posteo.de>,
	"Gary Guo" <gary@garyguo.net>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>
Cc: <linux-serial@vger.kernel.org>, <rust-for-linux@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] rust: serdev: remove `serdev::Timeout`
Date: Sat, 18 Jul 2026 16:23:05 +0100	[thread overview]
Message-ID: <DK1STJX916M3.J94WL07DKDHW@garyguo.net> (raw)
In-Reply-To: <dd8cc1a98c48338bd8b29168d312b7a1f466c8f3.camel@posteo.de>

On Sat Jul 18, 2026 at 4:12 PM BST, Markus Probst wrote:
> On Sat, 2026-07-18 at 16:02 +0100, Gary Guo wrote:
>> On Sat Jul 18, 2026 at 1:47 PM BST, Markus Probst wrote:
>> > Instead of relying on its own timeout types, the abstraction should make
>> > use of `impl Into<Jiffies>`.
>> > 
>> > Suggested-by: Gary Guo <gary@garyguo.net>
>> > Link: https://lore.kernel.org/rust-for-linux/DK0SX3P5K1J6.1OV4ETJMXW83R@garyguo.net/
>> > Signed-off-by: Markus Probst <markus.probst@posteo.de>
>> > ---
>> >  rust/kernel/serdev.rs | 55 +++++++++++++++++----------------------------------
>> >  1 file changed, 18 insertions(+), 37 deletions(-)
>> > 
>> > diff --git a/rust/kernel/serdev.rs b/rust/kernel/serdev.rs
>> > index a78dfa6e2c27..0fdb37cff15d 100644
>> > --- a/rust/kernel/serdev.rs
>> > +++ b/rust/kernel/serdev.rs
>> > @@ -20,11 +20,7 @@
>> >          aref::AlwaysRefCounted,
>> >          Mutex, //
>> >      },
>> > -    time::{
>> > -        msecs_to_jiffies,
>> > -        Jiffies,
>> > -        Msecs, //
>> > -    },
>> > +    time::Jiffies,
>> >      types::{
>> >          Opaque,
>> >          ScopeGuard, //
>> > @@ -35,7 +31,6 @@
>> >      cell::UnsafeCell,
>> >      marker::PhantomData,
>> >      mem::{offset_of, MaybeUninit},
>> > -    num::NonZero,
>> >      ptr::NonNull, //
>> >  };
>> >  
>> > @@ -50,30 +45,6 @@ pub enum Parity {
>> >      Odd = bindings::serdev_parity_SERDEV_PARITY_ODD,
>> >  }
>> >  
>> > -/// Timeout in Jiffies.
>> > -pub enum Timeout {
>> > -    /// Wait for a specific amount of [`Jiffies`].
>> > -    Jiffies(NonZero<Jiffies>),
>> > -    /// Wait for a specific amount of [`Msecs`].
>> > -    Milliseconds(NonZero<Msecs>),
>> > -    /// Wait as long as possible.
>> > -    ///
>> > -    /// This is equivalent to [`kernel::task::MAX_SCHEDULE_TIMEOUT`].
>> > -    Max,
>> > -}
>> > -
>> > -impl Timeout {
>> > -    fn into_jiffies(self) -> isize {
>> > -        match self {
>> > -            Self::Jiffies(value) => value.get().try_into().unwrap_or_default(),
>> > -            Self::Milliseconds(value) => {
>> > -                msecs_to_jiffies(value.get()).try_into().unwrap_or_default()
>> > -            }
>> > -            Self::Max => 0,
>> > -        }
>> > -    }
>> > -}
>> > -
>> >  /// An adapter for the registration of serial device bus device drivers.
>> >  pub struct Adapter<T: Driver>(T);
>> >  
>> > @@ -379,7 +350,7 @@ macro_rules! module_serdev_device_driver {
>> >  ///         _id_info: Option<&'bound Self::IdInfo>,
>> >  ///     ) -> impl PinInit<Self::Data<'bound>, Error> + 'bound {
>> >  ///         sdev.set_baudrate(115200);
>> > -///         sdev.write_all(b"Hello\n", serdev::Timeout::Max)?;
>> > +///         sdev.write_all(b"Hello\n", 0usize)?;
>> 
>> Note that the jiffies type is being converted to a new type (in fact,
>> `Into<Jiffies>` only make sense with it being a new type.
> I assume it won't take long for the patch series for the new type to be
> merged. Currently there is no user for any other timeout than 0 (which
> corrosponds to MAX_SCHEDULE_TIMEOUT in serdev).
>
> Or should I revert to `serdev::Timeout` until then?

`Timeout` uses `Jiffies` and `Msec` directly which would be changed too. I
think we just need to treat this as conflict and figure out how to handle the
conflict.

I think realistic there're some designs to still iron out for the jiffy series,
so yours one may land first. The easiest thing is probably just have API that
take `Jiffies` type directly without `Into` (as having it doesn't bring much
value at the moment), and that can be converted by the jiffy series.

Best,
Gary


  reply	other threads:[~2026-07-18 15:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 12:47 [PATCH v2 0/4] rust: serdev: trivial fixes Markus Probst
2026-07-18 12:47 ` [PATCH v2 1/4] rust: serdev: fix typo in rustdoc Markus Probst
2026-07-18 12:47 ` [PATCH v2 2/4] rust: serdev: mark small functions as `#[inline]` Markus Probst
2026-07-18 12:47 ` [PATCH v2 3/4] rust: serdev: document `PrivateData::active` Markus Probst
2026-07-18 12:47 ` [PATCH v2 4/4] rust: serdev: remove `serdev::Timeout` Markus Probst
2026-07-18 15:02   ` Gary Guo
2026-07-18 15:12     ` Markus Probst
2026-07-18 15:23       ` Gary Guo [this message]
2026-07-18 14:10 ` [PATCH v2 0/4] rust: serdev: trivial fixes Danilo Krummrich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DK1STJX916M3.J94WL07DKDHW@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=markus.probst@posteo.de \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox