Ignore:
Timestamp:
2012-02-18T16:47:38Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4449c6c
Parents:
bd5f3b7 (diff), f943dd3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

File:
1 moved

Legend:

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

    rbd5f3b7 r00aece0  
    3333 */
    3434#include "utils/malloc32.h"
    35 #include "hcd_endpoint.h"
     35#include "ohci_endpoint.h"
     36#include "hc.h"
    3637
    3738/** Callback to set toggle on ED.
     
    4041 * @param[in] toggle new value of toggle bit
    4142 */
    42 static void hcd_ep_toggle_set(void *hcd_ep, int toggle)
     43static void ohci_ep_toggle_set(void *ohci_ep, int toggle)
    4344{
    44         hcd_endpoint_t *instance = hcd_ep;
     45        ohci_endpoint_t *instance = ohci_ep;
    4546        assert(instance);
    4647        assert(instance->ed);
     
    5354 * @return Current value of toggle bit.
    5455 */
    55 static int hcd_ep_toggle_get(void *hcd_ep)
     56static int ohci_ep_toggle_get(void *ohci_ep)
    5657{
    57         hcd_endpoint_t *instance = hcd_ep;
     58        ohci_endpoint_t *instance = ohci_ep;
    5859        assert(instance);
    5960        assert(instance->ed);
     
    6465 *
    6566 * @param[in] ep USBD endpoint structure
    66  * @return pointer to a new hcd endpoint structure, NULL on failure.
     67 * @return Error code.
    6768 */
    68 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep)
     69int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep)
    6970{
    7071        assert(ep);
    71         hcd_endpoint_t *hcd_ep = malloc(sizeof(hcd_endpoint_t));
    72         if (hcd_ep == NULL)
    73                 return NULL;
     72        ohci_endpoint_t *ohci_ep = malloc(sizeof(ohci_endpoint_t));
     73        if (ohci_ep == NULL)
     74                return ENOMEM;
    7475
    75         hcd_ep->ed = malloc32(sizeof(ed_t));
    76         if (hcd_ep->ed == NULL) {
    77                 free(hcd_ep);
    78                 return NULL;
     76        ohci_ep->ed = malloc32(sizeof(ed_t));
     77        if (ohci_ep->ed == NULL) {
     78                free(ohci_ep);
     79                return ENOMEM;
    7980        }
    8081
    81         hcd_ep->td = malloc32(sizeof(td_t));
    82         if (hcd_ep->td == NULL) {
    83                 free32(hcd_ep->ed);
    84                 free(hcd_ep);
    85                 return NULL;
     82        ohci_ep->td = malloc32(sizeof(td_t));
     83        if (ohci_ep->td == NULL) {
     84                free32(ohci_ep->ed);
     85                free(ohci_ep);
     86                return ENOMEM;
    8687        }
    8788
    88         ed_init(hcd_ep->ed, ep);
    89         ed_set_td(hcd_ep->ed, hcd_ep->td);
    90         endpoint_set_hc_data(ep, hcd_ep, hcd_ep_toggle_get, hcd_ep_toggle_set);
    91 
    92         return hcd_ep;
     89        ed_init(ohci_ep->ed, ep, ohci_ep->td);
     90        endpoint_set_hc_data(
     91            ep, ohci_ep, ohci_ep_toggle_get, ohci_ep_toggle_set);
     92        hc_enqueue_endpoint(hcd->private_data, ep);
     93        return EOK;
    9394}
    9495/*----------------------------------------------------------------------------*/
    95 /** Disposes assigned hcd endpoint structure
     96/** Disposes hcd endpoint structure
    9697 *
    97  * @param[in] ep USBD endpoint structure
     98 * @param[in] hcd driver using this instance.
     99 * @param[in] ep endpoint structure.
    98100 */
    99 void hcd_endpoint_clear(endpoint_t *ep)
     101void ohci_endpoint_fini(hcd_t *hcd, endpoint_t *ep)
    100102{
     103        assert(hcd);
    101104        assert(ep);
    102         hcd_endpoint_t *hcd_ep = ep->hc_data.data;
    103         assert(hcd_ep);
    104         free32(hcd_ep->ed);
    105         free32(hcd_ep->td);
    106         free(hcd_ep);
     105        ohci_endpoint_t *instance = ohci_endpoint_get(ep);
     106        hc_dequeue_endpoint(hcd->private_data, ep);
     107        if (instance) {
     108                free32(instance->ed);
     109                free32(instance->td);
     110                free(instance);
     111        }
     112        endpoint_clear_hc_data(ep);
    107113}
    108114/**
Note: See TracChangeset for help on using the changeset viewer.