Skip to content

Commit 78e5165

Browse files
committed
Don't expose DLAB.
1 parent 684b3a9 commit 78e5165

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

uart8250/src/uart.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,15 @@ impl<'a> MmioUart8250<'a> {
113113
/// | 115200 | 1 | $00 | $01 |
114114
#[inline]
115115
pub fn set_divisor(&self, clock: usize, baud_rate: usize) {
116-
self.enable_divisor_latch_accessible();
116+
// Enable DLAB.
117+
self.reg.lcr.modify(LCR::DLAB::SET);
118+
117119
let divisor = clock / (16 * baud_rate);
118120
self.reg.thr_rbr_dll.set(divisor as u8);
119121
self.reg.ier_dlh.set((divisor >> 8) as u8);
120-
self.disable_divisor_latch_accessible();
122+
123+
// Disable DLAB.
124+
self.reg.lcr.modify(LCR::DLAB::CLEAR);
121125
}
122126

123127
/// Get IER bitflags
@@ -284,21 +288,6 @@ impl<'a> MmioUart8250<'a> {
284288
!self.reg.iir_fcr.is_set(IIR::InterruptPending)
285289
}
286290

287-
/// get whether DLAB is enabled
288-
pub fn is_divisor_latch_accessible(&self) -> bool {
289-
self.reg.lcr.read(LCR::DLAB) != 0
290-
}
291-
292-
/// enable DLAB
293-
pub fn enable_divisor_latch_accessible(&self) {
294-
self.reg.lcr.modify(LCR::DLAB::SET)
295-
}
296-
297-
/// disable DLAB
298-
pub fn disable_divisor_latch_accessible(&self) {
299-
self.reg.lcr.modify(LCR::DLAB::CLEAR)
300-
}
301-
302291
/// get parity of used data protocol
303292
pub fn get_parity(&self) -> Parity {
304293
self.reg
@@ -453,7 +442,6 @@ mod tests {
453442
assert!(matches!(uart.get_parity(), Parity::No));
454443
assert_eq!(uart.get_stop_bit(), 1);
455444
assert_eq!(uart.get_word_length(), 8);
456-
assert_eq!(uart.is_divisor_latch_accessible(), false);
457445
}
458446

459447
#[test]

0 commit comments

Comments
 (0)