File tree Expand file tree Collapse file tree 1 file changed +3
-21
lines changed Expand file tree Collapse file tree 1 file changed +3
-21
lines changed Original file line number Diff line number Diff line change @@ -95,29 +95,11 @@ impl Usbd {
95
95
unsafe { & * USBD :: ptr ( ) } . usbaddr . read ( ) . addr ( ) . bits ( )
96
96
}
97
97
98
- fn alloc_ep_buf (
99
- & mut self ,
100
- ep_type : EndpointType ,
101
- mut size : u16 ,
102
- ) -> usb_device:: Result < & ' static mut [ u8 ] > {
98
+ fn alloc_ep_buf ( & mut self , size : u16 ) -> usb_device:: Result < & ' static mut [ u8 ] > {
99
+ assert ! ( size <= 64 ) ;
103
100
if self . unalloc_buffers . len ( ) < usize:: from ( size) {
104
101
Err ( UsbError :: EndpointMemoryOverflow )
105
102
} else {
106
- if ep_type == EndpointType :: Bulk || ep_type == EndpointType :: Interrupt {
107
- // datasheet: buffer must be 4-byte aligned and its size must be a multiple of 4
108
- let rem = self . unalloc_buffers . as_mut_ptr ( ) as usize % 4 ;
109
- if rem != 0 {
110
- let ( _padding, remaining) =
111
- mem:: replace ( & mut self . unalloc_buffers , & mut [ ] ) . split_at_mut ( 4 - rem) ;
112
- self . unalloc_buffers = remaining;
113
- }
114
-
115
- let rem = size % 4 ;
116
- if rem != 0 {
117
- size = size + 4 - rem;
118
- }
119
- }
120
- assert ! ( size <= 64 ) ;
121
103
let ( alloc, remaining) =
122
104
mem:: replace ( & mut self . unalloc_buffers , & mut [ ] ) . split_at_mut ( size. into ( ) ) ;
123
105
self . unalloc_buffers = remaining;
@@ -201,7 +183,7 @@ impl UsbBus for Usbd {
201
183
202
184
// Endpoint directions are allocated individually.
203
185
204
- let buf = self . alloc_ep_buf ( ep_type , max_packet_size) ?;
186
+ let buf = self . alloc_ep_buf ( max_packet_size) ?;
205
187
206
188
if false {
207
189
unimplemented ! (
You can’t perform that action at this time.
0 commit comments