Changeset dc4c19e in mainline for uspace/drv/usbhub/utils.c
- Timestamp:
- 2011-04-10T12:18:09Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 60c0573
- Parents:
- a49e171 (diff), 82e8861 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/utils.c
ra49e171 rdc4c19e 60 60 size_t size = 7; 61 61 //variable size according to port count 62 size_t var_size = descriptor->ports_count / 8 + ((descriptor->ports_count % 8 > 0) ? 1 : 0);62 size_t var_size = (descriptor->ports_count+7)/8; 63 63 size += 2 * var_size; 64 uint8_t * result = (uint8_t*)malloc(size);64 uint8_t * result = malloc(size); 65 65 //size 66 66 result[0] = size; … … 84 84 } 85 85 86 usb_hub_descriptor_t * usb_deserialize_hub_desriptor(void * serialized_descriptor) { 87 uint8_t * sdescriptor = (uint8_t*) serialized_descriptor; 86 usb_hub_descriptor_t * usb_deserialize_hub_desriptor( 87 void * serialized_descriptor) { 88 uint8_t * sdescriptor = serialized_descriptor; 88 89 89 90 if (sdescriptor[1] != USB_DESCTYPE_HUB) { 90 usb_log_warning("trying to deserialize wrong descriptor %x\n",sdescriptor[1]); 91 usb_log_warning("trying to deserialize wrong descriptor %x\n", 92 sdescriptor[1]); 91 93 return NULL; 92 94 } 93 95 94 usb_hub_descriptor_t * result = usb_new(usb_hub_descriptor_t);96 usb_hub_descriptor_t * result = malloc(sizeof(usb_hub_descriptor_t)); 95 97 96 98 … … 100 102 result->pwr_on_2_good_time = sdescriptor[5]; 101 103 result->current_requirement = sdescriptor[6]; 102 size_t var_size = result->ports_count / 8 + ((result->ports_count % 8 > 0) 103 ? 1 : 0); 104 size_t var_size = (result->ports_count+7) / 8; 104 105 result->devices_removable = (uint8_t*) malloc(var_size); 105 106
Note:
See TracChangeset
for help on using the changeset viewer.