Changeset b02308e in mainline
- Timestamp:
- 2011-08-25T10:40:37Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 27873be
- Parents:
- 32e093e
- Location:
- uspace/drv/bus/usb/ohci
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
r32e093e rb02308e 238 238 return ENOMEM; 239 239 240 hcd_endpoint_t *hcd_ep= hcd_endpoint_assign(ep);241 if ( hcd_ep == NULL) {240 int ret = hcd_endpoint_assign(ep); 241 if (ret != EOK) { 242 242 endpoint_destroy(ep); 243 return ENOMEM; 244 } 245 246 int ret = 247 usb_endpoint_manager_register_ep(&instance->ep_manager, ep, size); 243 return ret; 244 } 245 246 ret = usb_endpoint_manager_register_ep(&instance->ep_manager, ep, size); 248 247 if (ret != EOK) { 249 hcd_endpoint_clear(ep);250 248 endpoint_destroy(ep); 251 249 return ret; … … 257 255 instance->registers->control &= ~C_CLE; 258 256 endpoint_list_add_ep( 259 &instance->lists[ep->transfer_type], hcd_e p);257 &instance->lists[ep->transfer_type], hcd_endpoint_get(ep)); 260 258 instance->registers->control_current = 0; 261 259 instance->registers->control |= C_CLE; … … 264 262 instance->registers->control &= ~C_BLE; 265 263 endpoint_list_add_ep( 266 &instance->lists[ep->transfer_type], hcd_e p);264 &instance->lists[ep->transfer_type], hcd_endpoint_get(ep)); 267 265 instance->registers->control |= C_BLE; 268 266 break; … … 271 269 instance->registers->control &= (~C_PLE & ~C_IE); 272 270 endpoint_list_add_ep( 273 &instance->lists[ep->transfer_type], hcd_e p);271 &instance->lists[ep->transfer_type], hcd_endpoint_get(ep)); 274 272 instance->registers->control |= C_PLE | C_IE; 275 273 break; … … 327 325 break; 328 326 } 329 hcd_endpoint_clear(ep);330 327 } else { 331 328 usb_log_warning("Endpoint without hcd equivalent structure.\n"); -
uspace/drv/bus/usb/ohci/hcd_endpoint.c
r32e093e rb02308e 61 61 } 62 62 /*----------------------------------------------------------------------------*/ 63 /** Disposes hcd endpoint structure 64 * 65 * @param[in] hcd_ep endpoint structure 66 */ 67 static 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 /*----------------------------------------------------------------------------*/ 63 77 /** Creates new hcd endpoint representation. 64 78 * … … 66 80 * @return pointer to a new hcd endpoint structure, NULL on failure. 67 81 */ 68 hcd_endpoint_t *hcd_endpoint_assign(endpoint_t *ep)82 int hcd_endpoint_assign(endpoint_t *ep) 69 83 { 70 84 assert(ep); 71 85 hcd_endpoint_t *hcd_ep = malloc(sizeof(hcd_endpoint_t)); 72 86 if (hcd_ep == NULL) 73 return NULL;87 return ENOMEM; 74 88 75 89 hcd_ep->ed = malloc32(sizeof(ed_t)); 76 90 if (hcd_ep->ed == NULL) { 77 91 free(hcd_ep); 78 return NULL;92 return ENOMEM; 79 93 } 80 94 … … 83 97 free32(hcd_ep->ed); 84 98 free(hcd_ep); 85 return NULL;99 return ENOMEM; 86 100 } 87 101 … … 89 103 ed_set_td(hcd_ep->ed, hcd_ep->td); 90 104 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); 92 106 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; 108 108 } 109 109 /** -
uspace/drv/bus/usb/ohci/hcd_endpoint.h
r32e093e rb02308e 52 52 } hcd_endpoint_t; 53 53 54 hcd_endpoint_t * hcd_endpoint_assign(endpoint_t *ep); 55 void hcd_endpoint_clear(endpoint_t *ep); 54 int hcd_endpoint_assign(endpoint_t *ep); 56 55 57 56 /** Get and convert assigned hcd_endpoint_t structure
Note:
See TracChangeset
for help on using the changeset viewer.