Skip to content

Commit c496425

Browse files
committed
nvme: mi: dev: Rework admin_send_invalid_field()
Increase utility by requiring the status to be sent as an argument, and renaming it to admin_send_status(). Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
1 parent e407cbb commit c496425

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

src/nvme/mi/dev.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,10 @@ where
936936
Ok(())
937937
}
938938

939-
async fn admin_send_invalid_field<C>(resp: &mut C) -> Result<(), ResponseStatus>
939+
async fn admin_send_status<C>(
940+
resp: &mut C,
941+
status: AdminIoCqeStatusType,
942+
) -> Result<(), ResponseStatus>
940943
where
941944
C: AsyncRespChannel,
942945
{
@@ -949,9 +952,7 @@ where
949952
cqedw3: AdminIoCqeStatus {
950953
cid: 0,
951954
p: true,
952-
status: AdminIoCqeStatusType::GenericCommandStatus(
953-
AdminIoCqeGenericCommandStatus::InvalidFieldInCommand,
954-
),
955+
status,
955956
crd: crate::nvme::CommandRetryDelay::None,
956957
m: false,
957958
dnr: true,
@@ -1019,7 +1020,13 @@ impl RequestHandler for AdminGetLogPageRequest {
10191020
if flags.contains(LidSupportedAndEffectsFlags::Ios) {
10201021
todo!("Add OT support");
10211022
} else {
1022-
return admin_send_invalid_field(resp).await;
1023+
return admin_send_status(
1024+
resp,
1025+
AdminIoCqeStatusType::GenericCommandStatus(
1026+
AdminIoCqeGenericCommandStatus::InvalidFieldInCommand,
1027+
),
1028+
)
1029+
.await;
10231030
}
10241031
}
10251032

@@ -1079,14 +1086,26 @@ impl RequestHandler for AdminGetLogPageRequest {
10791086
// Base v2.1, 5.1.2, Figure 199
10801087
let lpol = self.lpo & !3u64;
10811088
if lpol > 512 {
1082-
return admin_send_invalid_field(resp).await;
1089+
return admin_send_status(
1090+
resp,
1091+
AdminIoCqeStatusType::GenericCommandStatus(
1092+
AdminIoCqeGenericCommandStatus::InvalidFieldInCommand,
1093+
),
1094+
)
1095+
.await;
10831096
}
10841097

10851098
if self.nsid != 0 && self.nsid != u32::MAX {
10861099
if ctlr.lpa.contains(LogPageAttributes::Smarts) {
10871100
todo!();
10881101
} else {
1089-
return admin_send_invalid_field(resp).await;
1102+
return admin_send_status(
1103+
resp,
1104+
AdminIoCqeStatusType::GenericCommandStatus(
1105+
AdminIoCqeGenericCommandStatus::InvalidFieldInCommand,
1106+
),
1107+
)
1108+
.await;
10901109
}
10911110
}
10921111

0 commit comments

Comments
 (0)