Changeset 266d0871 in mainline for uspace/drv/vhc
- Timestamp:
- 2010-12-15T13:25:20Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1840e0d
- Parents:
- d5e7668
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hubops.c
rd5e7668 r266d0871 59 59 static int on_get_descriptor(struct usbvirt_device *dev, 60 60 usb_device_request_setup_packet_t *request, uint8_t *data); 61 static int on_set_configuration(struct usbvirt_device *dev,62 usb_device_request_setup_packet_t *request, uint8_t *data);63 61 static int on_data_request(struct usbvirt_device *dev, 64 62 usb_endpoint_t endpoint, … … 83 81 } 84 82 85 /** Callback for SET_CONFIGURATION request. */ 86 int on_set_configuration(struct usbvirt_device *dev, 87 usb_device_request_setup_packet_t *request, uint8_t *data) 88 { 89 /* We must suspend power source to all ports. */ 83 static void change_all_ports_state(hub_device_t *hub, hub_port_state_t state) 84 { 90 85 size_t i; 91 86 for (i = 0; i < HUB_PORT_COUNT; i++) { 92 hub_port_t *port = &hub_dev.ports[i]; 93 94 set_port_state(port, HUB_PORT_STATE_POWERED_OFF); 95 } 96 97 /* Let the framework handle the rest of the job. */ 98 return EFORWARD; 87 hub_port_t *port = &hub->ports[i]; 88 set_port_state(port, state); 89 } 90 } 91 92 /** Callback when device changes states. */ 93 static void on_state_change(struct usbvirt_device *dev, 94 usbvirt_device_state_t old_state, usbvirt_device_state_t new_state) 95 { 96 switch (new_state) { 97 case USBVIRT_STATE_CONFIGURED: 98 change_all_ports_state(&hub_dev, 99 HUB_PORT_STATE_POWERED_OFF); 100 break; 101 case USBVIRT_STATE_ADDRESS: 102 change_all_ports_state(&hub_dev, 103 HUB_PORT_STATE_NOT_CONFIGURED); 104 break; 105 default: 106 break; 107 } 99 108 } 100 109 … … 518 527 static usbvirt_control_transfer_handler_t endpoint_zero_handlers[] = { 519 528 { 520 STD_REQ(DIR_OUT, REC_DEVICE, USB_DEVREQ_SET_CONFIGURATION),521 .name = "SetConfiguration",522 .callback = on_set_configuration523 },524 {525 529 STD_REQ(DIR_IN, REC_DEVICE, USB_DEVREQ_GET_DESCRIPTOR), 526 530 .name = "GetDescriptor", … … 585 589 .control_transfer_handlers = endpoint_zero_handlers, 586 590 .on_data = NULL, 587 .on_data_request = on_data_request 591 .on_data_request = on_data_request, 592 .on_state_change = on_state_change, 588 593 }; 589 594
Note:
See TracChangeset
for help on using the changeset viewer.