Changeset feeac0d in mainline for uspace/lib
- Timestamp:
- 2013-09-10T16:32:35Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4982d87
- Parents:
- e8d6ce2
- Location:
- uspace/lib
- Files:
-
- 22 edited
-
block/block.c (modified) (2 diffs)
-
c/generic/adt/hash_table.c (modified) (2 diffs)
-
c/generic/adt/list.c (modified) (1 diff)
-
c/generic/cfg.c (modified) (3 diffs)
-
c/generic/devman.c (modified) (1 diff)
-
c/generic/pio_trace.c (modified) (2 diffs)
-
c/include/adt/list.h (modified) (3 diffs)
-
c/include/cfg.h (modified) (2 diffs)
-
draw/drawctx.c (modified) (1 diff)
-
drv/generic/driver.c (modified) (2 diffs)
-
drv/generic/interrupt.c (modified) (2 diffs)
-
fs/libfs.c (modified) (3 diffs)
-
graph/graph.c (modified) (5 diffs)
-
gui/connection.c (modified) (8 diffs)
-
gui/grid.c (modified) (1 diff)
-
gui/terminal.c (modified) (1 diff)
-
gui/window.c (modified) (6 diffs)
-
usbdev/src/recognise.c (modified) (1 diff)
-
usbhid/src/hiddescriptor.c (modified) (5 diffs)
-
usbhid/src/hidparser.c (modified) (13 diffs)
-
usbhid/src/hidpath.c (modified) (7 diffs)
-
usbhost/src/usb_endpoint_manager.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/block.c
re8d6ce2 rfeeac0d 93 93 fibril_mutex_lock(&dcl_lock); 94 94 95 list_foreach(dcl, cur) { 96 devcon_t *devcon = list_get_instance(cur, devcon_t, link); 95 list_foreach(dcl, link, devcon_t, devcon) { 97 96 if (devcon->service_id == service_id) { 98 97 fibril_mutex_unlock(&dcl_lock); … … 124 123 125 124 fibril_mutex_lock(&dcl_lock); 126 list_foreach(dcl, cur) { 127 devcon_t *d = list_get_instance(cur, devcon_t, link); 125 list_foreach(dcl, link, devcon_t, d) { 128 126 if (d->service_id == service_id) { 129 127 fibril_mutex_unlock(&dcl_lock); -
uspace/lib/c/generic/adt/hash_table.c
re8d6ce2 rfeeac0d 227 227 228 228 /* Check for duplicates. */ 229 list_foreach(h->bucket[idx], cur) {229 list_foreach(h->bucket[idx], link, ht_link_t, cur_link) { 230 230 /* 231 231 * We could filter out items using their hashes first, but 232 232 * calling equal() might very well be just as fast. 233 233 */ 234 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);235 234 if (h->op->equal(cur_link, item)) 236 235 return false; … … 258 257 size_t idx = h->op->key_hash(key) % h->bucket_cnt; 259 258 260 list_foreach(h->bucket[idx], cur) { 261 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link); 259 list_foreach(h->bucket[idx], link, ht_link_t, cur_link) { 262 260 /* 263 261 * Is this is the item we are looking for? We could have first -
uspace/lib/c/generic/adt/list.c
re8d6ce2 rfeeac0d 102 102 unsigned int count = 0; 103 103 104 list_foreach(*list, link) { 104 link_t *link = list_first(list); 105 while (link != NULL) { 105 106 count++; 107 link = list_next(link, list); 106 108 } 107 109 -
uspace/lib/c/generic/cfg.c
re8d6ce2 rfeeac0d 83 83 return true; 84 84 85 list_foreach(data->sections, link) { 86 const cfg_section_t *section = cfg_section_instance(link); 87 85 cfg_file_foreach(data, section) { 88 86 if (!list_empty(§ion->entries)) 89 87 return false; … … 413 411 const cfg_section_t *cfg_find_section(const cfg_file_t *data, const char *title) 414 412 { 415 list_foreach(data->sections, link) { 416 const cfg_section_t *section = cfg_section_instance(link); 417 413 cfg_file_foreach(data, section) { 418 414 if (str_cmp(section->title, title) == 0) 419 415 return section; … … 434 430 const char *cfg_find_value(const cfg_section_t *section, const char *key) 435 431 { 436 list_foreach(section->entries, link) { 437 const cfg_entry_t *entry = cfg_entry_instance(link); 438 432 cfg_section_foreach(section, entry) { 439 433 if (str_cmp(entry->key, key) == 0) 440 434 return entry->value; -
uspace/lib/c/generic/devman.c
re8d6ce2 rfeeac0d 230 230 } 231 231 232 match_id_t *match_id = NULL; 233 234 list_foreach(match_ids->ids, link) { 235 match_id = list_get_instance(link, match_id_t, link); 236 232 list_foreach(match_ids->ids, link, match_id_t, match_id) { 237 233 ipc_call_t answer2; 238 234 aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID, -
uspace/lib/c/generic/pio_trace.c
re8d6ce2 rfeeac0d 95 95 pio_regions_t *regions = get_regions(); 96 96 fibril_rwlock_read_lock(®ions->guard); 97 list_foreach(regions->list, it) { 98 assert(it); 99 region_t *reg = region_instance(it); 100 assert(reg); 97 list_foreach(regions->list, link, region_t, reg) { 101 98 if ((r >= reg->base) && (r < reg->base + reg->size)) { 102 99 if (reg->log) … … 131 128 fibril_rwlock_write_lock(®ions->guard); 132 129 list_foreach_safe(regions->list, it, next) { 133 assert(it);134 130 region_t *reg = region_instance(it); 135 assert(reg);136 131 if (r >= reg->base && (r < reg->base + reg->size)) { 137 list_remove(®->link);138 region_destroy(reg);132 list_remove(®->link); 133 region_destroy(reg); 139 134 } 140 135 } -
uspace/lib/c/include/adt/list.h
re8d6ce2 rfeeac0d 67 67 ((type *) (((void *)(link)) - list_link_to_void(&(((type *) NULL)->member)))) 68 68 69 #define list_foreach(list, iterator) \ 70 for (link_t *iterator = (list).head.next; \ 71 iterator != &(list).head; iterator = iterator->next) 69 #define list_foreach(list, member, itype, iterator) \ 70 for (itype *iterator = NULL; iterator == NULL; iterator =(itype *)1) \ 71 for (link_t *_link = (list).head.next; \ 72 iterator = list_get_instance(_link, itype, member), \ 73 _link != &(list).head; _link = _link->next) 72 74 73 75 /** Unlike list_foreach(), allows removing items while traversing a list. … … 238 240 static inline link_t *list_last(list_t *list) 239 241 { 240 return ((list->head.prev == &list->head) ? NULL : list->head.prev); 242 return (list->head.prev == &list->head) ? NULL : list->head.prev; 243 } 244 245 /** Get next item in list. 246 * 247 * @param link Current item link 248 * @param list List containing @a link 249 * 250 * @return Next item or NULL if @a link is the last item. 251 */ 252 static inline link_t *list_next(link_t *link, const list_t *list) 253 { 254 return (link->next == &list->head) ? NULL : link->next; 255 } 256 257 /** Get previous item in list. 258 * 259 * @param link Current item link 260 * @param list List containing @a link 261 * 262 * @return Previous item or NULL if @a link is the first item. 263 */ 264 static inline link_t *list_prev(link_t *link, const list_t *list) 265 { 266 return (link->prev == &list->head) ? NULL : link->prev; 241 267 } 242 268 … … 308 334 unsigned int cnt = 0; 309 335 310 list_foreach(*list, link) { 336 link_t *link = list_first(list); 337 while (link != NULL) { 311 338 if (cnt == n) 312 339 return link; 313 340 314 341 cnt++; 342 link = list_next(link, list); 315 343 } 316 344 -
uspace/lib/c/include/cfg.h
re8d6ce2 rfeeac0d 80 80 81 81 #define cfg_file_foreach(file, cur) \ 82 list_foreach((file)->sections, (cur))82 list_foreach((file)->sections, link, const cfg_section_t, (cur)) 83 83 84 84 #define cfg_section_instance(cur) \ … … 86 86 87 87 #define cfg_section_foreach(section, cur) \ 88 list_foreach((section)->entries, (cur))88 list_foreach((section)->entries, link, const cfg_entry_t, (cur)) 89 89 90 90 #define cfg_entry_instance(cur) \ -
uspace/lib/draw/drawctx.c
re8d6ce2 rfeeac0d 188 188 * transferred to the original surface. */ 189 189 190 list_foreach(*((list_t *) path), link) { 191 path_step_t *step = (path_step_t *) link; 190 list_foreach(*((list_t *) path), link, path_step_t, step) { 192 191 switch (step->type) { 193 192 case PATH_STEP_MOVETO: -
uspace/lib/drv/generic/driver.c
re8d6ce2 rfeeac0d 98 98 static ddf_dev_t *driver_get_device(devman_handle_t handle) 99 99 { 100 ddf_dev_t *dev = NULL;101 102 100 assert(fibril_mutex_is_locked(&devices_mutex)); 103 101 104 list_foreach(devices, link) { 105 dev = list_get_instance(link, ddf_dev_t, link); 102 list_foreach(devices, link, ddf_dev_t, dev) { 106 103 if (dev->handle == handle) 107 104 return dev; … … 113 110 static ddf_fun_t *driver_get_function(devman_handle_t handle) 114 111 { 115 ddf_fun_t *fun = NULL;116 117 112 assert(fibril_mutex_is_locked(&functions_mutex)); 118 113 119 list_foreach(functions, link) { 120 fun = list_get_instance(link, ddf_fun_t, link); 114 list_foreach(functions, link, ddf_fun_t, fun) { 121 115 if (fun->handle == handle) 122 116 return fun; -
uspace/lib/drv/generic/interrupt.c
re8d6ce2 rfeeac0d 138 138 interrupt_context_list_t *list, int id) 139 139 { 140 interrupt_context_t *ctx; 141 142 fibril_mutex_lock(&list->mutex); 143 144 list_foreach(list->contexts, link) { 145 ctx = list_get_instance(link, interrupt_context_t, link); 140 fibril_mutex_lock(&list->mutex); 141 142 list_foreach(list->contexts, link, interrupt_context_t, ctx) { 146 143 if (ctx->id == id) { 147 144 fibril_mutex_unlock(&list->mutex); … … 157 154 interrupt_context_list_t *list, ddf_dev_t *dev, int irq) 158 155 { 159 interrupt_context_t *ctx; 160 161 fibril_mutex_lock(&list->mutex); 162 163 list_foreach(list->contexts, link) { 164 ctx = list_get_instance(link, interrupt_context_t, link); 156 fibril_mutex_lock(&list->mutex); 157 158 list_foreach(list->contexts, link, interrupt_context_t, ctx) { 165 159 if (ctx->irq == irq && ctx->dev == dev) { 166 160 fibril_mutex_unlock(&list->mutex); -
uspace/lib/fs/libfs.c
re8d6ce2 rfeeac0d 882 882 883 883 fibril_mutex_lock(&instances_mutex); 884 list_foreach(instances_list, link) { 885 fs_instance_t *cur = list_get_instance(link, fs_instance_t, 886 link); 887 884 list_foreach(instances_list, link, fs_instance_t, cur) { 888 885 if (cur->service_id == service_id) { 889 886 fibril_mutex_unlock(&instances_mutex); … … 908 905 { 909 906 fibril_mutex_lock(&instances_mutex); 910 list_foreach(instances_list, link) { 911 fs_instance_t *inst = list_get_instance(link, fs_instance_t, 912 link); 913 907 list_foreach(instances_list, link, fs_instance_t, inst) { 914 908 if (inst->service_id == service_id) { 915 909 *idp = inst->data; … … 925 919 { 926 920 fibril_mutex_lock(&instances_mutex); 927 list_foreach(instances_list, link) { 928 fs_instance_t *inst = list_get_instance(link, fs_instance_t, 929 link); 930 921 list_foreach(instances_list, link, fs_instance_t, inst) { 931 922 if (inst->service_id == service_id) { 932 923 list_remove(&inst->link); -
uspace/lib/graph/graph.c
re8d6ce2 rfeeac0d 165 165 166 166 fibril_mutex_lock(&visualizer_list_mtx); 167 list_foreach(visualizer_list, link) { 168 visualizer_t *cur = list_get_instance(link, visualizer_t, link); 169 if (cur->reg_svc_handle == handle) { 170 vs = cur; 167 list_foreach(visualizer_list, link, visualizer_t, vcur) { 168 if (vcur->reg_svc_handle == handle) { 169 vs = vcur; 171 170 break; 172 171 } … … 182 181 183 182 fibril_mutex_lock(&renderer_list_mtx); 184 list_foreach(renderer_list, link) { 185 renderer_t *cur = list_get_instance(link, renderer_t, link); 186 if (cur->reg_svc_handle == handle) { 187 rnd = cur; 183 list_foreach(renderer_list, link, renderer_t, rcur) { 184 if (rcur->reg_svc_handle == handle) { 185 rnd = rcur; 188 186 break; 189 187 } … … 322 320 fibril_mutex_lock(&vs->mode_mtx); 323 321 vslmode_list_element_t *mode_elem = NULL; 324 list_foreach(vs->modes, link) { 325 vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link); 322 list_foreach(vs->modes, link, vslmode_list_element_t, cur) { 326 323 if (cur->mode.index == vs->def_mode_idx) { 327 324 mode_elem = cur; … … 382 379 fibril_mutex_lock(&vs->mode_mtx); 383 380 vslmode_list_element_t *mode_elem = NULL; 384 list_foreach(vs->modes, link) { 385 vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link); 381 list_foreach(vs->modes, link, vslmode_list_element_t, cur) { 386 382 if (cur->mode.index == mode_idx) { 387 383 mode_elem = cur; … … 425 421 fibril_mutex_lock(&vs->mode_mtx); 426 422 vslmode_list_element_t *mode_elem = NULL; 427 list_foreach(vs->modes, link) { 428 vslmode_list_element_t *cur = list_get_instance(link, vslmode_list_element_t, link); 423 list_foreach(vs->modes, link, vslmode_list_element_t, cur) { 429 424 if (cur->mode.index == mode_idx) { 430 425 mode_elem = cur; -
uspace/lib/gui/connection.c
re8d6ce2 rfeeac0d 65 65 66 66 signal_node_t *sig_node = NULL; 67 list_foreach(connection_list, link) { 68 signal_node_t *cur = list_get_instance(link, signal_node_t, link); 67 list_foreach(connection_list, link, signal_node_t, cur) { 69 68 if (cur->signal == signal) { 70 69 sig_node = cur; … … 88 87 89 88 slot_node_t *slt_node = NULL; 90 list_foreach(sig_node->slots, link) { 91 slot_node_t *cur = list_get_instance(link, slot_node_t, link); 89 list_foreach(sig_node->slots, link, slot_node_t, cur) { 92 90 if (cur->widget == widget && cur->slot == slot) { 93 91 slt_node = cur; … … 121 119 122 120 signal_node_t *sig_node = NULL; 123 list_foreach(connection_list, link) { 124 signal_node_t *cur = list_get_instance(link, signal_node_t, link); 121 list_foreach(connection_list, link, signal_node_t, cur) { 125 122 if (cur->signal == signal) { 126 123 sig_node = cur; … … 135 132 136 133 slot_node_t *slt_node = NULL; 137 list_foreach(sig_node->slots, link) { 138 slot_node_t *cur = list_get_instance(link, slot_node_t, link); 134 list_foreach(sig_node->slots, link, slot_node_t, cur) { 139 135 if (cur->widget == widget && cur->slot == slot) { 140 136 slt_node = cur; … … 164 160 165 161 signal_node_t *sig_node = NULL; 166 list_foreach(connection_list, link) { 167 signal_node_t *cur = list_get_instance(link, signal_node_t, link); 162 list_foreach(connection_list, link, signal_node_t, cur) { 168 163 if (cur->signal == signal) { 169 164 sig_node = cur; … … 177 172 } 178 173 179 list_foreach(sig_node->slots, link) { 180 slot_node_t *cur = list_get_instance(link, slot_node_t, link); 174 list_foreach(sig_node->slots, link, slot_node_t, cur) { 181 175 cur->slot(cur->widget, data); 182 176 } … … 190 184 191 185 signal_node_t *sig_node = NULL; 192 list_foreach(connection_list, link) { 193 signal_node_t *cur = list_get_instance(link, signal_node_t, link); 186 list_foreach(connection_list, link, signal_node_t, cur) { 194 187 if (cur->signal == signal) { 195 188 sig_node = cur; … … 203 196 } 204 197 205 list_foreach(sig_node->slots, link) { 206 slot_node_t *cur = list_get_instance(link, slot_node_t, link); 207 198 list_foreach(sig_node->slots, link, slot_node_t, cur) { 208 199 void *data_copy = NULL; 209 200 if (data != NULL) { -
uspace/lib/gui/grid.c
re8d6ce2 rfeeac0d 298 298 paint_internal(widget); 299 299 300 list_foreach(widget->children, link) { 301 widget_t *child = list_get_instance(link, widget_t, link); 300 list_foreach(widget->children, link, widget_t, child) { 302 301 child->repaint(child); 303 302 } -
uspace/lib/gui/terminal.c
re8d6ce2 rfeeac0d 685 685 terminal_t *term = NULL; 686 686 687 list_foreach(terms, link) { 688 terminal_t *cur = list_get_instance(link, terminal_t, link); 689 687 list_foreach(terms, link, terminal_t, cur) { 690 688 if (cur->dsid == (service_id_t) IPC_GET_ARG1(*icall)) { 691 689 term = cur; -
uspace/lib/gui/window.c
re8d6ce2 rfeeac0d 137 137 { 138 138 if (widget->window->is_decorated) { 139 list_foreach(widget->children, link) { 140 widget_t *child = list_get_instance(link, widget_t, link); 139 list_foreach(widget->children, link, widget_t, child) { 141 140 child->rearrange(child, 142 141 widget->hpos + border_thickness, … … 146 145 } 147 146 } else { 148 list_foreach(widget->children, link) { 149 widget_t *child = list_get_instance(link, widget_t, link); 147 list_foreach(widget->children, link, widget_t, child) { 150 148 child->rearrange(child, widget->hpos, widget->vpos, 151 149 widget->width, widget->height); … … 160 158 if (widget->window->is_decorated) { 161 159 paint_internal(widget); 162 list_foreach(widget->children, link) { 163 widget_t *child = list_get_instance(link, widget_t, link); 160 list_foreach(widget->children, link, widget_t, child) { 164 161 child->rearrange(child, 165 162 hpos + border_thickness, … … 169 166 } 170 167 } else { 171 list_foreach(widget->children, link) { 172 widget_t *child = list_get_instance(link, widget_t, link); 168 list_foreach(widget->children, link, widget_t, child) { 173 169 child->rearrange(child, hpos, vpos, width, height); 174 170 } … … 181 177 paint_internal(widget); 182 178 } 183 list_foreach(widget->children, link) { 184 widget_t *child = list_get_instance(link, widget_t, link); 179 list_foreach(widget->children, link, widget_t, child) { 185 180 child->repaint(child); 186 181 } … … 268 263 win_grab(widget->window->osess, event.pos_id, flags); 269 264 } else { 270 list_foreach(widget->children, link) { 271 widget_t *child = list_get_instance(link, widget_t, link); 265 list_foreach(widget->children, link, widget_t, child) { 272 266 child->handle_position_event(child, event); 273 267 } 274 268 } 275 269 } else { 276 list_foreach(widget->children, link) { 277 widget_t *child = list_get_instance(link, widget_t, link); 270 list_foreach(widget->children, link, widget_t, child) { 278 271 child->handle_position_event(child, event); 279 272 } -
uspace/lib/usbdev/src/recognise.c
re8d6ce2 rfeeac0d 383 383 goto failure; 384 384 385 list_foreach(match_ids.ids, id_link) { 386 match_id_t *match_id = list_get_instance(id_link, match_id_t, link); 385 list_foreach(match_ids.ids, link, match_id_t, match_id) { 387 386 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 388 387 if (rc != EOK) { -
uspace/lib/usbhid/src/hiddescriptor.c
re8d6ce2 rfeeac0d 333 333 } 334 334 335 usb_hid_report_description_t *report_des = NULL; 336 337 list_foreach(report->reports, report_it) { 338 report_des = list_get_instance(report_it, 339 usb_hid_report_description_t, reports_link); 340 335 list_foreach(report->reports, reports_link, 336 usb_hid_report_description_t, report_des) { 341 337 // if report id not set, return the first of the type 342 338 if(((report_des->report_id == report_id) || (report_id == 0)) && … … 902 898 void usb_hid_descriptor_print_list(list_t *list) 903 899 { 904 usb_hid_report_field_t *report_item;905 906 900 if(list == NULL || list_empty(list)) { 907 901 usb_log_debug("\tempty\n"); … … 909 903 } 910 904 911 list_foreach(*list, item) { 912 report_item = list_get_instance(item, usb_hid_report_field_t, 913 ritems_link); 914 905 list_foreach(*list, ritems_link, usb_hid_report_field_t, 906 report_item) { 915 907 usb_log_debug("\t\tOFFSET: %X\n", report_item->offset); 916 908 usb_log_debug("\t\tSIZE: %zu\n", report_item->size); … … 937 929 938 930 usb_log_debug("\n"); 939 940 } 941 931 } 942 932 } 943 933 … … 951 941 void usb_hid_descriptor_print(usb_hid_report_t *report) 952 942 { 953 if (report == NULL) {943 if (report == NULL) 954 944 return; 955 } 956 957 usb_hid_report_description_t *report_des; 958 959 list_foreach(report->reports, report_it) { 960 report_des = list_get_instance(report_it, 961 usb_hid_report_description_t, reports_link); 945 946 list_foreach(report->reports, reports_link, 947 usb_hid_report_description_t, report_des) { 962 948 usb_log_debug("Report ID: %d\n", report_des->report_id); 963 949 usb_log_debug("\tType: %d\n", report_des->type); -
uspace/lib/usbhid/src/hidparser.c
re8d6ce2 rfeeac0d 130 130 size_t size, uint8_t *report_id) 131 131 { 132 usb_hid_report_field_t *item;133 134 132 usb_hid_report_description_t *report_des; 135 133 usb_hid_report_type_t type = USB_HID_REPORT_TYPE_INPUT; 136 134 137 135 if (report == NULL) { 138 136 return EINVAL; … … 153 151 154 152 /* read data */ 155 list_foreach(report_des->report_items, list_item) { 156 item = list_get_instance(list_item, usb_hid_report_field_t, 157 ritems_link); 153 list_foreach(report_des->report_items, ritems_link, 154 usb_hid_report_field_t, item) { 158 155 159 156 if (USB_HID_ITEM_FLAG_CONSTANT(item->item_flags) == 0) { 160 157 161 158 if (USB_HID_ITEM_FLAG_VARIABLE(item->item_flags) == 0) { 162 159 /* array */ 163 160 item->value = 164 161 usb_hid_translate_data(item, data); 165 162 166 163 item->usage = USB_HID_EXTENDED_USAGE( 167 164 item->usages[item->value - … … 184 181 /* variable item */ 185 182 item->value = usb_hid_translate_data(item, 186 data); 187 } 183 data); 184 } 188 185 } 189 186 } 190 187 191 188 return EOK; 192 189 } … … 295 292 usb_hid_report_description_t *report_des = NULL; 296 293 297 list_foreach(report->reports, report_it) { 298 report_des = list_get_instance(report_it, 299 usb_hid_report_description_t, reports_link); 300 294 list_foreach(report->reports, reports_link, 295 usb_hid_report_description_t, report_des) { 301 296 if ((report_des->report_id == report_id) && 302 297 (report_des->type == USB_HID_REPORT_TYPE_OUTPUT)) { … … 345 340 int length; 346 341 int32_t tmp_value; 347 342 348 343 if (report == NULL) { 349 344 return EINVAL; … … 351 346 352 347 if (report->use_report_ids != 0) { 353 buffer[0] = report_id; 348 buffer[0] = report_id; 354 349 } 355 350 … … 357 352 report_des = usb_hid_report_find_description(report, report_id, 358 353 USB_HID_REPORT_TYPE_OUTPUT); 359 354 360 355 if (report_des == NULL) { 361 356 return EINVAL; 362 357 } 363 358 364 usb_hid_report_field_t *report_item; 365 366 list_foreach(report_des->report_items, item) { 367 report_item = list_get_instance(item, usb_hid_report_field_t, 368 ritems_link); 369 359 list_foreach(report_des->report_items, ritems_link, 360 usb_hid_report_field_t, report_item) { 370 361 value = usb_hid_translate_data_reverse(report_item, 371 362 report_item->value); … … 373 364 offset = report_des->bit_length - report_item->offset - 1; 374 365 length = report_item->size; 375 366 376 367 usb_log_debug("\ttranslated value: %x\n", value); 377 368 … … 382 373 } 383 374 size_t shift = 8 - offset % 8 - length; 384 value = value << shift; 375 value = value << shift; 385 376 value = value & (((1 << length) - 1) << shift); 386 377 387 378 uint8_t mask = 0; 388 379 mask = 0xff - (((1 << length) - 1) << shift); … … 400 391 401 392 tmp_value = tmp_value << (offset % 8); 402 393 403 394 mask = ~(((1 << (8 - (offset % 8))) - 1) 404 395 << (offset % 8)); … … 407 398 tmp_value; 408 399 } else if (i == ((offset + length - 1) / 8)) { 409 400 410 401 value = value >> (length - 411 402 ((offset + length) % 8)); … … 413 404 value = value & ((1 << (length - 414 405 ((offset + length) % 8))) - 1); 415 406 416 407 mask = (1 << (length - 417 408 ((offset + length) % 8))) - 1; … … 427 418 report_item->value = 0; 428 419 } 429 420 430 421 return EOK; 431 422 } -
uspace/lib/usbhid/src/hidpath.c
re8d6ce2 rfeeac0d 176 176 usb_log_debug("\tLENGTH: %d\n", path->depth); 177 177 178 usb_hid_report_usage_path_t *path_item; 179 180 list_foreach(path->items, item) { 181 path_item = list_get_instance(item, usb_hid_report_usage_path_t, 182 rpath_items_link); 178 list_foreach(path->items, rpath_items_link, 179 usb_hid_report_usage_path_t, path_item) { 183 180 184 181 usb_log_debug("\tUSAGE_PAGE: %X\n", path_item->usage_page); … … 237 234 usb_hid_report_usage_path_t, rpath_items_link); 238 235 239 list_foreach(report_path->items, report_link) { 240 report_item = list_get_instance(report_link, 241 usb_hid_report_usage_path_t, rpath_items_link); 242 236 list_foreach(report_path->items, rpath_items_link, 237 usb_hid_report_usage_path_t, report_item) { 238 243 239 if(USB_HID_SAME_USAGE_PAGE(report_item->usage_page, 244 240 path_item->usage_page)){ 245 241 246 242 if(only_page == 0){ 247 243 if(USB_HID_SAME_USAGE( 248 244 report_item->usage, 249 245 path_item->usage)) { 250 246 251 247 return EOK; 252 248 } … … 266 262 return 1; 267 263 } 268 264 269 265 /* path is prefix of the report_path */ 270 266 case USB_HID_PATH_COMPARE_BEGIN: 271 267 272 268 report_link = report_path->items.head.next; 273 269 path_link = path->items.head.next; 274 270 275 271 while((report_link != &report_path->items.head) && 276 272 (path_link != &path->items.head)) { 277 273 278 274 report_item = list_get_instance(report_link, 279 275 usb_hid_report_usage_path_t, rpath_items_link); 280 276 281 277 path_item = list_get_instance(path_link, 282 278 usb_hid_report_usage_path_t, rpath_items_link); … … 286 282 !USB_HID_SAME_USAGE(report_item->usage, 287 283 path_item->usage))) { 288 284 289 285 return 1; 290 } 291 else { 286 } else { 292 287 report_link = report_link->next; 293 path_link = path_link->next; 288 path_link = path_link->next; 294 289 } 295 296 290 } 297 291 … … 300 294 ((report_link == &report_path->items.head) && 301 295 (path_link == &path->items.head))) { 302 296 303 297 return EOK; 304 298 } … … 405 399 usb_hid_report_path_t *usage_path) 406 400 { 407 usb_hid_report_usage_path_t *path_item;408 401 usb_hid_report_usage_path_t *new_path_item; 409 402 usb_hid_report_path_t *new_usage_path = usb_hid_report_path (); … … 419 412 } 420 413 421 list_foreach(usage_path->items, path_link) { 422 path_item = list_get_instance(path_link, 423 usb_hid_report_usage_path_t, rpath_items_link); 414 list_foreach(usage_path->items, rpath_items_link, 415 usb_hid_report_usage_path_t, path_item) { 424 416 425 417 new_path_item = malloc(sizeof(usb_hid_report_usage_path_t)); -
uspace/lib/usbhost/src/usb_endpoint_manager.c
re8d6ce2 rfeeac0d 90 90 if (address < 0) 91 91 return NULL; 92 list_foreach(*get_list(instance, address), iterator) { 93 endpoint_t *ep = endpoint_get_instance(iterator); 92 list_foreach(*get_list(instance, address), link, endpoint_t, ep) { 94 93 if (ep_match(ep, address, endpoint, direction)) 95 94 return ep; … … 196 195 fibril_mutex_lock(&instance->guard); 197 196 /* endpoint number is < 16, thus first byte is enough */ 198 list_foreach(*get_list(instance, target.address), it) {199 endpoint_t *ep = endpoint_get_instance(it);197 list_foreach(*get_list(instance, target.address), 198 link, endpoint_t, ep) { 200 199 if ((ep->address == target.address) 201 200 && (ep->endpoint = data[4])) { … … 216 215 if ((data[0] & 0xf) == 0) { 217 216 fibril_mutex_lock(&instance->guard); 218 list_foreach(*get_list(instance, target.address), it) {219 endpoint_t *ep = endpoint_get_instance(it);217 list_foreach(*get_list(instance, target.address), 218 link, endpoint_t, ep) { 220 219 if (ep->address == target.address) { 221 220 endpoint_toggle_set(ep,0); … … 408 407 usb_address_t address, void (*callback)(endpoint_t *, void *), void *arg) 409 408 { 409 list_t *list; 410 link_t *link; 411 link_t *next; 412 410 413 assert(address >= 0); 411 414 assert(instance); 412 415 fibril_mutex_lock(&instance->guard); 413 list_foreach(*get_list(instance, address), iterator) { 414 endpoint_t *ep = endpoint_get_instance(iterator); 416 417 list = get_list(instance, address); 418 link = list_first(list); 419 while (link != NULL) { 420 endpoint_t *ep = list_get_instance(link, endpoint_t, link); 421 next = list_next(link, list); 422 415 423 if (ep->address == address) { 416 iterator = iterator->next;417 424 list_remove(&ep->link); 418 425 if (callback) … … 420 427 endpoint_destroy(ep); 421 428 } 429 link = next; 422 430 } 423 431 fibril_mutex_unlock(&instance->guard);
Note:
See TracChangeset
for help on using the changeset viewer.
