Changeset a35b458 in mainline for kernel/genarch/src/ofw/ofw_tree.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/ofw/ofw_tree.c
r3061bc1 ra35b458 70 70 return &node->property[i]; 71 71 } 72 72 73 73 return NULL; 74 74 } … … 87 87 if ((!prop) || (prop->size < 2)) 88 88 return NULL; 89 89 90 90 return prop->value; 91 91 } … … 110 110 return cur; 111 111 } 112 112 113 113 /* 114 114 * Disambigued name not found. … … 122 122 return cur; 123 123 } 124 124 125 125 return NULL; 126 126 } … … 141 141 ofw_tree_property_t *prop = 142 142 ofw_tree_getprop(cur, "device_type"); 143 143 144 144 if ((!prop) || (!prop->value)) 145 145 continue; 146 146 147 147 if (str_cmp(prop->value, dtype) == 0) 148 148 return cur; 149 149 } 150 150 151 151 return NULL; 152 152 } … … 170 170 if (cur->node_handle == handle) 171 171 return cur; 172 172 173 173 if (cur->child) { 174 174 ofw_tree_node_t *node = … … 178 178 } 179 179 } 180 180 181 181 return NULL; 182 182 } … … 197 197 ofw_tree_property_t *prop = 198 198 ofw_tree_getprop(cur, "device_type"); 199 199 200 200 if ((!prop) || (!prop->value)) 201 201 continue; 202 202 203 203 if (str_cmp(prop->value, dtype) == 0) 204 204 return cur; 205 205 } 206 206 207 207 return NULL; 208 208 } … … 223 223 ofw_tree_property_t *prop = 224 224 ofw_tree_getprop(cur, "name"); 225 225 226 226 if ((!prop) || (!prop->value)) 227 227 continue; 228 228 229 229 if (str_cmp(prop->value, name) == 0) 230 230 return cur; 231 231 } 232 232 233 233 return NULL; 234 234 } … … 246 246 if (path[0] != '/') 247 247 return NULL; 248 248 249 249 ofw_tree_node_t *node = ofw_root; 250 250 size_t j; 251 251 252 252 for (size_t i = 1; (i < str_size(path)) && (node); i = j + 1) { 253 253 for (j = i; (j < str_size(path)) && (path[j] != '/'); j++); 254 254 255 255 /* Skip extra slashes */ 256 256 if (i == j) 257 257 continue; 258 258 259 259 char buf[NAME_BUF_LEN + 1]; 260 260 memcpy(buf, &path[i], j - i); … … 262 262 node = ofw_tree_find_child(node, buf); 263 263 } 264 264 265 265 return node; 266 266 } … … 285 285 ofw_tree_property_t *prop = 286 286 ofw_tree_getprop(cur, "device_type"); 287 287 288 288 if ((prop) && (prop->value) && (str_cmp(prop->value, dtype) == 0)) { 289 289 bool ret = walker(cur, arg); … … 291 291 return false; 292 292 } 293 293 294 294 if (cur->child) { 295 295 bool ret = … … 299 299 } 300 300 } 301 301 302 302 return true; 303 303 } … … 336 336 { 337 337 ofw_tree_node_t *node = (ofw_tree_node_t *) data; 338 338 339 339 /* Compute serialized data size */ 340 340 *size = 0; … … 342 342 *size += str_size(node->property[i].name) + 1 + 343 343 sizeof(node->property[i].size) + node->property[i].size; 344 344 345 345 if (dry_run) 346 346 return NULL; 347 347 348 348 void *dump = malloc(*size, FRAME_ATOMIC); 349 349 if (dump == NULL) { … … 351 351 return NULL; 352 352 } 353 353 354 354 /* Serialize the data */ 355 355 size_t pos = 0; … … 358 358 str_cpy(dump + pos, *size - pos, node->property[i].name); 359 359 pos += str_size(node->property[i].name) + 1; 360 360 361 361 /* Value size */ 362 362 memcpy(dump + pos, &node->property[i].size, 363 363 sizeof(node->property[i].size)); 364 364 pos += sizeof(node->property[i].size); 365 365 366 366 /* Value */ 367 367 memcpy(dump + pos, node->property[i].value, … … 369 369 pos += node->property[i].size; 370 370 } 371 371 372 372 return ((void *) dump); 373 373 } … … 385 385 { 386 386 char *cur_path = (char *) malloc(PATH_MAX_LEN, 0); 387 387 388 388 for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) { 389 389 if ((cur->parent) && (path)) … … 391 391 else 392 392 snprintf(cur_path, PATH_MAX_LEN, "firmware.%s", cur->da_name); 393 393 394 394 sysinfo_set_item_gen_data(cur_path, NULL, ofw_sysinfo_properties, 395 395 (void *) cur); 396 396 397 397 if (cur->child) 398 398 ofw_tree_node_sysinfo(cur->child, cur_path); 399 399 } 400 400 401 401 free(cur_path); 402 402 }
Note:
See TracChangeset
for help on using the changeset viewer.