[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250319-try_with-v2-0-822ec63c05fb@nvidia.com>
Date: Wed, 19 Mar 2025 23:18:54 +0900
From: Alexandre Courbot <acourbot@...dia.com>
To: Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Danilo Krummrich <dakr@...nel.org>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>, Alice Ryhl <aliceryhl@...gle.com>,
Trevor Gross <tmgross@...ch.edu>, Bjorn Helgaas <bhelgaas@...gle.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org, Alexandre Courbot <acourbot@...dia.com>
Subject: [PATCH v2 0/2] rust/revocable: add try_access_with() convenience
method
This is a feature I found useful to have while writing Nova driver code
that accessed registers alongside other operations. I would find myself
quite confused about whether the guard was held or dropped at a given
point of the code, and it felt like walking through a minefield; this
pattern makes things safer and easier to read according to my experience
writing nova-core code.
Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
---
Changes in v2:
- Use FnOnce for the callback type.
- Rename to try_access_with.
- Don't assume that users will want to map failure to ENXIO and return
an option.
- Use a single method and let users adapt the behavior using their own
wrappers/macros.
---
Alexandre Courbot (2):
rust/revocable: add try_access_with() convenience method
samples: rust: convert PCI rust sample driver to use try_access_with()
rust/kernel/revocable.rs | 16 ++++++++++++++++
samples/rust/rust_driver_pci.rs | 11 +++++------
2 files changed, 21 insertions(+), 6 deletions(-)
---
base-commit: 7eb172143d5508b4da468ed59ee857c6e5e01da6
change-id: 20250313-try_with-cc9f91dd3b60
Best regards,
--
Alexandre Courbot <acourbot@...dia.com>
Powered by blists - more mailing lists