@@ -175,7 +175,7 @@ impl DescriptorWriter<'_> {
175
175
pub fn interface ( & mut self , number : InterfaceNumber ,
176
176
interface_class : u8 , interface_sub_class : u8 , interface_protocol : u8 ) -> Result < ( ) >
177
177
{
178
- self . interface_alternate_setting (
178
+ self . interface_alt (
179
179
number,
180
180
device:: DEFAULT_ALTERNATE_SETTING ,
181
181
interface_class,
@@ -192,14 +192,14 @@ impl DescriptorWriter<'_> {
192
192
///
193
193
/// * `number` - Interface number previously allocated with
194
194
/// [`UsbBusAllocator::interface`](crate::bus::UsbBusAllocator::interface).
195
- /// * `alternate_setting` - number of the alternate setting
195
+ /// * `alternate_setting` - Number of the alternate setting
196
196
/// * `interface_class` - Class code assigned by USB.org. Use `0xff` for vendor-specific devices
197
197
/// that do not conform to any class.
198
198
/// * `interface_sub_class` - Sub-class code. Depends on class.
199
199
/// * `interface_protocol` - Protocol code. Depends on class and sub-class.
200
200
/// * `interface_string` - Index of string descriptor describing this interface
201
201
202
- pub fn interface_alternate_setting (
202
+ pub fn interface_alt (
203
203
& mut self ,
204
204
number : InterfaceNumber ,
205
205
alternate_setting : u8 ,
@@ -208,29 +208,27 @@ impl DescriptorWriter<'_> {
208
208
interface_protocol : u8 ,
209
209
interface_string : Option < StringIndex > ,
210
210
) -> Result < ( ) > {
211
- let ifndx = match interface_string {
212
- Some ( si) => si. into ( ) ,
213
- None => 0 ,
214
- } ;
215
211
if alternate_setting == device:: DEFAULT_ALTERNATE_SETTING {
216
212
match self . num_interfaces_mark {
217
213
Some ( mark) => self . buf [ mark] += 1 ,
218
214
None => return Err ( UsbError :: InvalidState ) ,
219
215
} ;
220
216
}
221
217
218
+ let str_index = interface_string. map_or ( 0 , Into :: into) ;
219
+
222
220
self . num_endpoints_mark = Some ( self . position + 4 ) ;
223
221
224
222
self . write (
225
223
descriptor_type:: INTERFACE ,
226
224
& [
227
225
number. into ( ) , // bInterfaceNumber
228
- alternate_setting, // bAlternateSetting (how to even handle these...)
226
+ alternate_setting, // bAlternateSetting
229
227
0 , // bNumEndpoints
230
228
interface_class, // bInterfaceClass
231
229
interface_sub_class, // bInterfaceSubClass
232
230
interface_protocol, // bInterfaceProtocol
233
- ifndx , // iInterface
231
+ str_index , // iInterface
234
232
] ,
235
233
) ?;
236
234
0 commit comments