Changeset 3597dab in mainline
- Timestamp:
- 2011-02-02T11:49:05Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a887bd1, ab65fa1, aec2ad4
- Parents:
- b00849e (diff), 93f8da1 (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 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
rb00849e r3597dab 104 104 } async_transaction_t; 105 105 106 static void async_transaction_destroy(async_transaction_t *trans) 107 { 108 if (trans == NULL) { 109 return; 110 } 111 112 if (trans->setup_packet != NULL) { 113 free(trans->setup_packet); 114 } 115 if (trans->buffer != NULL) { 116 free(trans->buffer); 117 } 118 119 free(trans); 120 } 121 122 static async_transaction_t *async_transaction_create(ipc_callid_t caller) 123 { 124 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 125 if (trans == NULL) { 126 return NULL; 127 } 128 129 trans->caller = caller; 130 trans->buffer = NULL; 131 trans->setup_packet = NULL; 132 trans->size = 0; 133 134 return trans; 135 } 136 106 137 void remote_usbhc_get_address(device_t *device, void *iface, 107 138 ipc_callid_t callid, ipc_call_t *call) … … 136 167 if (trans->buffer == NULL) { 137 168 ipc_answer_0(callid, EINVAL); 138 free(trans);169 async_transaction_destroy(trans); 139 170 return; 140 171 } … … 144 175 if (!async_data_read_receive(&cid, &accepted_size)) { 145 176 ipc_answer_0(callid, EINVAL); 177 async_transaction_destroy(trans); 146 178 return; 147 179 } … … 154 186 ipc_answer_1(callid, EOK, accepted_size); 155 187 156 free(trans->buffer); 157 free(trans); 188 async_transaction_destroy(trans); 158 189 } 159 190 … … 248 279 async_transaction_t *trans = (async_transaction_t *)arg; 249 280 250 // FIXME - answer according to outcome251 281 ipc_answer_0(trans->caller, outcome); 252 282 253 free(trans);283 async_transaction_destroy(trans); 254 284 } 255 285 … … 259 289 async_transaction_t *trans = (async_transaction_t *)arg; 260 290 261 // FIXME - answer according to outcome 262 ipc_answer_1(trans->caller, outcome, (sysarg_t)trans); 291 if (outcome != USB_OUTCOME_OK) { 292 ipc_answer_0(trans->caller, outcome); 293 async_transaction_destroy(trans); 294 return; 295 } 263 296 264 297 trans->size = actual_size; 298 ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans); 265 299 } 266 300 … … 300 334 } 301 335 302 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 303 trans->caller = callid; 304 trans->buffer = buffer; 305 trans->setup_packet = NULL; 306 trans->size = len; 307 308 int rc = transfer_func(device, target, buffer, len, 309 callback_out, trans); 310 311 if (rc != EOK) { 312 ipc_answer_0(callid, rc); 336 async_transaction_t *trans = async_transaction_create(callid); 337 if (trans == NULL) { 313 338 if (buffer != NULL) { 314 339 free(buffer); 315 340 } 316 free(trans); 341 ipc_answer_0(callid, ENOMEM); 342 return; 343 } 344 345 trans->buffer = buffer; 346 trans->size = len; 347 348 int rc = transfer_func(device, target, buffer, len, 349 callback_out, trans); 350 351 if (rc != EOK) { 352 ipc_answer_0(callid, rc); 353 async_transaction_destroy(trans); 317 354 } 318 355 } … … 340 377 }; 341 378 342 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 343 trans->caller = callid; 379 async_transaction_t *trans = async_transaction_create(callid); 380 if (trans == NULL) { 381 ipc_answer_0(callid, ENOMEM); 382 return; 383 } 344 384 trans->buffer = malloc(len); 345 trans->setup_packet = NULL;346 385 trans->size = len; 347 386 … … 351 390 if (rc != EOK) { 352 391 ipc_answer_0(callid, rc); 353 free(trans->buffer); 354 free(trans); 392 async_transaction_destroy(trans); 355 393 } 356 394 } … … 396 434 }; 397 435 398 async_transaction_t *trans = malloc(sizeof(async_transaction_t));399 trans->caller = callid;400 trans->buffer = NULL;401 trans->setup_packet = NULL;402 trans->size = 0;436 async_transaction_t *trans = async_transaction_create(callid); 437 if (trans == NULL) { 438 ipc_answer_0(callid, ENOMEM); 439 return; 440 } 403 441 404 442 int rc; … … 419 457 if (rc != EOK) { 420 458 ipc_answer_0(callid, rc); 421 free(trans); 422 } 423 return; 459 async_transaction_destroy(trans); 460 } 424 461 } 425 462 … … 537 574 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 538 575 if (rc != EOK) { 576 ipc_answer_0(callid, rc); 539 577 free(setup_packet); 540 ipc_answer_0(callid, rc); 541 return; 542 } 543 544 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 545 trans->caller = callid; 578 return; 579 } 580 581 async_transaction_t *trans = async_transaction_create(callid); 582 if (trans == NULL) { 583 ipc_answer_0(callid, ENOMEM); 584 free(setup_packet); 585 free(data_buffer); 586 return; 587 } 546 588 trans->setup_packet = setup_packet; 547 589 trans->buffer = data_buffer; … … 555 597 if (rc != EOK) { 556 598 ipc_answer_0(callid, rc); 557 free(setup_packet); 558 free(data_buffer); 559 free(trans); 599 async_transaction_destroy(trans); 560 600 } 561 601 } … … 591 631 } 592 632 593 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 594 trans->caller = callid; 633 async_transaction_t *trans = async_transaction_create(callid); 634 if (trans == NULL) { 635 ipc_answer_0(callid, ENOMEM); 636 free(setup_packet); 637 return; 638 } 595 639 trans->setup_packet = setup_packet; 640 trans->size = data_len; 596 641 trans->buffer = malloc(data_len); 597 trans->size = data_len; 642 if (trans->buffer == NULL) { 643 ipc_answer_0(callid, ENOMEM); 644 async_transaction_destroy(trans); 645 return; 646 } 598 647 599 648 rc = usb_iface->control_read(device, target, … … 604 653 if (rc != EOK) { 605 654 ipc_answer_0(callid, rc); 606 free(setup_packet); 607 free(trans->buffer); 608 free(trans); 655 async_transaction_destroy(trans); 609 656 } 610 657 }
Note:
See TracChangeset
for help on using the changeset viewer.