Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/hubops.c

    r1e32a63 r9223dc5c  
    6767    void *buffer, size_t size, size_t *actual_size);
    6868static 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);
    7169
    7270/** Standard USB requests. */
     
    137135        async_usleep(change->delay);
    138136       
    139         fibril_mutex_lock(&change->port->guard);
    140137        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        }
    144140       
    145141        free(change);
     
    170166void set_port_state(hub_port_t *port, hub_port_state_t state)
    171167{
    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));
    185170       
    186171        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);
    190175        }
    191176        if (state == HUB_PORT_STATE_RESUMING) {
     
    199184        if ((port->state == HUB_PORT_STATE_RESETTING)
    200185            && (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);
    202187        }
    203188       
     
    227212        _GET_PORT(port, portindex);
    228213       
    229         fibril_mutex_lock(&port->guard);
    230         int rc = ENOTSUP;
    231 
    232214        switch (feature) {
    233215                case USB_HUB_FEATURE_PORT_ENABLE:
    234216                        if ((port->state != HUB_PORT_STATE_NOT_CONFIGURED)
    235217                            && (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;
    240221               
    241222                case USB_HUB_FEATURE_PORT_SUSPEND:
    242223                        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;
    249228                       
    250229                case USB_HUB_FEATURE_PORT_POWER:
    251230                        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;
    256234               
    257235                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;
    261238               
    262239                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;
    266242               
    267243                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;
    271246                       
    272247                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;
    286253}
    287254
     
    318285        _GET_PORT(port, portindex);
    319286       
    320         fibril_mutex_lock(&port->guard);
    321 
    322287        uint32_t status;
    323288        status = MAKE_BYTE(
     
    347312        status |= (port->status_change << 16);
    348313       
    349         fibril_mutex_unlock(&port->guard);
    350 
    351314        dprintf(2, "GetPortStatus(port=%d, status=%u)\n", (int)portindex,
    352315            (unsigned int) status);
     
    364327        _GET_PORT(port, portindex);
    365328       
    366         fibril_mutex_lock(&port->guard);
    367 
    368         int rc = ENOTSUP;
    369 
    370329        switch (feature) {
    371330                case USB_HUB_FEATURE_PORT_RESET:
    372331                        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;
    377335               
    378336                case USB_HUB_FEATURE_PORT_SUSPEND:
    379337                        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;
    384341               
    385342                case USB_HUB_FEATURE_PORT_POWER:
    386343                        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;
    395349}
    396350
     
    462416}
    463417
    464 void clear_port_status_change_nl(hub_port_t *port, uint16_t change)
     418void clear_port_status_change(hub_port_t *port, uint16_t change)
    465419{
    466420        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
     423void set_port_status_change(hub_port_t *port, uint16_t change)
    472424{
    473425        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);
    491426}
    492427
     
    506441                hub_port_t *port = &hub_dev.ports[i];
    507442               
    508                 fibril_mutex_lock(&port->guard);
    509443                if (port->status_change != 0) {
    510444                        change_map |= (1 << (i + 1));
    511445                }
    512                 fibril_mutex_unlock(&port->guard);
    513446        }
    514447       
Note: See TracChangeset for help on using the changeset viewer.