Changeset 584aa38 in mainline
- Timestamp:
- 2014-01-25T03:27:29Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8a81e431
- Parents:
- bfff7fd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/ohci_batch.c
rbfff7fd r584aa38 97 97 { 98 98 assert(usb_batch); 99 #define CHECK_NULL_DISPOSE_RET(ptr, message...) \100 if (ptr == NULL) { \101 usb_log_error(message); \102 ohci_transfer_batch_dispose(ohci_batch); \103 return NULL; \104 } else (void)0105 99 106 100 ohci_transfer_batch_t *ohci_batch = 107 101 calloc(1, sizeof(ohci_transfer_batch_t)); 108 CHECK_NULL_DISPOSE_RET(ohci_batch, 109 "Failed to allocate OHCI batch data.\n"); 102 if (!ohci_batch) { 103 usb_log_error("Failed to allocate OHCI batch data."); 104 goto dispose; 105 } 110 106 link_initialize(&ohci_batch->link); 111 107 ohci_batch->td_count = … … 119 115 /* We need an extra place for TD that was left at ED */ 120 116 ohci_batch->tds = calloc(ohci_batch->td_count + 1, sizeof(td_t*)); 121 CHECK_NULL_DISPOSE_RET(ohci_batch->tds, 122 "Failed to allocate OHCI transfer descriptors.\n"); 117 if (!ohci_batch->tds) { 118 usb_log_error("Failed to allocate OHCI transfer descriptors."); 119 goto dispose; 120 } 123 121 124 122 /* Add TD left over by the previous transfer */ … … 128 126 for (unsigned i = 1; i <= ohci_batch->td_count; ++i) { 129 127 ohci_batch->tds[i] = malloc32(sizeof(td_t)); 130 CHECK_NULL_DISPOSE_RET(ohci_batch->tds[i], 131 "Failed to allocate TD %d.\n", i ); 128 if (!ohci_batch->tds[i]) { 129 usb_log_error("Failed to allocate TD %d.", i); 130 goto dispose; 131 } 132 132 } 133 133 … … 141 141 ohci_batch->device_buffer = 142 142 malloc32(usb_batch->setup_size + usb_batch->buffer_size); 143 CHECK_NULL_DISPOSE_RET(ohci_batch->device_buffer, 144 "Failed to allocate device accessible buffer.\n"); 143 if (!ohci_batch->device_buffer) { 144 usb_log_error("Failed to allocate device buffer"); 145 goto dispose; 146 } 145 147 /* Copy setup data */ 146 148 memcpy(ohci_batch->device_buffer, usb_batch->setup_buffer, … … 159 161 160 162 return ohci_batch; 161 #undef CHECK_NULL_DISPOSE_RET 163 dispose: 164 ohci_transfer_batch_dispose(ohci_batch); 165 return NULL; 162 166 } 163 167
Note:
See TracChangeset
for help on using the changeset viewer.