Ignore:
Timestamp:
2011-08-25T10:40:37Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
27873be
Parents:
32e093e
Message:

OHCI: Use destructor instead of manual clearing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hcd_endpoint.c

    r32e093e rb02308e  
    6161}
    6262/*----------------------------------------------------------------------------*/
     63/** Disposes hcd endpoint structure
     64 *
     65 * @param[in] hcd_ep endpoint structure
     66 */
     67static void hcd_ep_destroy(void *hcd_ep)
     68{
     69        if (hcd_ep) {
     70                hcd_endpoint_t *instance = hcd_ep;
     71                free32(instance->ed);
     72                free32(instance->td);
     73                free(instance);
     74        }
     75}
     76/*----------------------------------------------------------------------------*/
    6377/** Creates new hcd endpoint representation.
    6478 *
     
    6680 * @return pointer to a new hcd endpoint structure, NULL on failure.
    6781 */
    68 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep)
     82int hcd_endpoint_assign(endpoint_t *ep)
    6983{
    7084        assert(ep);
    7185        hcd_endpoint_t *hcd_ep = malloc(sizeof(hcd_endpoint_t));
    7286        if (hcd_ep == NULL)
    73                 return NULL;
     87                return ENOMEM;
    7488
    7589        hcd_ep->ed = malloc32(sizeof(ed_t));
    7690        if (hcd_ep->ed == NULL) {
    7791                free(hcd_ep);
    78                 return NULL;
     92                return ENOMEM;
    7993        }
    8094
     
    8397                free32(hcd_ep->ed);
    8498                free(hcd_ep);
    85                 return NULL;
     99                return ENOMEM;
    86100        }
    87101
     
    89103        ed_set_td(hcd_ep->ed, hcd_ep->td);
    90104        endpoint_set_hc_data(
    91             ep, hcd_ep, NULL, hcd_ep_toggle_get, hcd_ep_toggle_set);
     105            ep, hcd_ep, hcd_ep_destroy, hcd_ep_toggle_get, hcd_ep_toggle_set);
    92106
    93         return hcd_ep;
    94 }
    95 /*----------------------------------------------------------------------------*/
    96 /** Disposes assigned hcd endpoint structure
    97  *
    98  * @param[in] ep USBD endpoint structure
    99  */
    100 void hcd_endpoint_clear(endpoint_t *ep)
    101 {
    102         assert(ep);
    103         hcd_endpoint_t *hcd_ep = ep->hc_data.data;
    104         assert(hcd_ep);
    105         free32(hcd_ep->ed);
    106         free32(hcd_ep->td);
    107         free(hcd_ep);
     107        return EOK;
    108108}
    109109/**
Note: See TracChangeset for help on using the changeset viewer.