Changeset ba038f4 in mainline for uspace/lib/usb/src/host/usb_endpoint_manager.c
- Timestamp:
- 2011-04-09T22:03:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a19a2d7
- Parents:
- 501e5df
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/host/usb_endpoint_manager.c
r501e5df rba038f4 31 31 #include <errno.h> 32 32 33 #include <usb/debug.h> 33 34 #include <usb/host/usb_endpoint_manager.h> 34 35 … … 80 81 endpoint_destroy(node->ep); 81 82 free(node); 83 } 84 /*----------------------------------------------------------------------------*/ 85 static void node_toggle_reset_filtered(link_t *item, void *arg) 86 { 87 assert(item); 88 node_t *node = hash_table_get_instance(item, node_t, link); 89 usb_target_t *target = arg; 90 endpoint_toggle_reset_filtered(node->ep, *target); 82 91 } 83 92 /*----------------------------------------------------------------------------*/ … … 230 239 return node->ep; 231 240 } 241 /*----------------------------------------------------------------------------*/ 242 /** Check setup packet data for signs of toggle reset. 243 * 244 * @param[in] instance Device keeper structure to use. 245 * @param[in] target Device to receive setup packet. 246 * @param[in] data Setup packet data. 247 * 248 * Really ugly one. 249 */ 250 void usb_endpoint_manager_reset_if_need( 251 usb_endpoint_manager_t *instance, usb_target_t target, const uint8_t *data) 252 { 253 assert(instance); 254 if (target.endpoint > 15 || target.endpoint < 0 255 || target.address >= USB11_ADDRESS_MAX || target.address < 0) { 256 usb_log_error("Invalid data when checking for toggle reset.\n"); 257 return; 258 } 259 260 switch (data[1]) 261 { 262 case 0x01: /*clear feature*/ 263 /* recipient is endpoint, value is zero (ENDPOINT_STALL) */ 264 if (((data[0] & 0xf) == 1) && ((data[2] | data[3]) == 0)) { 265 /* endpoint number is < 16, thus first byte is enough */ 266 usb_target_t reset_target = 267 { .address = target.address, data[4] }; 268 fibril_mutex_lock(&instance->guard); 269 hash_table_apply(&instance->ep_table, 270 node_toggle_reset_filtered, &reset_target); 271 fibril_mutex_unlock(&instance->guard); 272 } 273 break; 274 275 case 0x9: /* set configuration */ 276 case 0x11: /* set interface */ 277 /* target must be device */ 278 if ((data[0] & 0xf) == 0) { 279 usb_target_t reset_target = 280 { .address = target.address, 0 }; 281 fibril_mutex_lock(&instance->guard); 282 hash_table_apply(&instance->ep_table, 283 node_toggle_reset_filtered, &reset_target); 284 fibril_mutex_unlock(&instance->guard); 285 } 286 break; 287 } 288 }
Note:
See TracChangeset
for help on using the changeset viewer.