Changes in uspace/drv/vhc/hubops.c [10096231:138a7fd] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/drv/vhc/hubops.c ¶
r10096231 r138a7fd 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); 61 63 static int on_class_request(struct usbvirt_device *dev, 62 64 usb_device_request_setup_packet_t *request, uint8_t *data); … … 64 66 usb_endpoint_t endpoint, 65 67 void *buffer, size_t size, size_t *actual_size); 68 static void set_port_state(hub_port_t *, hub_port_state_t); 66 69 67 70 /** Standard USB requests. */ … … 74 77 .on_set_descriptor = NULL, 75 78 .on_get_configuration = NULL, 76 .on_set_configuration = NULL,79 .on_set_configuration = on_set_configuration, 77 80 .on_get_interface = NULL, 78 81 .on_set_interface = NULL, … … 102 105 } 103 106 107 /** Callback for SET_CONFIGURATION request. */ 108 int on_set_configuration(struct usbvirt_device *dev, 109 usb_device_request_setup_packet_t *request, uint8_t *data) 110 { 111 /* We must suspend power source to all ports. */ 112 size_t i; 113 for (i = 0; i < HUB_PORT_COUNT; i++) { 114 hub_port_t *port = &hub_dev.ports[i]; 115 116 set_port_state(port, HUB_PORT_STATE_POWERED_OFF); 117 } 118 119 /* Let the framework handle the rest of the job. */ 120 return EFORWARD; 121 } 122 123 struct delay_port_state_change { 124 suseconds_t delay; 125 hub_port_state_t old_state; 126 hub_port_state_t new_state; 127 hub_port_t *port; 128 }; 129 130 static int set_port_state_delayed_fibril(void *arg) 131 { 132 struct delay_port_state_change *change 133 = (struct delay_port_state_change *) arg; 134 135 async_usleep(change->delay); 136 137 if (change->port->state == change->old_state) { 138 set_port_state(change->port, change->new_state); 139 } 140 141 free(change); 142 143 return EOK; 144 } 145 146 static void set_port_state_delayed(hub_port_t *port, 147 suseconds_t delay_time, 148 hub_port_state_t old_state, hub_port_state_t new_state) 149 { 150 struct delay_port_state_change *change 151 = malloc(sizeof(struct delay_port_state_change)); 152 change->port = port; 153 change->delay = delay_time; 154 change->old_state = old_state; 155 change->new_state = new_state; 156 fid_t fibril = fibril_create(set_port_state_delayed_fibril, change); 157 if (fibril == 0) { 158 printf("Failed to create fibril\n"); 159 return; 160 } 161 fibril_add_ready(fibril); 162 } 163 104 164 /** Change port status and updates status change status fields. 105 165 */ 106 static void set_port_state(hub_port_t *port, hub_port_state_t state) 107 { 108 port->state = state; 166 void set_port_state(hub_port_t *port, hub_port_state_t state) 167 { 168 dprintf(1, "setting port %d state to %d (%c)", port->index, 169 state, hub_port_state_as_char(state)); 170 109 171 if (state == HUB_PORT_STATE_POWERED_OFF) { 110 172 clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); … … 113 175 } 114 176 if (state == HUB_PORT_STATE_RESUMING) { 115 async_usleep(10*1000); 116 if (port->state == state) { 117 set_port_state(port, HUB_PORT_STATE_ENABLED); 118 } 177 set_port_state_delayed(port, 10*1000, 178 HUB_PORT_STATE_RESUMING, HUB_PORT_STATE_ENABLED); 119 179 } 120 180 if (state == HUB_PORT_STATE_RESETTING) { 121 async_usleep(10*1000); 122 if (port->state == state) { 123 set_port_status_change(port, HUB_STATUS_C_PORT_RESET); 124 set_port_state(port, HUB_PORT_STATE_ENABLED); 125 } 126 } 181 set_port_state_delayed(port, 10*1000, 182 HUB_PORT_STATE_RESETTING, HUB_PORT_STATE_ENABLED); 183 } 184 if ((port->state == HUB_PORT_STATE_RESETTING) 185 && (state == HUB_PORT_STATE_ENABLED)) { 186 set_port_status_change(port, HUB_STATUS_C_PORT_RESET); 187 } 188 189 port->state = state; 127 190 } 128 191 … … 249 312 status |= (port->status_change << 16); 250 313 314 dprintf(2, "GetPortStatus(port=%d, status=%u)\n", (int)portindex, 315 (unsigned int) status); 251 316 return virthub_dev.control_transfer_reply(&virthub_dev, 0, &status, 4); 252 317 } … … 291 356 usb_device_request_setup_packet_t *request, uint8_t *data) 292 357 { 293 dprintf(2, "hub class request (%d) \n", (int) request->request);358 dprintf(2, "hub class request (%d)", (int) request->request); 294 359 295 360 uint8_t recipient = request->request_type & 31; … … 340 405 341 406 default: 407 dprintf(0, "WARN: unknown request (%d)!\n", 408 request->request); 342 409 break; 343 410 }
Note:
See TracChangeset
for help on using the changeset viewer.