Changeset fd07e526 in mainline for uspace/drv/bus/usb/ohci/ohci_endpoint.c
- Timestamp:
- 2011-09-16T14:50:20Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 432a269, d1e18573
- Parents:
- 47fecbb (diff), 82a31261 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_endpoint.c
r47fecbb rfd07e526 33 33 */ 34 34 #include "utils/malloc32.h" 35 #include "hcd_endpoint.h" 35 #include "ohci_endpoint.h" 36 #include "hc.h" 36 37 37 38 /** Callback to set toggle on ED. … … 40 41 * @param[in] toggle new value of toggle bit 41 42 */ 42 static void hcd_ep_toggle_set(void *hcd_ep, int toggle)43 static void ohci_ep_toggle_set(void *ohci_ep, int toggle) 43 44 { 44 hcd_endpoint_t *instance = hcd_ep;45 ohci_endpoint_t *instance = ohci_ep; 45 46 assert(instance); 46 47 assert(instance->ed); … … 53 54 * @return Current value of toggle bit. 54 55 */ 55 static int hcd_ep_toggle_get(void *hcd_ep)56 static int ohci_ep_toggle_get(void *ohci_ep) 56 57 { 57 hcd_endpoint_t *instance = hcd_ep;58 ohci_endpoint_t *instance = ohci_ep; 58 59 assert(instance); 59 60 assert(instance->ed); 60 61 return ed_toggle_get(instance->ed); 62 } 63 /*----------------------------------------------------------------------------*/ 64 /** Disposes hcd endpoint structure 65 * 66 * @param[in] hcd_ep endpoint structure 67 */ 68 static void ohci_endpoint_fini(endpoint_t *ep) 69 { 70 ohci_endpoint_t *instance = ep->hc_data.data; 71 hc_dequeue_endpoint(instance->hcd->private_data, ep); 72 if (instance) { 73 free32(instance->ed); 74 free32(instance->td); 75 free(instance); 76 } 61 77 } 62 78 /*----------------------------------------------------------------------------*/ … … 66 82 * @return pointer to a new hcd endpoint structure, NULL on failure. 67 83 */ 68 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep)84 int ohci_endpoint_init(hcd_t *hcd, endpoint_t *ep) 69 85 { 70 86 assert(ep); 71 hcd_endpoint_t *hcd_ep = malloc(sizeof(hcd_endpoint_t));72 if ( hcd_ep == NULL)73 return NULL;87 ohci_endpoint_t *ohci_ep = malloc(sizeof(ohci_endpoint_t)); 88 if (ohci_ep == NULL) 89 return ENOMEM; 74 90 75 hcd_ep->ed = malloc32(sizeof(ed_t));76 if ( hcd_ep->ed == NULL) {77 free( hcd_ep);78 return NULL;91 ohci_ep->ed = malloc32(sizeof(ed_t)); 92 if (ohci_ep->ed == NULL) { 93 free(ohci_ep); 94 return ENOMEM; 79 95 } 80 96 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;97 ohci_ep->td = malloc32(sizeof(td_t)); 98 if (ohci_ep->td == NULL) { 99 free32(ohci_ep->ed); 100 free(ohci_ep); 101 return ENOMEM; 86 102 } 87 103 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; 93 } 94 /*----------------------------------------------------------------------------*/ 95 /** Disposes assigned hcd endpoint structure 96 * 97 * @param[in] ep USBD endpoint structure 98 */ 99 void hcd_endpoint_clear(endpoint_t *ep) 100 { 101 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); 104 ed_init(ohci_ep->ed, ep); 105 ed_set_td(ohci_ep->ed, ohci_ep->td); 106 endpoint_set_hc_data( 107 ep, ohci_ep, ohci_endpoint_fini, ohci_ep_toggle_get, ohci_ep_toggle_set); 108 ohci_ep->hcd = hcd; 109 hc_enqueue_endpoint(hcd->private_data, ep); 110 return EOK; 107 111 } 108 112 /**
Note:
See TracChangeset
for help on using the changeset viewer.