Changes in uspace/drv/vhc/devices.c [bd8c753d:13101d06] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/vhc/devices.c
rbd8c753d r13101d06 27 27 */ 28 28 29 /** @addtogroup drvusbvhc29 /** @addtogroup usb 30 30 * @{ 31 31 */ … … 58 58 /** Create virtual device. 59 59 * 60 * @param address USB address. 60 61 * @param phone Callback phone. 61 * @param id Device id.62 62 * @return New device. 63 * @retval NULL Out of memory .63 * @retval NULL Out of memory or address already occupied. 64 64 */ 65 virtdev_connection_t *virtdev_add_device(int phone , sysarg_t id)65 virtdev_connection_t *virtdev_add_device(int phone) 66 66 { 67 67 virtdev_connection_t *dev = (virtdev_connection_t *) 68 68 malloc(sizeof(virtdev_connection_t)); 69 if (dev == NULL) {70 return NULL;71 }72 73 69 dev->phone = phone; 74 dev->id = id;75 70 list_append(&dev->link, &devices); 76 71 … … 78 73 79 74 return dev; 80 }81 82 /** Find virtual device by id.83 *84 * @param id Device id.85 * @return Device with given id.86 * @retval NULL No such device.87 */88 virtdev_connection_t *virtdev_find(sysarg_t id)89 {90 link_t *pos;91 list_foreach(pos, &devices) {92 virtdev_connection_t *dev93 = list_get_instance(pos, virtdev_connection_t, link);94 if (dev->id == id) {95 return dev;96 }97 }98 99 return NULL;100 75 } 101 76 … … 115 90 usb_transaction_outcome_t virtdev_send_to_all(transaction_t *transaction) 116 91 { 117 /* For easier debugging. */118 switch (transaction->type) {119 case USBVIRT_TRANSACTION_SETUP:120 case USBVIRT_TRANSACTION_OUT:121 transaction->actual_len = transaction->len;122 break;123 case USBVIRT_TRANSACTION_IN:124 transaction->actual_len = 0;125 break;126 default:127 assert(false && "unreachable branch in switch()");128 }129 usb_transaction_outcome_t outcome = USB_OUTCOME_BABBLE;130 131 92 link_t *pos; 132 93 list_foreach(pos, &devices) { … … 180 141 rc = (int)answer_rc; 181 142 } 182 183 /*184 * If at least one device was able to accept this185 * transaction and process it, we can announce success.186 */187 if (rc == EOK) {188 outcome = USB_OUTCOME_OK;189 }190 143 } 191 144 … … 212 165 transaction->buffer, transaction->len, 213 166 &tmp); 214 transaction->actual_len = tmp; 167 if (tmp < transaction->len) { 168 transaction->len = tmp; 169 } 215 170 break; 216 171 … … 223 178 } 224 179 dprintf(4, "transaction on hub processed..."); 225 outcome = USB_OUTCOME_OK;226 180 } 227 181 … … 230 184 * real-life image. 231 185 */ 232 return outcome;186 return USB_OUTCOME_OK; 233 187 } 234 188
Note:
See TracChangeset
for help on using the changeset viewer.