Changeset 1d1bb0f in mainline for uspace/lib/usb/src
- Timestamp:
- 2011-06-19T13:38:37Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b72efe8
- Parents:
- adfdbd5 (diff), 9724d7f (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. - Location:
- uspace/lib/usb/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/debug.c
radfdbd5 r1d1bb0f 38 38 #include <stdlib.h> 39 39 #include <stdio.h> 40 #include <ddf/log.h> 40 41 #include <usb/debug.h> 41 42 … … 67 68 if (rc > 0) { 68 69 log_stream = fopen(fname, "w"); 70 if (log_stream != NULL) { 71 setvbuf(log_stream, NULL, _IOFBF, BUFSIZ); 72 } 69 73 free(fname); 70 74 } … … 193 197 bzero(buffer_dump[buffer_dump_index], BUFFER_DUMP_LEN); 194 198 195 if (buffer == NULL) { 196 return "(null)"; 197 } 198 if (size == 0) { 199 return "(empty)"; 200 } 201 if ((dumped_size == 0) || (dumped_size > size)) { 202 dumped_size = size; 203 } 204 205 /* How many bytes are available in the output buffer. */ 206 size_t buffer_remaining_size = BUFFER_DUMP_LEN - 1 - REMAINDER_STR_LEN; 207 char *it = buffer_dump[buffer_dump_index]; 208 209 size_t index = 0; 210 211 while (index < size) { 212 /* Determine space before the number. */ 213 const char *space_before; 214 if (index == 0) { 215 space_before = ""; 216 } else if ((index % BUFFER_DUMP_GROUP_SIZE) == 0) { 217 space_before = " "; 218 } else { 219 space_before = " "; 220 } 221 222 /* 223 * Add the byte as a hexadecimal number plus the space. 224 * We do it into temporary buffer to ensure that always 225 * the whole byte is printed. 226 */ 227 int val = buffer[index]; 228 char current_byte[16]; 229 int printed = snprintf(current_byte, 16, 230 "%s%02x", space_before, val); 231 if (printed < 0) { 232 break; 233 } 234 235 if ((size_t) printed > buffer_remaining_size) { 236 break; 237 } 238 239 /* We can safely add 1, because space for end 0 is reserved. */ 240 str_append(it, buffer_remaining_size + 1, current_byte); 241 242 buffer_remaining_size -= printed; 243 /* Point at the terminator 0. */ 244 it += printed; 245 index++; 246 247 if (index >= dumped_size) { 248 break; 249 } 250 } 251 252 /* Add how many bytes were not printed. */ 253 if (index < size) { 254 snprintf(it, REMAINDER_STR_LEN, 255 REMAINDER_STR_FMT, size - index); 256 } 199 /* Do the actual dump. */ 200 ddf_dump_buffer(buffer_dump[buffer_dump_index], BUFFER_DUMP_LEN, 201 buffer, 1, size, dumped_size); 257 202 258 203 /* Next time, use the other buffer. */ -
uspace/lib/usb/src/hc.c
radfdbd5 r1d1bb0f 98 98 return EBUSY; 99 99 100 async_sess_t *sess = devman_device_connect(EXCHANGE_ SERIALIZE,100 async_sess_t *sess = devman_device_connect(EXCHANGE_ATOMIC, 101 101 connection->hc_handle, 0); 102 102 if (!sess) … … 177 177 { 178 178 async_sess_t *parent_sess = 179 devman_parent_device_connect(EXCHANGE_ SERIALIZE, dev_handle,179 devman_parent_device_connect(EXCHANGE_ATOMIC, dev_handle, 180 180 IPC_FLAG_BLOCKING); 181 181 if (!parent_sess) … … 241 241 { 242 242 async_sess_t *parent_sess = 243 devman_parent_device_connect(EXCHANGE_ SERIALIZE, device_handle,243 devman_parent_device_connect(EXCHANGE_ATOMIC, device_handle, 244 244 IPC_FLAG_BLOCKING); 245 245 if (!parent_sess) -
uspace/lib/usb/src/usb.c
radfdbd5 r1d1bb0f 58 58 }; 59 59 60 static const char *str_direction[] = { 61 "in", 62 "out", 63 "both" 64 }; 65 60 66 /** String representation for USB transfer type. 61 67 * … … 84 90 } 85 91 92 /** String representation of USB direction. 93 * 94 * @param d The direction. 95 * @return Direction as a string (in English). 96 */ 97 const char *usb_str_direction(usb_direction_t d) 98 { 99 if (d >= ARR_SIZE(str_direction)) { 100 return "invalid"; 101 } 102 return str_direction[d]; 103 } 104 86 105 /** String representation of USB speed. 87 106 *
Note:
See TracChangeset
for help on using the changeset viewer.