code improvement

change variable names + using if let conditions instead match for
Result/Options values
This commit is contained in:
doryan 2025-02-14 00:16:04 +04:00
parent e27c5e7803
commit c5788c5b2e

View File

@ -146,9 +146,11 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
} }
fn is_stalled(&self, ep_addr: EndpointAddress) -> bool { fn is_stalled(&self, ep_addr: EndpointAddress) -> bool {
free(|cs| match self.select_endpoint(cs, ep_addr.index()) { free(|cs| {
Ok(_) => self.usb.borrow(cs).ueconx.read().stallrq().bit_is_set(), if self.select_endpoint(cs, ep_addr.index()).is_ok() {
Err(_) => false, return self.usb.borrow(cs).ueconx.read().stallrq().bit_is_set();
}
false
}) })
} }
@ -223,8 +225,8 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
free(|cs| { free(|cs| {
let usb = self.usb.borrow(cs); let usb = self.usb.borrow(cs);
if let Err(error) = self.select_endpoint(cs, ep_addr.index()) { if let Err(usb_error) = self.select_endpoint(cs, ep_addr.index()) {
Err(error) Err(usb_error)
} else { } else {
let ep = &self.ep_table[ep_addr.index()]; let ep = &self.ep_table[ep_addr.index()];
@ -261,11 +263,11 @@ impl<const L: usize> UsbBus for UsbDevice<L> {
.write(|w| w.clear_interrupts().rxouti().clear_bit()); .write(|w| w.clear_interrupts().rxouti().clear_bit());
let mut bytes_read = 0; let mut bytes_read = 0;
for slot in buf { for data in buf {
if usb.ueintx.read().rwal().bit_is_clear() { if usb.ueintx.read().rwal().bit_is_clear() {
break; break;
} }
*slot = usb.uedatx.read().bits(); *data = usb.uedatx.read().bits();
bytes_read += 1; bytes_read += 1;
} }