@@ -122,7 +122,7 @@ struct device {
122122 DEVICE_STATE_CONFIGURED ,
123123 } state : 2 ;
124124 uint8_t address : 7 , numPorts : 7 ;
125- hub_t hub [] ;
125+ hub_t hub ;
126126};
127127
128128struct context {
@@ -261,7 +261,7 @@ static int device_init(context_t *context, struct libusb_device *libusb_device)
261261 (unsigned char * )& hub_desc ,
262262 offsetof(struct usb_hub_descriptor ,
263263 wHubCharacteristics ), 1000 ));
264- size += sizeof (hub_t ) + sizeof ( port_t ) * hub_desc .bNbrPorts ;
264+ size += sizeof (port_t ) * hub_desc .bNbrPorts ;
265265 }
266266 if (error != USB_SUCCESS ) {
267267 libusb_close (handle );
@@ -280,9 +280,9 @@ static int device_init(context_t *context, struct libusb_device *libusb_device)
280280 device -> address = 0 ;
281281 device -> numPorts = hub_desc .bNbrPorts ;
282282 if (device -> numPorts ) {
283- device -> hub -> statusChange .value = 0 ;
283+ device -> hub . statusChange .value = 0 ;
284284 for (uint8_t portIdx = 0 ; portIdx != device -> numPorts ; ++ portIdx ) {
285- port_t * port = & device -> hub -> ports [portIdx ];
285+ port_t * port = & device -> hub . ports [portIdx ];
286286 port -> device = NULL ;
287287 port -> statusChange .value = 0 ;
288288 }
@@ -293,7 +293,7 @@ static int device_init(context_t *context, struct libusb_device *libusb_device)
293293 if (parent -> handle && libusb_get_device (parent -> handle ) == libusb_parent ) {
294294 uint8_t portNum = libusb_get_port_number (libusb_device );
295295 if (0 < portNum && portNum <= parent -> numPorts ) {
296- port_t * port = & parent -> hub -> ports [portNum - 1 ];
296+ port_t * port = & parent -> hub . ports [portNum - 1 ];
297297 port -> device = device ;
298298 if (port -> status .power ) {
299299 device -> state = DEVICE_STATE_POWERED ;
@@ -340,7 +340,7 @@ static device_t *device_detach(context_t *context, device_t *device) {
340340 if (parent -> handle && libusb_get_device (parent -> handle ) == libusb_parent ) {
341341 uint8_t portNum = libusb_get_port_number (libusb_device );
342342 if (0 < portNum && portNum <= parent -> numPorts ) {
343- port_t * port = & parent -> hub -> ports [portNum - 1 ];
343+ port_t * port = & parent -> hub . ports [portNum - 1 ];
344344 port -> device = NULL ;
345345 if (port -> status .power ) {
346346 UPDATE_STATUS_CHANGE (port , connection , false);
@@ -470,8 +470,8 @@ static int device_intercept_control_setup(context_t *context, device_t *device,
470470 }
471471 if (device -> state >= DEVICE_STATE_CONFIGURED && !setup -> wValue && !setup -> wIndex ) {
472472 * status = LIBUSB_TRANSFER_COMPLETED ;
473- transfer_append (transfer , & device -> hub -> statusChange ,
474- sizeof (device -> hub -> statusChange ));
473+ transfer_append (transfer , & device -> hub . statusChange ,
474+ sizeof (device -> hub . statusChange ));
475475 }
476476 break ;
477477 case LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_OTHER :
@@ -481,8 +481,8 @@ static int device_intercept_control_setup(context_t *context, device_t *device,
481481 if (device -> state >= DEVICE_STATE_CONFIGURED
482482 && !setup -> wValue && setup -> wIndex && setup -> wIndex <= device -> numPorts ) {
483483 * status = LIBUSB_TRANSFER_COMPLETED ;
484- transfer_append (transfer , & device -> hub -> ports [setup -> wIndex - 1 ].statusChange ,
485- sizeof (device -> hub -> ports [setup -> wIndex - 1 ].statusChange ));
484+ transfer_append (transfer , & device -> hub . ports [setup -> wIndex - 1 ].statusChange ,
485+ sizeof (device -> hub . ports [setup -> wIndex - 1 ].statusChange ));
486486 }
487487 break ;
488488 default :
@@ -498,7 +498,7 @@ static int device_intercept_control_setup(context_t *context, device_t *device,
498498 if (device -> state >= DEVICE_STATE_CONFIGURED
499499 && setup -> wValue < 2 && !setup -> wIndex ) {
500500 * status = LIBUSB_TRANSFER_COMPLETED ;
501- device -> hub -> change .value &= ~(UINT16_C (1 ) << setup -> wValue );
501+ device -> hub . change .value &= ~(UINT16_C (1 ) << setup -> wValue );
502502 }
503503 break ;
504504 case LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_OTHER :
@@ -510,7 +510,7 @@ static int device_intercept_control_setup(context_t *context, device_t *device,
510510 && setup -> wIndex && setup -> wIndex <= device -> numPorts ) {
511511 * status = LIBUSB_TRANSFER_COMPLETED ;
512512 if (UINT32_C (0x5F0106 ) >> setup -> wValue & 1 ) {
513- port_t * port = & device -> hub -> ports [setup -> wIndex - 1 ];
513+ port_t * port = & device -> hub . ports [setup -> wIndex - 1 ];
514514 port -> statusChange .value &= ~(UINT32_C (1 ) << setup -> wValue );
515515 switch (setup -> wValue ) {
516516 case 8 :
@@ -537,7 +537,7 @@ static int device_intercept_control_setup(context_t *context, device_t *device,
537537 if (device -> state >= DEVICE_STATE_CONFIGURED
538538 && setup -> wValue < 2 && !setup -> wIndex ) {
539539 * status = LIBUSB_TRANSFER_COMPLETED ;
540- device -> hub -> change .value |= UINT16_C (1 ) << setup -> wValue ;
540+ device -> hub . change .value |= UINT16_C (1 ) << setup -> wValue ;
541541 }
542542 break ;
543543 case LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_OTHER :
@@ -549,7 +549,7 @@ static int device_intercept_control_setup(context_t *context, device_t *device,
549549 && setup -> wIndex && setup -> wIndex <= device -> numPorts ) {
550550 * status = LIBUSB_TRANSFER_COMPLETED ;
551551 if (UINT32_C (0x7F0114 ) >> setup -> wValue & 1 ) {
552- port_t * port = & device -> hub -> ports [setup -> wIndex - 1 ];
552+ port_t * port = & device -> hub . ports [setup -> wIndex - 1 ];
553553 port -> statusChange .value |= UINT32_C (1 ) << setup -> wValue ;
554554 switch (setup -> wValue ) {
555555 case 4 :
@@ -875,15 +875,15 @@ static int device_intercept_interrupt(device_t *device, transfer_t *transfer) {
875875 struct libusb_transfer * libusb_transfer = transfer -> transfer ;
876876 if (transfer -> state >= TRANSFER_STATE_PENDING && libusb_transfer -> endpoint & LIBUSB_ENDPOINT_IN
877877 && device -> numPorts ) {
878- uint8_t any = 0 , byte = !!device -> hub -> change .value ;
878+ uint8_t any = 0 , byte = !!device -> hub . change .value ;
879879 for (uint8_t portIdx = 0 ; portIdx != device -> numPorts ; ++ portIdx ) {
880880 uint8_t bit = (1 + portIdx ) & 7 ;
881881 if (!bit ) {
882882 transfer_append (transfer , & byte , sizeof (byte ));
883883 any |= byte ;
884884 byte = 0 ;
885885 }
886- if (device -> hub -> ports [portIdx ].change .value ) {
886+ if (device -> hub . ports [portIdx ].change .value ) {
887887 byte |= UINT8_C (1 ) << bit ;
888888 }
889889 }
0 commit comments