Changeset 89a0485a in mainline for uspace/drv/uhci/uhci.c
- Timestamp:
- 2011-01-25T20:44:28Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b00163f
- Parents:
- 7977fa1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci/uhci.c
r7977fa1 r89a0485a 22 22 if (!instance) 23 23 { return ENOMEM; } 24 memset( instance, 0, sizeof(uhci_t) );24 bzero( instance, sizeof(uhci_t) ); 25 25 26 26 /* init address keeper(libusb) */ … … 86 86 return ENOTSUP; 87 87 88 callback_t *job = malloc(sizeof(callback_t)); 89 if (job == NULL) { 90 uhci_print_error("Failed to allocate callback structure.\n"); 91 return ENOMEM; 92 } 88 transfer_descriptor_t *td = NULL; 89 callback_t *job = NULL; 90 int ret = EOK; 93 91 94 #define CHECK_RET_ FREE_JOB(r,message) \95 if (r != EOK) { \92 #define CHECK_RET_TRANS_FREE_JOB_TD(message) \ 93 if (ret != EOK) { \ 96 94 uhci_print_error(message); \ 97 callback_fini(job); \ 98 trans_free(job); \ 99 return r; \ 95 if (job) { \ 96 callback_fini(job); \ 97 trans_free(job); \ 98 } \ 99 if (td) { trans_free(td); } \ 100 return ret; \ 100 101 } else (void) 0 101 102 102 int ret = callback_in_init(job, dev, buffer, size, callback, arg);103 CHECK_RET_FREE_JOB(ret, "Failed to initialize callback structure.\n");104 103 105 transfer_descriptor_t *td = trans_malloc(sizeof(transfer_descriptor_t)); 106 ret = (td == NULL) ? ENOMEM : EOK; 107 CHECK_RET_FREE_JOB(ret, "Failed to allocate tranfer descriptor.\n"); 104 job = malloc(sizeof(callback_t)); 105 ret= job ? EOK : ENOMEM; 106 CHECK_RET_TRANS_FREE_JOB_TD("Failed to allocate callback structure.\n"); 107 108 ret = callback_in_init(job, dev, buffer, size, callback, arg); 109 CHECK_RET_TRANS_FREE_JOB_TD("Failed to initialize callback structure.\n"); 110 111 td = trans_malloc(sizeof(transfer_descriptor_t)); 112 ret = td ? ENOMEM : EOK; 113 CHECK_RET_TRANS_FREE_JOB_TD("Failed to allocate tranfer descriptor.\n"); 108 114 109 115 ret = transfer_descriptor_init(td, 3, size, false, target, USB_PID_IN); 110 if (ret != EOK) { 111 uhci_print_error("Failed to initialize transfer descriptor.\n"); 112 trans_free(td); 113 trans_free(job); 114 return ret; 115 } 116 CHECK_RET_TRANS_FREE_JOB_TD("Failed to initialize transfer descriptor.\n"); 117 116 118 td->callback = job; 117 119 120 assert(dev); 121 uhci_t *instance = (uhci_t*)dev->driver_data; 122 assert(instance); 118 123 119 // TODO: add to list120 // callback(dev, USB_OUTCOME_OK, size, arg);124 ret = transfer_list_append(&instance->transfers[transfer_type], td); 125 CHECK_RET_TRANS_FREE_JOB_TD("Failed to append transfer descriptor.\n"); 121 126 122 127 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.