Changes in uspace/drv/vhc/hubops.c [1e32a63:9223dc5c] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/hubops.c
r1e32a63 r9223dc5c 67 67 void *buffer, size_t size, size_t *actual_size); 68 68 static void set_port_state(hub_port_t *, hub_port_state_t); 69 static void clear_port_status_change_nl(hub_port_t *, uint16_t);70 static void set_port_state_nl(hub_port_t *, hub_port_state_t);71 69 72 70 /** Standard USB requests. */ … … 137 135 async_usleep(change->delay); 138 136 139 fibril_mutex_lock(&change->port->guard);140 137 if (change->port->state == change->old_state) { 141 set_port_state_nl(change->port, change->new_state); 142 } 143 fibril_mutex_unlock(&change->port->guard); 138 set_port_state(change->port, change->new_state); 139 } 144 140 145 141 free(change); … … 170 166 void set_port_state(hub_port_t *port, hub_port_state_t state) 171 167 { 172 fibril_mutex_lock(&port->guard); 173 set_port_state_nl(port, state); 174 fibril_mutex_unlock(&port->guard); 175 } 176 177 void set_port_state_nl(hub_port_t *port, hub_port_state_t state) 178 { 179 180 dprintf(2, "setting port %d state to %d (%c) from %c (change=%u)", 181 port->index, 182 state, hub_port_state_as_char(state), 183 hub_port_state_as_char(port->state), 184 (unsigned int) port->status_change); 168 dprintf(1, "setting port %d state to %d (%c)", port->index, 169 state, hub_port_state_as_char(state)); 185 170 186 171 if (state == HUB_PORT_STATE_POWERED_OFF) { 187 clear_port_status_change _nl(port, HUB_STATUS_C_PORT_CONNECTION);188 clear_port_status_change _nl(port, HUB_STATUS_C_PORT_ENABLE);189 clear_port_status_change _nl(port, HUB_STATUS_C_PORT_RESET);172 clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); 173 clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE); 174 clear_port_status_change(port, HUB_STATUS_C_PORT_RESET); 190 175 } 191 176 if (state == HUB_PORT_STATE_RESUMING) { … … 199 184 if ((port->state == HUB_PORT_STATE_RESETTING) 200 185 && (state == HUB_PORT_STATE_ENABLED)) { 201 set_port_status_change _nl(port, HUB_STATUS_C_PORT_RESET);186 set_port_status_change(port, HUB_STATUS_C_PORT_RESET); 202 187 } 203 188 … … 227 212 _GET_PORT(port, portindex); 228 213 229 fibril_mutex_lock(&port->guard);230 int rc = ENOTSUP;231 232 214 switch (feature) { 233 215 case USB_HUB_FEATURE_PORT_ENABLE: 234 216 if ((port->state != HUB_PORT_STATE_NOT_CONFIGURED) 235 217 && (port->state != HUB_PORT_STATE_POWERED_OFF)) { 236 set_port_state_nl(port, HUB_PORT_STATE_DISABLED); 237 } 238 rc = EOK; 239 break; 218 set_port_state(port, HUB_PORT_STATE_DISABLED); 219 } 220 return EOK; 240 221 241 222 case USB_HUB_FEATURE_PORT_SUSPEND: 242 223 if (port->state != HUB_PORT_STATE_SUSPENDED) { 243 rc = EOK; 244 break; 245 } 246 set_port_state_nl(port, HUB_PORT_STATE_RESUMING); 247 rc = EOK; 248 break; 224 return EOK; 225 } 226 set_port_state(port, HUB_PORT_STATE_RESUMING); 227 return EOK; 249 228 250 229 case USB_HUB_FEATURE_PORT_POWER: 251 230 if (port->state != HUB_PORT_STATE_NOT_CONFIGURED) { 252 set_port_state_nl(port, HUB_PORT_STATE_POWERED_OFF); 253 } 254 rc = EOK; 255 break; 231 set_port_state(port, HUB_PORT_STATE_POWERED_OFF); 232 } 233 return EOK; 256 234 257 235 case USB_HUB_FEATURE_C_PORT_CONNECTION: 258 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_CONNECTION); 259 rc = EOK; 260 break; 236 clear_port_status_change(port, HUB_STATUS_C_PORT_CONNECTION); 237 return EOK; 261 238 262 239 case USB_HUB_FEATURE_C_PORT_ENABLE: 263 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_ENABLE); 264 rc = EOK; 265 break; 240 clear_port_status_change(port, HUB_STATUS_C_PORT_ENABLE); 241 return EOK; 266 242 267 243 case USB_HUB_FEATURE_C_PORT_SUSPEND: 268 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_SUSPEND); 269 rc = EOK; 270 break; 244 clear_port_status_change(port, HUB_STATUS_C_PORT_SUSPEND); 245 return EOK; 271 246 272 247 case USB_HUB_FEATURE_C_PORT_OVER_CURRENT: 273 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_OVER_CURRENT); 274 rc = EOK; 275 break; 276 277 case USB_HUB_FEATURE_C_PORT_RESET: 278 clear_port_status_change_nl(port, HUB_STATUS_C_PORT_RESET); 279 rc = EOK; 280 break; 281 } 282 283 fibril_mutex_unlock(&port->guard); 284 285 return rc; 248 clear_port_status_change(port, HUB_STATUS_C_PORT_OVER_CURRENT); 249 return EOK; 250 } 251 252 return ENOTSUP; 286 253 } 287 254 … … 318 285 _GET_PORT(port, portindex); 319 286 320 fibril_mutex_lock(&port->guard);321 322 287 uint32_t status; 323 288 status = MAKE_BYTE( … … 347 312 status |= (port->status_change << 16); 348 313 349 fibril_mutex_unlock(&port->guard);350 351 314 dprintf(2, "GetPortStatus(port=%d, status=%u)\n", (int)portindex, 352 315 (unsigned int) status); … … 364 327 _GET_PORT(port, portindex); 365 328 366 fibril_mutex_lock(&port->guard);367 368 int rc = ENOTSUP;369 370 329 switch (feature) { 371 330 case USB_HUB_FEATURE_PORT_RESET: 372 331 if (port->state != HUB_PORT_STATE_POWERED_OFF) { 373 set_port_state_nl(port, HUB_PORT_STATE_RESETTING); 374 } 375 rc = EOK; 376 break; 332 set_port_state(port, HUB_PORT_STATE_RESETTING); 333 } 334 return EOK; 377 335 378 336 case USB_HUB_FEATURE_PORT_SUSPEND: 379 337 if (port->state == HUB_PORT_STATE_ENABLED) { 380 set_port_state_nl(port, HUB_PORT_STATE_SUSPENDED); 381 } 382 rc = EOK; 383 break; 338 set_port_state(port, HUB_PORT_STATE_SUSPENDED); 339 } 340 return EOK; 384 341 385 342 case USB_HUB_FEATURE_PORT_POWER: 386 343 if (port->state == HUB_PORT_STATE_POWERED_OFF) { 387 set_port_state_nl(port, HUB_PORT_STATE_DISCONNECTED); 388 } 389 rc = EOK; 390 break; 391 } 392 393 fibril_mutex_unlock(&port->guard); 394 return rc; 344 set_port_state(port, HUB_PORT_STATE_DISCONNECTED); 345 } 346 return EOK; 347 } 348 return ENOTSUP; 395 349 } 396 350 … … 462 416 } 463 417 464 void clear_port_status_change _nl(hub_port_t *port, uint16_t change)418 void clear_port_status_change(hub_port_t *port, uint16_t change) 465 419 { 466 420 port->status_change &= (~change); 467 dprintf(2, "cleared port %d status change %d (%u)", port->index, 468 (int)change, (unsigned int) port->status_change); 469 } 470 471 void set_port_status_change_nl(hub_port_t *port, uint16_t change) 421 } 422 423 void set_port_status_change(hub_port_t *port, uint16_t change) 472 424 { 473 425 port->status_change |= change; 474 dprintf(2, "set port %d status change %d (%u)", port->index,475 (int)change, (unsigned int) port->status_change);476 477 }478 479 void clear_port_status_change(hub_port_t *port, uint16_t change)480 {481 fibril_mutex_lock(&port->guard);482 clear_port_status_change_nl(port, change);483 fibril_mutex_unlock(&port->guard);484 }485 486 void set_port_status_change(hub_port_t *port, uint16_t change)487 {488 fibril_mutex_lock(&port->guard);489 set_port_status_change_nl(port, change);490 fibril_mutex_unlock(&port->guard);491 426 } 492 427 … … 506 441 hub_port_t *port = &hub_dev.ports[i]; 507 442 508 fibril_mutex_lock(&port->guard);509 443 if (port->status_change != 0) { 510 444 change_map |= (1 << (i + 1)); 511 445 } 512 fibril_mutex_unlock(&port->guard);513 446 } 514 447
Note:
See TracChangeset
for help on using the changeset viewer.