rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/2] rust/revocable: add try_access_with() convenience method
@ 2025-04-11 12:09 Alexandre Courbot
  2025-04-11 12:09 ` [PATCH v4 1/2] " Alexandre Courbot
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Alexandre Courbot @ 2025-04-11 12:09 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Boqun Feng, Gary Guo, Danilo Krummrich,
	Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
	Trevor Gross, Bjorn Helgaas
  Cc: rust-for-linux, linux-kernel, linux-pci, Alexandre Courbot

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@nvidia.com>
---
Changes in v4:
- Collected Reviewed-by tags.
- Link to v3: https://lore.kernel.org/r/20250406-try_with-v3-0-c0947842e768@nvidia.com

Changes in v3:
- Add Acked-by from v2.

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: 0af2f6be1b4281385b618cb86ad946eded089ac8
change-id: 20250313-try_with-cc9f91dd3b60

Best regards,
-- 
Alexandre Courbot <acourbot@nvidia.com>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-04-22 15:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-11 12:09 [PATCH v4 0/2] rust/revocable: add try_access_with() convenience method Alexandre Courbot
2025-04-11 12:09 ` [PATCH v4 1/2] " Alexandre Courbot
2025-04-15  4:37   ` [v4,1/2] " Joel Fernandes
2025-04-15  4:37   ` Joel Fernandes
2025-04-22 14:23   ` [PATCH v4 1/2] " Miguel Ojeda
2025-04-11 12:09 ` [PATCH v4 2/2] samples: rust: convert PCI rust sample driver to use try_access_with() Alexandre Courbot
2025-04-11 13:15 ` [PATCH v4 0/2] rust/revocable: add try_access_with() convenience method Danilo Krummrich
2025-04-22  8:01   ` Danilo Krummrich
2025-04-22 14:21     ` Miguel Ojeda
2025-04-22 15:27 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).