Skip to content

Commit 3e8685f

Browse files
committed
uefi: Return AtaResponse from failed AtaDevice::execute_command()
The AtaResponse contains status register values that help identifying what went wrong.
1 parent f75e9c7 commit 3e8685f

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

uefi/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
## Changed
1010
- Changed ordering of `proto::pci::PciIoAddress` to (bus -> dev -> fun -> reg -> ext_reg).
11+
- Return request with status as error data object for `proto::ata::pass_thru::AtaDevice`.
1112

1213
# uefi - v0.36.1 (2025-11-05)
1314

uefi/src/proto/ata/pass_thru.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,25 @@ impl AtaDevice<'_> {
182182
/// - [`Status::UNSUPPORTED`] The host adapter does not support the command described by the ATA command.
183183
/// The command was not sent, and no additional status information is available.
184184
/// - [`Status::TIMEOUT`] A timeout occurred while waiting for the ATA command to execute. Refer to `Asb` for additional status details.
185+
#[allow(clippy::result_large_err)]
185186
pub fn execute_command<'req>(
186187
&mut self,
187188
mut req: AtaRequest<'req>,
188-
) -> crate::Result<AtaResponse<'req>> {
189+
) -> crate::Result<AtaResponse<'req>, AtaResponse<'req>> {
189190
req.packet.acb = &req.acb;
190-
unsafe {
191+
let result = unsafe {
191192
((*self.proto.get()).pass_thru)(
192193
self.proto.get(),
193194
self.port,
194195
self.pmp,
195196
&mut req.packet,
196197
ptr::null_mut(),
197198
)
198-
.to_result_with_val(|| AtaResponse { req })
199+
.to_result()
200+
};
201+
match result {
202+
Ok(_) => Ok(AtaResponse { req }),
203+
Err(s) => Err(crate::Error::new(s.status(), AtaResponse { req })),
199204
}
200205
}
201206
}

0 commit comments

Comments
 (0)