public inbox for rust-for-linux@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/2] rust: pci: add capability lookup helpers
@ 2026-02-01  7:42 Zijing Zhang
  2026-02-01  7:42 ` [PATCH v5 1/2] " Zijing Zhang
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Zijing Zhang @ 2026-02-01  7:42 UTC (permalink / raw)
  To: dakr, linux-pci, rust-for-linux
  Cc: bhelgaas, kwilczynski, ojeda, gary, dirk.behme, lianux.mm,
	Zijing Zhang

It introduces `pci::Device::{find_capability, find_ext_capability}`, thin 
wrappers around the PCI core helpers (`pci_find_capability()` and 
`pci_find_ext_capability()`), returning the config-space offset when present.

In `pci::CapabilityId` and  `pci::ExtendedCapabilityId`, Capability IDs are 
wrapped as newtypes with `from_raw()` plus a set of common constants.

An in-tree user is added to Rust PCI driver sample to exercise the new API.

Previous versions (v4)
https://lore.kernel.org/rust-for-linux/20260201071450.1614172-1-zijing.zhang@ry.rs/

Testing
---

Build
- x86_64 defconfig-based kernel with Rust enabled (out-of-tree build)
- `CONFIG_SAMPLES_RUST=y`
- `CONFIG_SAMPLE_RUST_DRIVER_PCI=y`

Runtime
- QEMU x86_64 (i440FX) with `-device pci-testdev`
- QEMU x86_64 (q35) with an NVMe device

Changelog
---

v2
- Run rustfmt on samples/rust/rust_driver_pci.rs to fix rustfmtcheck.

v3
- Base on pci/next.
- Add `CapabilityId`/`ExtendedCapabilityId`, switch `find_*capability()`
  to use them.
- Document the common ID constants.
- Update the sample to use typed IDs and exercise the new helpers.

v4
- Minor doc/style nits.
- Use early-return style in `find_*capability()`.


v5 (current)
- Fix sample build by using `pdev.as_ref()` for `dev_info!`.
- Use `as _` in constant definitions.

Zijing Zhang (2):
  rust: pci: add capability lookup helpers
  samples: rust: pci: exercise capability lookup

 rust/kernel/pci.rs              | 150 ++++++++++++++++++++++++++++++++
 samples/rust/rust_driver_pci.rs |  31 +++++++
 2 files changed, 181 insertions(+)


base-commit: ff0e2f679ab0de50a2e9e88fabc1026bc3be04ba
-- 
2.52.0


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

end of thread, other threads:[~2026-02-03  5:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-01  7:42 [PATCH v5 0/2] rust: pci: add capability lookup helpers Zijing Zhang
2026-02-01  7:42 ` [PATCH v5 1/2] " Zijing Zhang
2026-02-01  7:42 ` [PATCH v5 2/2] samples: rust: pci: exercise capability lookup Zijing Zhang
2026-02-02 14:13 ` [PATCH v5 0/2] rust: pci: add capability lookup helpers Gary Guo
2026-02-02 15:02 ` Gary Guo
2026-02-02 15:41   ` Zijing Zhang
2026-02-02 19:57     ` Zhi Wang
2026-02-03  5:42       ` Zijing Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox