Changes in uspace/lib/drv/generic/remote_usbhc.c [93f8da1:9753220] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usbhc.c
r93f8da1 r9753220 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 137 106 void remote_usbhc_get_address(device_t *device, void *iface, 138 107 ipc_callid_t callid, ipc_call_t *call) … … 167 136 if (trans->buffer == NULL) { 168 137 ipc_answer_0(callid, EINVAL); 169 async_transaction_destroy(trans);138 free(trans); 170 139 return; 171 140 } … … 175 144 if (!async_data_read_receive(&cid, &accepted_size)) { 176 145 ipc_answer_0(callid, EINVAL); 177 async_transaction_destroy(trans);178 146 return; 179 147 } … … 186 154 ipc_answer_1(callid, EOK, accepted_size); 187 155 188 async_transaction_destroy(trans); 156 free(trans->buffer); 157 free(trans); 189 158 } 190 159 … … 279 248 async_transaction_t *trans = (async_transaction_t *)arg; 280 249 250 // FIXME - answer according to outcome 281 251 ipc_answer_0(trans->caller, outcome); 282 252 283 async_transaction_destroy(trans);253 free(trans); 284 254 } 285 255 … … 289 259 async_transaction_t *trans = (async_transaction_t *)arg; 290 260 291 if (outcome != USB_OUTCOME_OK) { 292 ipc_answer_0(trans->caller, outcome); 293 async_transaction_destroy(trans); 294 return; 295 } 261 // FIXME - answer according to outcome 262 ipc_answer_1(trans->caller, outcome, (sysarg_t)trans); 296 263 297 264 trans->size = actual_size; 298 ipc_answer_1(trans->caller, USB_OUTCOME_OK, (sysarg_t)trans);299 265 } 300 266 … … 334 300 } 335 301 336 async_transaction_t *trans = async_transaction_create(callid); 337 if (trans == NULL) { 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); 338 313 if (buffer != NULL) { 339 314 free(buffer); 340 315 } 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); 316 free(trans); 354 317 } 355 318 } … … 377 340 }; 378 341 379 async_transaction_t *trans = async_transaction_create(callid); 380 if (trans == NULL) { 381 ipc_answer_0(callid, ENOMEM); 382 return; 383 } 342 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 343 trans->caller = callid; 384 344 trans->buffer = malloc(len); 345 trans->setup_packet = NULL; 385 346 trans->size = len; 386 347 … … 390 351 if (rc != EOK) { 391 352 ipc_answer_0(callid, rc); 392 async_transaction_destroy(trans); 353 free(trans->buffer); 354 free(trans); 393 355 } 394 356 } … … 434 396 }; 435 397 436 async_transaction_t *trans = async_transaction_create(callid);437 if (trans == NULL) {438 ipc_answer_0(callid, ENOMEM);439 return;440 }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; 441 403 442 404 int rc; … … 457 419 if (rc != EOK) { 458 420 ipc_answer_0(callid, rc); 459 async_transaction_destroy(trans); 460 } 421 free(trans); 422 } 423 return; 461 424 } 462 425 … … 574 537 1, USB_MAX_PAYLOAD_SIZE, 0, &data_buffer_len); 575 538 if (rc != EOK) { 576 ipc_answer_0(callid, rc);577 539 free(setup_packet); 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 } 540 ipc_answer_0(callid, rc); 541 return; 542 } 543 544 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 545 trans->caller = callid; 588 546 trans->setup_packet = setup_packet; 589 547 trans->buffer = data_buffer; … … 597 555 if (rc != EOK) { 598 556 ipc_answer_0(callid, rc); 599 async_transaction_destroy(trans); 557 free(setup_packet); 558 free(data_buffer); 559 free(trans); 600 560 } 601 561 } … … 631 591 } 632 592 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 } 593 async_transaction_t *trans = malloc(sizeof(async_transaction_t)); 594 trans->caller = callid; 639 595 trans->setup_packet = setup_packet; 596 trans->buffer = malloc(data_len); 640 597 trans->size = data_len; 641 trans->buffer = malloc(data_len);642 if (trans->buffer == NULL) {643 ipc_answer_0(callid, ENOMEM);644 async_transaction_destroy(trans);645 return;646 }647 598 648 599 rc = usb_iface->control_read(device, target, … … 653 604 if (rc != EOK) { 654 605 ipc_answer_0(callid, rc); 655 async_transaction_destroy(trans); 606 free(setup_packet); 607 free(trans->buffer); 608 free(trans); 656 609 } 657 610 }
Note:
See TracChangeset
for help on using the changeset viewer.