Skip to content

Commit 0454c41

Browse files
committed
Rename memory mapped SerialPort to MmioSerialPort
1 parent fb207ba commit 0454c41

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/lib.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
//! ## With `mmio_{stable, nightly}` feature
2222
//!
2323
//! ```rust
24-
//! use uart_16550::SerialPort;
24+
//! use uart_16550::MmioSerialPort;
2525
//!
2626
//! const SERIAL_IO_PORT: usize = 0x1000_0000;
2727
//!
@@ -39,9 +39,10 @@
3939
#![warn(missing_docs)]
4040
#![cfg_attr(feature = "mmio_nightly", feature(const_ptr_offset))]
4141

42-
use bitflags::bitflags;
4342
use core::fmt;
4443

44+
use bitflags::bitflags;
45+
4546
#[cfg(any(
4647
all(
4748
not(any(feature = "port_stable", feature = "port_nightly")),
@@ -52,16 +53,17 @@ use core::fmt;
5253
any(feature = "mmio_stable", feature = "mmio_nightly")
5354
)
5455
))]
55-
compile_error!(
56-
"One of these features must be enabled: `port_{stable, nightly}`, `mmio_{stable, nightly}`"
57-
);
56+
compile_error!("One of these features must be enabled: `port_{stable, nightly}`, `mmio_{stable, nightly}`");
57+
58+
#[cfg(any(feature = "mmio_stable", feature = "mmio_nightly"))]
59+
use core::sync::atomic::{
60+
AtomicPtr,
61+
Ordering,
62+
};
5863

5964
#[cfg(any(feature = "port_stable", feature = "port_nightly"))]
6065
use x86_64::instructions::port::Port;
6166

62-
#[cfg(any(feature = "mmio_stable", feature = "mmio_nightly"))]
63-
use core::sync::atomic::{AtomicPtr, Ordering};
64-
6567
macro_rules! wait_for {
6668
($cond:expr) => {
6769
while !$cond {
@@ -182,11 +184,11 @@ impl SerialPort {
182184
self.data.write(b' ');
183185
wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
184186
self.data.write(8)
185-
}
187+
},
186188
_ => {
187189
wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
188190
self.data.write(data);
189-
}
191+
},
190192
}
191193
}
192194
}
@@ -202,7 +204,7 @@ impl SerialPort {
202204

203205
/// An interface to a serial port that allows sending out individual bytes.
204206
#[cfg(any(feature = "mmio_stable", feature = "mmio_nightly"))]
205-
pub struct SerialPort {
207+
pub struct MmioSerialPort {
206208
data: AtomicPtr<u8>,
207209
int_en: AtomicPtr<u8>,
208210
fifo_ctrl: AtomicPtr<u8>,
@@ -295,11 +297,11 @@ impl SerialPort {
295297
self_data.write(b' ');
296298
wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
297299
self_data.write(8)
298-
}
300+
},
299301
_ => {
300302
wait_for!(self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY));
301303
self_data.write(data);
302-
}
304+
},
303305
}
304306
}
305307
}

0 commit comments

Comments
 (0)