Skip to content

Commit 6c96da0

Browse files
committed
pci: More convenience builder methods on PciIoAddress
1 parent f97a483 commit 6c96da0

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

uefi/src/proto/pci/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,30 @@ impl PciIoAddress {
3737
}
3838
}
3939

40+
/// Construct a new address with the bus address set to the given value
41+
#[must_use]
42+
pub const fn with_bus(&self, bus: u8) -> Self {
43+
let mut addr = *self;
44+
addr.bus = bus;
45+
addr
46+
}
47+
48+
/// Construct a new address with the device address set to the given value
49+
#[must_use]
50+
pub const fn with_device(&self, dev: u8) -> Self {
51+
let mut addr = *self;
52+
addr.dev = dev;
53+
addr
54+
}
55+
56+
/// Construct a new address with the function address set to the given value
57+
#[must_use]
58+
pub const fn with_function(&self, fun: u8) -> Self {
59+
let mut addr = *self;
60+
addr.fun = fun;
61+
addr
62+
}
63+
4064
/// Configure the **byte**-offset of the register to access.
4165
#[must_use]
4266
pub const fn with_register(&self, reg: u8) -> Self {

0 commit comments

Comments
 (0)