rust/kernel/revocable.rs | 16 ++++++++++++++++ samples/rust/rust_driver_pci.rs | 11 +++++------ 2 files changed, 21 insertions(+), 6 deletions(-)
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>
On Fri, Apr 11, 2025 at 09:09:37PM +0900, Alexandre Courbot wrote: > 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> With the following changes, applied to nova-next, thanks! * link `None`, `Some`, `Option` in doc-comment - Danilo
On Fri, Apr 11, 2025 at 09:09:37PM +0900, Alexandre Courbot wrote: > 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. Any concerns taking this through the nova tree?
On 4/11/25 3:15 PM, Danilo Krummrich wrote: > On Fri, Apr 11, 2025 at 09:09:37PM +0900, Alexandre Courbot wrote: >> 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. > > Any concerns taking this through the nova tree? @Miguel: Can I get an ACK for taking it through the nova tree?
On Tue, Apr 22, 2025 at 10:01 AM Danilo Krummrich <dakr@kernel.org> wrote: > > @Miguel: Can I get an ACK for taking it through the nova tree? Sure, please go ahead: Acked-by: Miguel Ojeda <ojeda@kernel.org> (Sorry, I missed replying to the other one) Cheers, Miguel
© 2016 - 2025 Red Hat, Inc.