Skip to content

Commit a3b7df3

Browse files
authored
Merge branch 'main' into docs
2 parents 493ceaf + 36e9732 commit a3b7df3

File tree

6 files changed

+50
-19
lines changed

6 files changed

+50
-19
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,20 @@ jobs:
6464

6565
- name: Run AML test suite
6666
run: cargo run --bin aml_tester -- -p tests --reset
67+
68+
clippy:
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v2
72+
with:
73+
submodules: 'recursive'
74+
- name: Install Rust
75+
uses: actions-rs/toolchain@v1
76+
with:
77+
toolchain: nightly
78+
default: true
79+
profile: minimal
80+
components: clippy
81+
82+
- name: Run clippy
83+
run: cargo clippy -p acpi

acpi/src/handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ where
5151
/// than `region_length`, due to requirements of the paging system or other reasoning.
5252
/// - `handler` should be the same `AcpiHandler` that created the mapping. When the `PhysicalMapping` is
5353
/// dropped, it will be used to unmap the structure.
54+
///
55+
/// ### Safety
56+
///
57+
/// The caller must ensure that the physical memory can be safely mapped.
5458
pub unsafe fn new(
5559
physical_start: usize,
5660
virtual_start: NonNull<T>,

acpi/src/lib.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
//! * Use [`AcpiTables::from_rsdp`] if you have the physical address of the RSDP
2929
//! * Use [`AcpiTables::from_rsdt`] if you have the physical address of the RSDT/XSDT
3030
//! * Use [`AcpiTables::search_for_rsdp_bios`] if you don't have the address of either, but **you know you are
31-
//! running on BIOS, not UEFI**
31+
//! running on BIOS, not UEFI**
3232
//!
3333
//! `AcpiTables` stores the addresses of all of the tables detected on a platform. The SDTs are parsed by this
3434
//! library, or can be accessed directly with `from_sdt`, while the `DSDT` and any `SSDTs` should be parsed with
@@ -199,7 +199,9 @@ where
199199
{
200200
/// Create an `AcpiTables` if you have the physical address of the RSDP.
201201
///
202-
/// ### Safety: Caller must ensure the provided address is valid to read as an RSDP.
202+
/// ### Safety
203+
///
204+
/// Caller must ensure the provided address is valid to read as an RSDP.
203205
pub unsafe fn from_rsdp(handler: H, address: usize) -> AcpiResult<Self> {
204206
let rsdp_mapping = unsafe { handler.map_physical_region::<Rsdp>(address, mem::size_of::<Rsdp>()) };
205207
rsdp_mapping.validate()?;
@@ -210,6 +212,11 @@ where
210212

211213
/// Search for the RSDP on a BIOS platform. This accesses BIOS-specific memory locations and will probably not
212214
/// work on UEFI platforms. See [`Rsdp::search_for_on_bios`] for details.
215+
/// details.
216+
///
217+
/// ### Safety
218+
///
219+
/// The caller must ensure that this function is called on BIOS platforms.
213220
pub unsafe fn search_for_rsdp_bios(handler: H) -> AcpiResult<Self> {
214221
let rsdp_mapping = unsafe { Rsdp::search_for_on_bios(handler.clone())? };
215222
// Safety: RSDP has been validated from `Rsdp::search_for_on_bios`
@@ -220,7 +227,9 @@ where
220227
/// from `from_rsdp` after validation, but can also be used if you've searched for the RSDP manually on a BIOS
221228
/// system.
222229
///
223-
/// ### Safety: Caller must ensure that the provided mapping is a fully validated RSDP.
230+
/// ### Safety
231+
///
232+
/// Caller must ensure that the provided mapping is a fully validated RSDP.
224233
pub unsafe fn from_validated_rsdp(handler: H, rsdp_mapping: PhysicalMapping<H, Rsdp>) -> AcpiResult<Self> {
225234
let revision = rsdp_mapping.revision();
226235
let root_table_mapping = if revision == 0 {
@@ -245,7 +254,9 @@ where
245254

246255
/// Create an `AcpiTables` if you have the physical address of the RSDT/XSDT.
247256
///
248-
/// ### Safety: Caller must ensure the provided address is valid RSDT/XSDT address.
257+
/// ### Safety
258+
///
259+
/// Caller must ensure the provided address is valid RSDT/XSDT address.
249260
pub unsafe fn from_rsdt(handler: H, revision: u8, address: usize) -> AcpiResult<Self> {
250261
let root_table_mapping = if revision == 0 {
251262
/*
@@ -404,7 +415,9 @@ impl AmlTable {
404415
}
405416
}
406417

407-
/// ### Safety: Caller must ensure the provided address is valid for being read as an `SdtHeader`.
418+
/// ### Safety
419+
///
420+
/// Caller must ensure the provided address is valid for being read as an `SdtHeader`.
408421
unsafe fn read_table<H: AcpiHandler, T: AcpiTable>(
409422
handler: H,
410423
address: usize,
@@ -427,7 +440,7 @@ where
427440
handler: H,
428441
}
429442

430-
impl<'t, H> Iterator for SsdtIterator<'t, H>
443+
impl<H> Iterator for SsdtIterator<'_, H>
431444
where
432445
H: AcpiHandler,
433446
{
@@ -475,7 +488,7 @@ where
475488
handler: H,
476489
}
477490

478-
impl<'t, H> Iterator for SdtHeaderIterator<'t, H>
491+
impl<H> Iterator for SdtHeaderIterator<'_, H>
479492
where
480493
H: AcpiHandler,
481494
{

acpi/src/madt.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ unsafe impl AcpiTable for Madt {
5353
impl Madt {
5454
pub fn get_mpwk_mailbox_addr(&self) -> Result<u64, AcpiError> {
5555
for entry in self.entries() {
56-
match entry {
57-
MadtEntry::MultiprocessorWakeup(entry) => {
58-
return Ok(entry.mailbox_address);
59-
}
60-
_ => {}
56+
if let MadtEntry::MultiprocessorWakeup(entry) = entry {
57+
return Ok(entry.mailbox_address);
6158
}
6259
}
6360
Err(AcpiError::InvalidMadt(MadtError::UnexpectedEntry))

acpi/src/managed_slice.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ where
1616
allocator: A,
1717
}
1818

19-
impl<'a, T, A> ManagedSlice<'a, T, A>
19+
impl<T, A> ManagedSlice<'_, T, A>
2020
where
2121
A: Allocator,
2222
{
@@ -34,13 +34,13 @@ where
3434
}
3535

3636
#[cfg(feature = "alloc")]
37-
impl<'a, T> ManagedSlice<'a, T, alloc::alloc::Global> {
37+
impl<T> ManagedSlice<'_, T, alloc::alloc::Global> {
3838
pub fn new(len: usize) -> AcpiResult<Self> {
3939
Self::new_in(len, alloc::alloc::Global)
4040
}
4141
}
4242

43-
impl<'a, T, A> Drop for ManagedSlice<'a, T, A>
43+
impl<T, A> Drop for ManagedSlice<'_, T, A>
4444
where
4545
A: Allocator,
4646
{
@@ -54,7 +54,7 @@ where
5454
}
5555
}
5656

57-
impl<'a, T, A> core::ops::Deref for ManagedSlice<'a, T, A>
57+
impl<T, A> core::ops::Deref for ManagedSlice<'_, T, A>
5858
where
5959
A: Allocator,
6060
{
@@ -65,7 +65,7 @@ where
6565
}
6666
}
6767

68-
impl<'a, T, A> core::ops::DerefMut for ManagedSlice<'a, T, A>
68+
impl<T, A> core::ops::DerefMut for ManagedSlice<'_, T, A>
6969
where
7070
A: Allocator,
7171
{

acpi/src/platform/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ where
102102
}
103103

104104
#[cfg(feature = "alloc")]
105-
impl<'a> PlatformInfo<'a, alloc::alloc::Global> {
105+
impl PlatformInfo<'_, alloc::alloc::Global> {
106106
pub fn new<H>(tables: &AcpiTables<H>) -> AcpiResult<Self>
107107
where
108108
H: AcpiHandler,
@@ -111,7 +111,7 @@ impl<'a> PlatformInfo<'a, alloc::alloc::Global> {
111111
}
112112
}
113113

114-
impl<'a, A> PlatformInfo<'a, A>
114+
impl<A> PlatformInfo<'_, A>
115115
where
116116
A: Allocator + Clone,
117117
{

0 commit comments

Comments
 (0)