Skip to content

Commit e863a07

Browse files
committed
pldm: Don't assume File PDR Record is first
Using the recent pldm-platform get_pdr() changes, we can iterate PDR records until we find a valid one (ie., a File Descriptor record). Signed-off-by: Jeremy Kerr <[email protected]>
1 parent b46c708 commit e863a07

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ futures-io = "0.3.30"
2525
hex = { version = "0.4.3", optional = true }
2626
log = "0.4.22"
2727
mctp = "0.2.0"
28-
mctp-estack = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "mctp-estack" }
28+
mctp-estack = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "2492e094f93f5f36f900b3ee958a289630400030", package = "mctp-estack" }
2929
nvme-mi-dev = { git = "https://github.com/CodeConstruct/nvme-mi-dev", branch = "main", optional = true }
3030
polling = "3.7.4"
31-
pldm = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "pldm", optional = true }
32-
pldm-file = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "pldm-file", optional = true }
33-
pldm-platform = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "pldm-platform", optional = true }
31+
pldm = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "2492e094f93f5f36f900b3ee958a289630400030", package = "pldm", optional = true }
32+
pldm-file = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "2492e094f93f5f36f900b3ee958a289630400030", package = "pldm-file", optional = true }
33+
pldm-platform = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "2492e094f93f5f36f900b3ee958a289630400030", package = "pldm-platform", optional = true }
3434
sha2 = {version = "0.10.9", optional = true }
3535
simplelog = "0.12.2"
3636
smol = "2.0.0"
@@ -39,4 +39,4 @@ uuid = { version = "1.16.0", features = ["v4"] }
3939

4040
# update nvme-mi-dev mctp dependency
4141
[patch.crates-io]
42-
mctp = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "mctp" }
42+
mctp = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "2492e094f93f5f36f900b3ee958a289630400030", package = "mctp" }

src/pldm.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-3.0
22

3-
use anyhow::{bail, Context, Result};
3+
use anyhow::{Context, Result};
44
use log::{debug, info, warn};
55
use sha2::{Digest, Sha256};
66

@@ -37,15 +37,21 @@ async fn pldm_pdr(
3737
debug!("PDR Repository Info: {pdr_info:?}");
3838

3939
// File Descriptor PDR
40-
let pdr_record = 1;
41-
let pdr = platrq::get_pdr(chan, pdr_record)
42-
.await
43-
.context("Get PDR failed")?;
44-
45-
let PdrRecord::FileDescriptor(file) = pdr else {
46-
bail!("Unexpected PDR record {pdr_record}: {pdr:?}");
40+
let mut pdrs = platrq::get_pdr(chan);
41+
42+
let file = loop {
43+
match pdrs.next().await {
44+
None => break None,
45+
Some(Ok(PdrRecord::FileDescriptor(file))) => break Some(file),
46+
Some(Ok(_)) => (),
47+
Some(Err(e)) => {
48+
debug!("Error reading PDR, skipping: {e}");
49+
}
50+
}
4751
};
4852

53+
let file = file.context("No File Descriptor PDR record found")?;
54+
4955
debug!("PDR: {file:?}");
5056

5157
Ok((

0 commit comments

Comments
 (0)