rust/hw/char/pl011: Extract DR write logic into separate function

- Split `write()` DR case into `write_data_register()`

Signed-off-by: Rakesh Jeyasingh <rakeshjb010@gmail.com>
Link: https://lore.kernel.org/r/20250407181327.171563-3-rakeshjb010@gmail.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Rakesh Jeyasingh 2025-04-07 23:43:27 +05:30 committed by Paolo Bonzini
parent efc5603292
commit 6d8c6dee3a

View file

@ -221,12 +221,7 @@ impl PL011Registers {
// eprintln!("write offset {offset} value {value}"); // eprintln!("write offset {offset} value {value}");
use RegisterOffset::*; use RegisterOffset::*;
match offset { match offset {
DR => { DR => return self.write_data_register(value),
// interrupts always checked
let _ = self.loopback_tx(value.into());
self.int_level |= Interrupt::TX.0;
return true;
}
RSR => { RSR => {
self.receive_status_error_clear = 0.into(); self.receive_status_error_clear = 0.into();
} }
@ -307,6 +302,13 @@ impl PL011Registers {
u32::from(c) u32::from(c)
} }
fn write_data_register(&mut self, value: u32) -> bool {
// interrupts always checked
let _ = self.loopback_tx(value.into());
self.int_level |= Interrupt::TX.0;
true
}
#[inline] #[inline]
#[must_use] #[must_use]
fn loopback_tx(&mut self, value: registers::Data) -> bool { fn loopback_tx(&mut self, value: registers::Data) -> bool {