Changes in uspace/drv/vhc/devices.c [daec5e04:774afaae] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/devices.c
rdaec5e04 r774afaae 27 27 */ 28 28 29 /** @addtogroup drvusbvhc29 /** @addtogroup usb 30 30 * @{ 31 31 */ … … 34 34 */ 35 35 36 #include <ipc/ipc.h> 36 37 #include <adt/list.h> 37 38 #include <bool.h> … … 57 58 /** Create virtual device. 58 59 * 60 * @param address USB address. 59 61 * @param phone Callback phone. 60 * @param id Device id.61 62 * @return New device. 62 * @retval NULL Out of memory .63 * @retval NULL Out of memory or address already occupied. 63 64 */ 64 virtdev_connection_t *virtdev_add_device(int phone , sysarg_t id)65 virtdev_connection_t *virtdev_add_device(int phone) 65 66 { 66 67 virtdev_connection_t *dev = (virtdev_connection_t *) 67 68 malloc(sizeof(virtdev_connection_t)); 68 if (dev == NULL) {69 return NULL;70 }71 72 69 dev->phone = phone; 73 dev->id = id;74 70 list_append(&dev->link, &devices); 75 71 … … 77 73 78 74 return dev; 79 }80 81 /** Find virtual device by id.82 *83 * @param id Device id.84 * @return Device with given id.85 * @retval NULL No such device.86 */87 virtdev_connection_t *virtdev_find(sysarg_t id)88 {89 link_t *pos;90 list_foreach(pos, &devices) {91 virtdev_connection_t *dev92 = list_get_instance(pos, virtdev_connection_t, link);93 if (dev->id == id) {94 return dev;95 }96 }97 98 return NULL;99 75 } 100 76 … … 112 88 * @param transaction Transaction to be sent over the bus. 113 89 */ 114 int virtdev_send_to_all(transaction_t *transaction)90 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction) 115 91 { 116 /* For easier debugging. */117 switch (transaction->type) {118 case USBVIRT_TRANSACTION_SETUP:119 case USBVIRT_TRANSACTION_OUT:120 transaction->actual_len = transaction->len;121 break;122 case USBVIRT_TRANSACTION_IN:123 transaction->actual_len = 0;124 break;125 default:126 assert(false && "unreachable branch in switch()");127 }128 int outcome = EBADCHECKSUM;129 130 92 link_t *pos; 131 93 list_foreach(pos, &devices) { … … 138 100 139 101 ipc_call_t answer_data; 140 sysarg_t answer_rc;102 ipcarg_t answer_rc; 141 103 aid_t req; 142 104 int rc = EOK; … … 176 138 } else { 177 139 async_wait_for(req, &answer_rc); 178 transaction->actual_len = IPC_GET_ARG1(answer_data);179 140 rc = (int)answer_rc; 180 }181 182 /*183 * If at least one device was able to accept this184 * transaction and process it, we can announce success.185 */186 if (rc == EOK) {187 outcome = EOK;188 141 } 189 142 } … … 195 148 if (virtual_hub_device.address == transaction->target.address) { 196 149 size_t tmp; 197 usb_log_debug2("Sending `%s' transaction to hub.\n",150 dprintf(1, "sending `%s' transaction to hub", 198 151 usbvirt_str_transaction_type(transaction->type)); 199 152 switch (transaction->type) { … … 211 164 transaction->buffer, transaction->len, 212 165 &tmp); 213 transaction->actual_len = tmp; 166 if (tmp < transaction->len) { 167 transaction->len = tmp; 168 } 214 169 break; 215 170 … … 221 176 break; 222 177 } 223 outcome = EOK;178 dprintf(4, "transaction on hub processed..."); 224 179 } 225 180 … … 228 183 * real-life image. 229 184 */ 230 return outcome;185 return USB_OUTCOME_OK; 231 186 } 232 187
Note:
See TracChangeset
for help on using the changeset viewer.