Changeset b9e3aa3 in mainline for uspace/drv/usbhub/utils.c
- Timestamp:
- 2011-05-30T14:13:53Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f3f9733
- Parents:
- 2002595 (diff), 8357fc9 (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
r2002595 rb9e3aa3 62 62 * @return newly created serializd descriptor pointer 63 63 */ 64 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t * 64 void * usb_create_serialized_hub_descriptor(usb_hub_descriptor_t *descriptor) { 65 65 //base size 66 66 size_t size = 7; 67 67 //variable size according to port count 68 size_t var_size = (descriptor->ports_count +7)/8;68 size_t var_size = (descriptor->ports_count + 7) / 8; 69 69 size += 2 * var_size; 70 70 uint8_t * result = malloc(size); 71 71 //size 72 if (result)73 usb_serialize_hub_descriptor(descriptor, result);72 if (result) 73 usb_serialize_hub_descriptor(descriptor, result); 74 74 return result; 75 75 } … … 82 82 * @param serialized_descriptor 83 83 */ 84 void usb_serialize_hub_descriptor(usb_hub_descriptor_t * 84 void usb_serialize_hub_descriptor(usb_hub_descriptor_t *descriptor, 85 85 void * serialized_descriptor) { 86 86 //base size … … 88 88 size_t size = 7; 89 89 //variable size according to port count 90 size_t var_size = (descriptor->ports_count +7)/8;90 size_t var_size = (descriptor->ports_count + 7) / 8; 91 91 size += 2 * var_size; 92 92 //size … … 110 110 } 111 111 112 113 112 /** 114 113 * create deserialized desriptor structure out of serialized descriptor … … 121 120 */ 122 121 usb_hub_descriptor_t * usb_create_deserialized_hub_desriptor( 123 void *serialized_descriptor) {122 void *serialized_descriptor) { 124 123 uint8_t * sdescriptor = serialized_descriptor; 125 124 … … 130 129 } 131 130 132 usb_hub_descriptor_t * result = malloc(sizeof (usb_hub_descriptor_t));133 if (result)134 usb_deserialize_hub_desriptor(serialized_descriptor, result);131 usb_hub_descriptor_t * result = malloc(sizeof (usb_hub_descriptor_t)); 132 if (result) 133 usb_deserialize_hub_desriptor(serialized_descriptor, result); 135 134 return result; 136 135 } … … 144 143 */ 145 144 void usb_deserialize_hub_desriptor( 146 void * serialized_descriptor, usb_hub_descriptor_t *descriptor) {145 void * serialized_descriptor, usb_hub_descriptor_t *descriptor) { 147 146 uint8_t * sdescriptor = serialized_descriptor; 148 147 descriptor->ports_count = sdescriptor[2]; … … 151 150 descriptor->pwr_on_2_good_time = sdescriptor[5]; 152 151 descriptor->current_requirement = sdescriptor[6]; 153 size_t var_size = (descriptor->ports_count +7) / 8;152 size_t var_size = (descriptor->ports_count + 7) / 8; 154 153 //descriptor->devices_removable = (uint8_t*) malloc(var_size); 155 154
Note:
See TracChangeset
for help on using the changeset viewer.