@@ -287,30 +287,41 @@ func addUSBDevice(ctx context.Context, serviceManager adapter.ServiceManager, se
287287 ctx : ctx ,
288288 pending : make (map [uint64 ]chan * USBURBResponse ),
289289 }
290- busID , err := provider .AddDevice (usbip.DynamicDeviceInfo {
291- BusID : descriptor .GetDeviceId (),
292- BusNum : descriptor .GetBusNum (),
293- DevNum : descriptor .GetDevNum (),
294- Speed : descriptor .GetSpeed (),
295- VendorID : uint16 (descriptor .GetVendorId ()),
296- ProductID : uint16 (descriptor .GetProductId ()),
297- BCDDevice : uint16 (descriptor .GetBcdDevice ()),
298- DeviceClass : uint8 (descriptor .GetDeviceClass ()),
299- DeviceSubClass : uint8 (descriptor .GetDeviceSubClass ()),
300- DeviceProtocol : uint8 (descriptor .GetDeviceProtocol ()),
301- ConfigurationValue : uint8 (descriptor .GetConfigurationValue ()),
302- NumConfigurations : uint8 (descriptor .GetNumConfigurations ()),
303- Interfaces : usbInterfacesFromProto (descriptor .GetInterfaces ()),
304- Serial : descriptor .GetSerial (),
305- Product : descriptor .GetProduct (),
306- }, device )
290+ entry := usbDeviceEntryFromDescriptor (descriptor )
291+ busID , err := provider .AddDevice (usbip.ProvidedDeviceInfo {Entry : entry }, device )
307292 if err != nil {
308293 return nil , err
309294 }
310295 device .busID = busID
311296 return device , nil
312297}
313298
299+ func usbDeviceEntryFromDescriptor (descriptor * USBDeviceDescriptor ) usbip.DeviceEntry {
300+ deviceID := descriptor .GetDeviceId ()
301+ interfaces := usbInterfacesFromProto (descriptor .GetInterfaces ())
302+ info := usbip.DeviceInfoTruncated {
303+ BusNum : descriptor .GetBusNum (),
304+ DevNum : descriptor .GetDevNum (),
305+ Speed : descriptor .GetSpeed (),
306+ IDVendor : uint16 (descriptor .GetVendorId ()),
307+ IDProduct : uint16 (descriptor .GetProductId ()),
308+ BCDDevice : uint16 (descriptor .GetBcdDevice ()),
309+ BDeviceClass : uint8 (descriptor .GetDeviceClass ()),
310+ BDeviceSubClass : uint8 (descriptor .GetDeviceSubClass ()),
311+ BDeviceProtocol : uint8 (descriptor .GetDeviceProtocol ()),
312+ BConfigurationValue : uint8 (descriptor .GetConfigurationValue ()),
313+ BNumConfigurations : uint8 (descriptor .GetNumConfigurations ()),
314+ BNumInterfaces : uint8 (len (interfaces )),
315+ }
316+ copy (info .BusID [:], deviceID )
317+ return usbip.DeviceEntry {
318+ Info : info ,
319+ Interfaces : interfaces ,
320+ Serial : descriptor .GetSerial (),
321+ Product : descriptor .GetProduct (),
322+ }
323+ }
324+
314325// sing-usbip calls Submit concurrently across endpoints for a single device.
315326type usbProvidedDevice struct {
316327 deviceID string
0 commit comments