usb: do not allow converting Directon to/from u8

This commit is contained in:
Dario Nieuwenhuis
2022-09-26 12:35:33 +02:00
parent 7f7c14b7bc
commit f4f5824972
2 changed files with 3 additions and 10 deletions

View File

@ -106,7 +106,7 @@ impl Request {
let recipient = rt & 0b11111;
Request {
direction: rt.into(),
direction: if rt & 0x80 == 0 { Direction::Out } else { Direction::In },
request_type: unsafe { mem::transmute((rt >> 5) & 0b11) },
recipient: if recipient <= 3 {
unsafe { mem::transmute(recipient) }