From c324f301e6a3faa7031483c58edbee309765d603 Mon Sep 17 00:00:00 2001 From: Matt Baker Date: Tue, 4 Jun 2024 16:43:11 -0700 Subject: [PATCH] usb: fix enumeration issues by propagating buffer overflow error. --- hal/CHANGELOG.md | 1 + hal/src/peripherals/usb/d11/bus.rs | 4 ++-- hal/src/peripherals/usb/d5x/bus.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/hal/CHANGELOG.md b/hal/CHANGELOG.md index c584c7c3fc7..93e668e9534 100644 --- a/hal/CHANGELOG.md +++ b/hal/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased Changes +- Fix USB enumeration issues with fast host controllers - Allow configuring USB clock with `GenericClockController` on atsamd11 - fix samd51j not having i2s support - remove i2s functionality for samd51g since it does not have it diff --git a/hal/src/peripherals/usb/d11/bus.rs b/hal/src/peripherals/usb/d11/bus.rs index 94a521d42ea..e3fc049eaea 100644 --- a/hal/src/peripherals/usb/d11/bus.rs +++ b/hal/src/peripherals/usb/d11/bus.rs @@ -898,7 +898,7 @@ impl Inner { let rxstp = bank.received_setup_interrupt(); if bank.is_ready() || rxstp { - let size = bank.read(buf); + let size = bank.read(buf)?; if rxstp { bank.clear_received_setup_interrupt(); @@ -907,7 +907,7 @@ impl Inner { bank.clear_transfer_complete(); bank.set_ready(false); - size + Ok(size) } else { Err(UsbError::WouldBlock) } diff --git a/hal/src/peripherals/usb/d5x/bus.rs b/hal/src/peripherals/usb/d5x/bus.rs index 50ab2ae3c03..aa0d8a629b6 100644 --- a/hal/src/peripherals/usb/d5x/bus.rs +++ b/hal/src/peripherals/usb/d5x/bus.rs @@ -841,7 +841,7 @@ impl Inner { let rxstp = bank.received_setup_interrupt(); if bank.is_ready() || rxstp { - let size = bank.read(buf); + let size = bank.read(buf)?; if rxstp { bank.clear_received_setup_interrupt(); @@ -850,7 +850,7 @@ impl Inner { bank.clear_transfer_complete(); bank.set_ready(false); - size + Ok(size) } else { Err(UsbError::WouldBlock) }