Changeset 592369ae in mainline


Ignore:
Timestamp:
2011-04-13T13:09:18Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9a6fde4
Parents:
5a2c42b
Message:

Add proper locking to prevent use/remove race

Location:
uspace/drv/ohci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/ohci/hc.c

    r5a2c42b r592369ae  
    152152        hcd_endpoint_t *hcd_ep = hcd_endpoint_assign(ep);
    153153        if (hcd_ep == NULL) {
    154                 free(ep);
     154                endpoint_destroy(ep);
    155155                return ENOMEM;
    156156        }
     
    158158        ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, size);
    159159        if (ret != EOK) {
     160                hcd_endpoint_clear(ep);
    160161                endpoint_destroy(ep);
    161162                return ret;
     
    188189        }
    189190
    190         return ret;
     191        return EOK;
    191192}
    192193/*----------------------------------------------------------------------------*/
     
    194195    usb_endpoint_t endpoint, usb_direction_t direction)
    195196{
     197        assert(instance);
     198        fibril_mutex_lock(&instance->guard);
    196199        endpoint_t *ep = usb_endpoint_manager_get_ep(&instance->ep_manager,
    197200            address, endpoint, direction, NULL);
    198201        if (ep == NULL) {
    199                 usb_log_error("Endpoint unregister failed.\n");
     202                usb_log_error("Endpoint unregister failed: No such EP.\n");
     203                fibril_mutex_unlock(&instance->guard);
    200204                return ENOENT;
    201205        }
     
    232236                usb_log_warning("Endpoint without hcd equivalent structure.\n");
    233237        }
    234         return usb_endpoint_manager_unregister_ep(&instance->ep_manager,
     238        int ret = usb_endpoint_manager_unregister_ep(&instance->ep_manager,
    235239            address, endpoint, direction);
     240        fibril_mutex_unlock(&instance->guard);
     241        return ret;
     242}
     243/*----------------------------------------------------------------------------*/
     244endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
     245    usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw)
     246{
     247        assert(instance);
     248        fibril_mutex_lock(&instance->guard);
     249        endpoint_t *ep = usb_endpoint_manager_get_ep(&instance->ep_manager,
     250            address, endpoint, direction, bw);
     251        fibril_mutex_unlock(&instance->guard);
     252        return ep;
    236253}
    237254/*----------------------------------------------------------------------------*/
  • uspace/drv/ohci/hc.h

    r5a2c42b r592369ae  
    8585    usb_endpoint_t endpoint, usb_direction_t direction);
    8686
     87endpoint_t * hc_get_endpoint(hc_t *instance, usb_address_t address,
     88    usb_endpoint_t endpoint, usb_direction_t direction, size_t *bw);
     89
    8790int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
    8891
  • uspace/drv/ohci/iface.c

    r5a2c42b r592369ae  
    5555
    5656        size_t res_bw;
    57         endpoint_t *ep = usb_endpoint_manager_get_ep(&(*hc)->ep_manager,
     57        endpoint_t *ep = hc_get_endpoint(*hc,
    5858            target.address, target.endpoint, direction, &res_bw);
    5959        if (ep == NULL) {
Note: See TracChangeset for help on using the changeset viewer.