Skip to content

Commit

Permalink
gateware.usb.usb2.request: stall when handlers step on each other
Browse files Browse the repository at this point in the history
This commit changes the fallback mechanism to also stall when multiple
request handlers want to manage a setup packet at the same time.
  • Loading branch information
mndza committed Dec 6, 2023
1 parent a89405b commit d7dd849
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion luna/gateware/usb/usb2/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def elaborate(self, platform):
if len(self._request_handlers) > 0:
# Emit a stall when the request is not taken care of by the registered request handlers
handle_conditions = [handler.handled for handler in self._request_handlers]
stall_condition = lambda setup: reduce(operator.and_, (~cond(setup) for cond in handle_conditions))
stall_condition = lambda setup: sum((cond(setup) for cond in handle_conditions)) != 1
else:
stall_condition = lambda setup: True
self.add_request_handler(StallOnlyRequestHandler(stall_condition))
Expand Down

0 comments on commit d7dd849

Please sign in to comment.