Skip to content

Commit 42bce6f

Browse files
committed
Set DLAB directly.
1 parent 8c43283 commit 42bce6f

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

uart8250/src/uart.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,15 @@ impl<'a> MmioUart8250<'a> {
131131
/// | 115200 | 1 | $00 | $01 |
132132
#[inline]
133133
pub fn set_divisor(&self, clock: usize, baud_rate: usize) {
134-
self.enable_divisor_latch_accessible();
134+
// Enable DLAB.
135+
self.reg.lcr.modify(LCR::DLAB::SET);
136+
135137
let divisor = clock / (16 * baud_rate);
136138
self.reg.thr_rbr_dll.set(divisor as u8);
137139
self.reg.ier_dlh.set((divisor >> 8) as u8);
138-
self.disable_divisor_latch_accessible();
140+
141+
// Disable DLAB.
142+
self.reg.lcr.modify(LCR::DLAB::CLEAR);
139143
}
140144

141145
/// get whether low power mode (16750) is enabled (IER\[5\])
@@ -251,16 +255,6 @@ impl<'a> MmioUart8250<'a> {
251255
}
252256
}
253257

254-
/// enable DLAB
255-
fn enable_divisor_latch_accessible(&self) {
256-
self.reg.lcr.modify(LCR::DLAB::SET)
257-
}
258-
259-
/// disable DLAB
260-
fn disable_divisor_latch_accessible(&self) {
261-
self.reg.lcr.modify(LCR::DLAB::CLEAR)
262-
}
263-
264258
/// get parity of used data protocol
265259
pub fn get_parity(&self) -> Parity {
266260
self.reg

0 commit comments

Comments
 (0)